|
我就是做的普通攻击带击退的但是击退的速度越变越快,问题应该出在创建Timer上 就是每次攻击都新建一个Timer 绑定数据然后循环计时 运行触发 因为每次绑定的数据都一样 所以就出BUG了 所以谁帮忙看下怎么改 自己实在是想不出办法了
[jass]
function MachokeCond takes nothing returns boolean
return ( UnitHasBuffBJ(GetAttacker(), 'B006') == true )
endfunction
function mach takes nothing returns nothing
local timer Mact = GetExpiredTimer()
local unit Macu = i2u(GetStoredInteger(udg_GG,"Mac",I2S(h2i(Mact))))
local unit Macumb = i2u(GetStoredInteger(udg_GG,"Macmb",I2S(h2i(Mact))))
local real MacAngle = Atan2BJ(( GetUnitY(Macumb) - GetUnitY(Macu) ), ( GetUnitX(Macumb) - GetUnitX(Macu) ))
if ( GetUnitUserData(Macumb) < 10 ) then
call SetUnitUserData( Macumb, ( GetUnitUserData(Macumb) + 1 ) )
call DestroyEffect( AddSpecialEffectLoc("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl", Location(GetUnitX(Macumb),GetUnitY(Macumb))) )
call SetUnitPosition( Macumb, (GetUnitX(Macumb)+((3*GetUnitUserData(Macumb))*CosBJ(MacAngle))), (GetUnitY(Macumb)+((5*GetUnitUserData(Macumb))*SinBJ(MacAngle)) ))
elseif ( GetUnitUserData(Macumb) == 10 ) then
call FlushStoredMission(udg_GG,"Macmb")
call FlushStoredMission(udg_GG,"Mac")
call DestroyTimer(Mact)
endif
endfunction
function MachokeLoop takes nothing returns nothing
local unit Mac = GetAttacker()
local unit Macmb = GetAttackedUnitBJ()
local integer MacIndex = GetHeroStatBJ(bj_HEROSTAT_STR, Mac, true)
local timer MacT = CreateTimer()
call UnitDamageTarget( Mac, Macmb, I2R(MacIndex), false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
call StoreInteger(udg_GG,"Mac",I2S(h2i(MacT)),h2i(Mac))
call StoreInteger(udg_GG,"Macmb",I2S(h2i(MacT)),h2i(Macmb))
call SetUnitUserData( Macmb, 0 )
call TimerStart(MacT0.05,true, function mach )
set Mac = null
set Macmb = null
endfunction
function Machoke takes unit mk returns nothing
local trigger mac = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( mac, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( mac, Condition( function MachokeCond ) )
call TriggerAddAction( mac, function MachokeLoop )
set mac = null
endfunction
[/jass] |
|