找回密码
 点一下
楼主: akasha

创建了一群 单位,对他们发动移动命令阵型的问题

[复制链接]
 楼主| 发表于 2008-8-23 12:52:32 | 显示全部楼层
我最先就是用单位组做的,48个单位,选取他们然后每0.02秒移动会比48个单位每个一个计时器卡很多哦
回复

使用道具 举报

发表于 2008-8-23 12:54:33 | 显示全部楼层
引用第17楼akasha于2008-08-23 09:08发表的  :
那个,是有考虑每个单位只受一次伤害的....local boolexpr lCheck=Condition(function JHFilter)      的
JHFilter不知道为什么发掉了,里面有考虑到,测试的时候一个单位只受到一次伤害是通过了的

昨天没注意到,不过这样写,多个技能就不能叠加了
回复

使用道具 举报

发表于 2008-8-23 12:55:40 | 显示全部楼层
引用第20楼akasha于2008-08-23 12:52发表的  :
我最先就是用单位组做的,48个单位,选取他们然后每0.02秒移动会比48个单位每个一个计时器卡很多哦

不可能
回复

使用道具 举报

 楼主| 发表于 2008-8-23 12:56:38 | 显示全部楼层
确实是这样,还没想到什么好办法...不过,其实这个并不是很重要的...可以提示减速期间不能再被冰冻....好邪恶......想不到其他办法了

不过,先不管那个效果吧,移动单位还是有问题,怎么看都比DOTA里面卡...


我怎么说您才相信啊....

我真的最先就是用的单位组,我发代码好了
回复

使用道具 举报

 楼主| 发表于 2008-8-23 12:58:32 | 显示全部楼层
[jass]function GroupAC takes nothing returns nothing  
        local timer t = CreateTimer()   
        call StoreInteger( CacheValue(), HandleName(t), "UTG", ConvertHandleInt(GetTriggerUnit()) )   
        call StoreInteger( CacheValue(), HandleName(t), "UBOO", ConvertHandleInt(GetEnumUnit()) )  
        call StoreInteger( CacheValue(), HandleName(t), "INT", 0 )  
        call TimerStart( t, 0.03, true, function boo )   
        set t = null   
endfunction  
function Trig_NewTrigger_001_Actions takes nothing returns nothing  
    local group GG = CreateGroup()
    local integer xunhuan = 0
    local location p1  
    local location p2 = GetUnitLoc(GetTriggerUnit())  
    loop  
    exitwhen xunhuan > 44
        set p1 = PolarProjectionBJ(p2, 5.00, ( ( I2R(xunhuan) + 1 ) * 8.00 ))
        call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(GetTriggerUnit()), p1, ( ( 1 + I2R(xunhuan) ) * 8.00 ) )  
        set xunhuan = xunhuan + 1  
        call GroupAddUnitSimple( GetLastCreatedUnit(),GG)  
    endloop
    call ForGroupBJ(GG, function GroupAC)  
    call GroupClear(GG)  
    call RemoveLocation(p1)  
    call RemoveLocation(p2)  
    set GG = null  
    set p1 = null  
    set p2 = null  
endfunction  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function boo takes nothing returns nothing
    local timer t = GetExpiredTimer()  
    local unit u1 = ConvertUnit( GetStoredInteger(CacheValue(), HandleName(t), "UTG") )  
    local unit u2 = ConvertUnit( GetStoredInteger(CacheValue(), HandleName(t), "UBOO"))
    local integer cs =  GetStoredInteger(CacheValue(), HandleName(t), "INT")
    local real angle = 0
    local real tempX = 0  
    local real tempY = 0  
    set angle = AngleBetweenUnits( u1, u2 )
    set tempX = GetUnitX( u2 ) + 30 * Cos( (3.14159/180) * angle  )  
    set tempY = GetUnitY( u2 ) + 30 * Sin( (3.14159/180) * angle  )
    call SetUnitX( u2, tempX )  
    call SetUnitY( u2, tempY )  
    set cs = cs +30
    call StoreInteger( CacheValue(), HandleName(t), "INT", cs )
    if(cs>700) then
    call KillUnit(u2)
    call FlushStoredMission( CacheValue(), HandleName(t) )  
    call DestroyTimer( t )  
    endif
    set t = null  
    set u1 = null  
    set u2 = null  
endfunction [/jass]

