|
[jass]function DamageTimedAction takes nothing returns nothing
local real inv = 0.02
local integer tmIndex = GetTimerIndex(GetExpiredTimer())
local unit su = I2U(SYS_TimerData_1[tmIndex])
local unit tu = I2U(SYS_TimerData_2[tmIndex])
local real value = SYS_TimerData_R0[tmIndex]
local real heroconfig = SYS_TimerData_R1[tmIndex]
local real x = SYS_TimerData_R2[tmIndex]
local real y = SYS_TimerData_R3[tmIndex]
local real speed = SYS_TimerData_R4[tmIndex]*inv
local real tx = GetUnitX(tu)
local real ty = GetUnitY(tu)
local real c = Atan2(ty-y,tx-x)
local real l = ((tx-x)*(tx-x)+((ty-y)*(ty-y)))
if(l<=10000 or l<=speed*speed)then
if(IsUnitType(tu,UNIT_TYPE_HERO))then
set value = value * heroconfig
endif
if(SYS_TimerData_0[tmIndex]>0)then
call UnitDamageTarget(su,tu,I2R(R2I(value)),true,false,ATTACK_TYPE_NORMAL, DAMAGE_TYPE_POISON,WEAPON_TYPE_WHOKNOWS)
else
call SetUnitState(tu,UNIT_STATE_LIFE,GetUnitState(tu,UNIT_STATE_LIFE)+value)
call ShowStrPosUnitCfg(su,tu,I2S(R2I(value)),2,1.00,false,true)
endif
call PauseTimer(GetExpiredTimer())
call ReleaseTimer(GetExpiredTimer())
elseif(SYS_TimerData_R5[tmIndex]<=0)then
call PauseTimer(GetExpiredTimer())
call ReleaseTimer(GetExpiredTimer())
endif
set SYS_TimerData_R5[tmIndex] = SYS_TimerData_R5[tmIndex] - inv
if(not(ty==y) and not(tx==x))then
if(((tx-x)*(tx-x))>=1000)then
set x = x+Cos(c)*speed
endif
if(((ty-y)*(ty-y))>=1000)then
set y = y+Sin(c)*speed
endif
set SYS_TimerData_R2[tmIndex] = x
set SYS_TimerData_R3[tmIndex] = y
endif
set su = null
set tu = null
endfunction
function DamageTargetTimed takes unit su,unit tu,real BlotSpeed,real MaxWaitTime, boolean DamOrHeal,real Value,real HeroConfig returns nothing
local timer tm = GetTimer()
local integer tmIndex = GetTimerIndex(tm)
if(DamOrHeal)then
set SYS_TimerData_0[tmIndex] = 1
else
set SYS_TimerData_0[tmIndex] = 0
endif
set SYS_TimerData_1[tmIndex] = H2I(su)
set SYS_TimerData_2[tmIndex] = H2I(tu)
set SYS_TimerData_R0[tmIndex] = Value
set SYS_TimerData_R1[tmIndex] = HeroConfig
set SYS_TimerData_R2[tmIndex] = GetUnitX(su)
set SYS_TimerData_R3[tmIndex] = GetUnitY(su)
set SYS_TimerData_R4[tmIndex] = BlotSpeed
set SYS_TimerData_R5[tmIndex] = MaxWaitTime
call TimerStart(tm,0.02,true,function DamageTimedAction)
set tm = null
endfunction
[/jass]
//============================================================
该函数可以模拟箭矢,射出去命中目标后才造成伤害,考虑了目标的移动对伤害时间造成的细微影响。
适合大家做地图的时候更完美地模拟“风暴之锤”一类的魔法造成的伤害效果。
附测试地图 |
|