还好有保存,我测试的时候确实 单位组 的这种做法卡很多,,,,,,不知道是不是哪里写得不对~
回复

使用道具 举报

发表于 2008-8-23 13:02:02 | 显示全部楼层
这叫用单位组绑定计时器吗
回复

使用道具 举报

 楼主| 发表于 2008-8-23 13:04:01 | 显示全部楼层
听不懂,您教我吧,稍微解释吧.
回复

使用道具 举报

发表于 2008-8-23 13:13:00 | 显示全部楼层
[codes=jass]
function IceTimer takes nothing returns boolean
    local trigger t = GetTriggeringTrigger()
    local string s = H2S(t)
    local group g = GetGroup(s, "CasterGroup")
    if GetTriggerEvalCount(t) > 50 then
        call DestroyGroup(g)
        call CloseTrigger(t)
    else
        call ForGroup(g, function IceDoAnyThing)
    endif
    set t=null
    set g = null
    return false
endfunction
function IceSpell takes nothing returns nothing
    local unit source = GetTriggerUnit()
    local group g = CreateGroup()
    local unit u
    local real x = GetUnitX(source)
    local real y = GetUnitY(source)
    local integer i = 0
    local integer num = 48
    local trigger t = CreateTrigger()
    local string s = H2S(t)
    loop
        exitwhen i > num
        set u = CreateUnit(GetOwningPlayer(source),'xxxx', x, y, 360*i/num)
        call GroupAddUnit(g, u)
        set i = i + 1
    endloop
    call SetHandle(s, "CasterGroup",g)
    call SetHandle(s, "Source", source)
    call TriggerRegisterTimerEvent(t, 0.03, true)
    call TriggerAddCondition(t, Condition(function IceTimer))
    set t = null
    set u = null
    set source = null
    set g = null
endfunction
[/codes]

没测试过
回复

使用道具 举报

 楼主| 发表于 2008-8-23 13:19:32 | 显示全部楼层
弱弱的问一下这样做和我那样做最大的区别在什么地方

我太失败了,实在看不出区别。。
回复

使用道具 举报

发表于 2008-8-23 13:25:20 | 显示全部楼层
你有48个计时器,我这只用了一个,这样叠加的问题也很好处理了
回复

使用道具 举报

 楼主| 发表于 2008-8-23 13:27:12 | 显示全部楼层
叠加的问题还是不明白怎么处理?另外为什么我那么写会有48个计时器?我的意思是只做了一次单位组动作,也应该只有1个计时器啊?
回复

使用道具 举报

发表于 2008-8-23 13:31:15 | 显示全部楼层
再创建一个单位组绑定给计时器,已经伤害过的单位都加到这个单位组里去

[codes=jass]
function GroupAC takes nothing returns nothing   
            local timer t = CreateTimer()     
            call StoreInteger( CacheValue(), HandleName(t), "UTG", ConvertHandleInt(GetTriggerUnit()) )     
            call StoreInteger( CacheValue(), HandleName(t), "UBOO", ConvertHandleInt(GetEnumUnit()) )   
            call StoreInteger( CacheValue(), HandleName(t), "INT", 0 )   
            call TimerStart( t, 0.03, true, function boo )     
            set t = null     
endfunction  
[/codes]

GroupAC 为每个单位运行一次,不就有48个计时器了?
回复

使用道具 举报

 楼主| 发表于 2008-8-23 13:36:42 | 显示全部楼层
原来是这样的,我不知道选取单位会为选取的单位每个执行一次。。好像这种事应该能想到,脑残了,谢谢……

您的方法我去试试好了
回复

使用道具 举报

 楼主| 发表于 2008-8-23 18:11:56 | 显示全部楼层
额,我发现还是有点卡
那个按照您的方法做了,那个IceDoAnyThing里面我选取扩散出去的单位身边的满足不在已经受到伤害单位组里的单位

最开始没有用寒冰效果,只是按照您所说的方法模拟视觉效果,确实比之前好一些了
但是加上寒冰效果,选取单位后变得还是有点卡了…………
不知道是不是哪里写得不对,代码发上来了
如果没有什么问题的话,那就算了……都折腾这么半天了。。。

[jass]function IceDoAnyThing takes nothing returns nothing
    local unit u = udg_U_temp
    local string s = udg_D    //udg_D里面暂存的是那个触发器名字
    local boolexpr lCheck
    local real angle = GetUnitFacing(GetEnumUnit())
    local real tempX = GetUnitX( GetEnumUnit() ) + 20 * Cos( (3.14159/180) * angle  )
    local real tempY = GetUnitY( GetEnumUnit() ) + 20 * Sin( (3.14159/180) * angle  )
    local group lGroup2 = GetGroup(s,"damaged")//读取已经受到伤害的单位的单位组
    local group lGroup = CreateGroup()
    set udg_G = lGroup2
    set lCheck=Condition(function JHFilter)//这里选取不在单位组udg_G里面的单位IsUnitInGroup(GetFilterUnit(), udg_G) == false
    call GroupEnumUnitsInRange(lGroup,tempX,tempY,50,lCheck)
    call GroupAddGroup(lGroup,lGroup2)//把刚刚选取的单位组里的单位添加到已经受到伤害的单位组里面
    call SetHandle(s,"damaged",lGroup2)//把受到伤害的单位组保存下来
    set lGroup2 = null
    if(lGroup!=null) then//如果刚刚选取的单位组不为空就做动作
    set udg_U_temp2 = u
    call ForGroupBJ(lGroup1,function JHActions)//这里就是动作函数了    endif
    call SetUnitX( GetEnumUnit(), tempX )
    call SetUnitY( GetEnumUnit(), tempY )
endfunction[/jass]
其他的都是直接搬的您上面写的函数。
回复

使用道具 举报

 楼主| 发表于 2008-8-23 19:17:01 | 显示全部楼层
原来 set lGroup2 = null
如果 写的销毁lGroup2 ,缓存的lGroup2 也会没了
回复

使用道具 举报

发表于 2008-8-23 20:04:32 | 显示全部楼层
[codes=jass]
function IceDamage takes nothing returns nothing
    local string s = H2S(GetTriggeringTrigger())
    local unit u = GetFilterUnit()
    local group g = GetGroup(s, "Damaged")
    if IsUnitInGroup(u, g) == false then
        call GroupAddUnit(g, u)
        //----------
        // 伤害代码
        //----------
    endif
    set u = null
    set g = null
endfunction

function IceCasterMove takes nothing returns nothing
    local unit u = GetEnumUnit()
    local real x = GetUnitX(u)+20*Cos(GetUnitFacing(u)*bj_DEGTORAD)
    local real y = GetUnitY(u)+20*Sin(GetUnitFacing(u)*bj_DEGTORAD)
    local boolexpr filter = Condition(function IceDamage)
    call SetUnitX(u, GetMapX(x))
    call SetUnitY(u, GetMapY(y))
    call GroupEnumUnitsInRange(udg_TempGroup, x, y, 100, filter)
    call DestroyBoolExpr(filter)
    set filter = null
    set u = null
endfunction
[/codes]

依然没测试过


再觉得卡我也没办法了
回复

使用道具 举报

 楼主| 发表于 2008-8-23 20:26:43 | 显示全部楼层
弱弱的问一下bj_DEGTORAD是什么

那个选取了单位什么都不做吗

ICEDAMAGE怎么调用的?
回复

使用道具 举报

发表于 2008-8-23 20:50:44 | 显示全部楼层
bj_DEGTORAD=bj_PI/180.0=3.14159/180.0

这句不是调用了吗
[codes=jass]
local boolexpr filter = Condition(function IceDamage)
call GroupEnumUnitsInRange(udg_TempGroup, x, y, 100, filter)
[/codes]
回复

使用道具 举报

发表于 2008-8-23 20:52:59 | 显示全部楼层
IceDamage还得把判断的语句加上,别照抄了
回复

使用道具 举报

发表于 2008-9-12 19:41:22 | 显示全部楼层
那样更卡了。。

GroupEnumUnitsInRange(lGroup,tempX,tempY,50,lCheck)
这个语句,在一个技能没有完成的时候这个技能再次被使用(也就是波向前扩展还没有结束,就又施放了这个技能),会使得游戏变得很卡很卡。。。怎么办啊?难倒可以不用GroupEnumUnitsInRange,用另外一种方法?还有1次没完再次施放的时候GroupEnumUnitsInRange这个语句为什么会使得游戏这么卡咧?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-21 06:23 , Processed in 0.098585 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表