game_war48
New Member
- Reaction score
- 5
JASS:
scope MarkoftheDeath initializer InitMOTD
private function GetReturnMana takes integer lvl returns real
return 25. + (5. * I2R(lvl))
endfunction
private struct motd
//! runtextmacro PUI()
unit c
unit t
trigger trg
triggercondition trgc
integer tick
real mana
endstruct
private function MarkoftheDeathT takes nothing returns nothing
local timer ti = GetExpiredTimer()
local motd d = GetTimerData( ti )
if d.tick == 0 or GetUnitAbilityLevel( d.t, 039;B001039; ) == 0 then
call UnitRemoveAbility( d.t, 039;A000039; )
call UnitRemoveAbility( d.t, 039;B001039; )
call SetUnitUserData( d.t, 0 )
call DisableTrigger( d.trg )
call TriggerRemoveCondition( d.trg, d.trgc )
call DestroyTrigger( d.trg )
call ReleaseTimer( ti )
set motd[d.t] = 0
set ti = null
return
endif
set d.tick = d.tick - 1
set ti = null
endfunction
private function MarkoftheDeathC takes nothing returns boolean
local unit t = GetTriggerUnit()
local motd d = motd[t]
local boolean ok
local real dam
local real res
call BJDebugMsg("custom value: " + I2S(GetUnitUserData(t)))
call BJDebugMsg("struct: " + I2S(d))
if GetUnitUserData( t ) == d then
call BJDebugMsg("user data")
set ok = Damage_IsSpell()
if ok then
call BJDebugMsg("spell")
set dam = GetEventDamage()
if dam == 0. or GetUnitAbilityLevel( d.t, 039;B001039; ) == 0 then
return false
elseif dam >= 20 then
call BJDebugMsg("regen")
set res = (dam / 20) * d.mana
call SetUnitState( d.t, UNIT_STATE_MANA, res )
call DestroyEffect( AddSpecialEffectTarget( "Abilities\\Spells\\Items\\AIil\\AIilTarget.mdl", d.c, "origin" ) )
endif
endif
endif
return false
endfunction
private function Act takes nothing returns nothing
local unit t = GetSpellTargetUnit()
local timer ti
local motd d = motd[t]
if d == 0 then
set d = motd.create()
set motd[t] = d //>> that is
call SetUnitUserData( t, d )
call BJDebugMsg("motd start: " + I2S(motd[t]))
call BJDebugMsg("d start: " + I2S(d))
set d.c = GetTriggerUnit()
set d.t = t
set d.mana = GetReturnMana( GetUnitAbilityLevel( d.c, 039;A002039; ) )
set d.tick = 150
set d.trg = CreateTrigger()
set d.trgc = TriggerAddCondition( d.trg, Condition( function MarkoftheDeathC ) )
call Damage_RegisterEvent( d.trg )
call UnitAddAbility( d.t, 039;A000039; )
set ti = NewTimer()
call SetTimerData( ti, d )
call TimerStart( ti, 0.04, true, function MarkoftheDeathT )
set ti = null
else
set d.tick = 150
endif
set t = null
endfunction
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == 039;A002039;
endfunction
//===========================================================================
function InitMOTD takes nothing returns nothing
local trigger MOTD = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( MOTD, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( MOTD, Condition( function Cond ) )
call TriggerAddAction( MOTD, function Act )
endfunction
endscope
My problem is "Why motd[t] always set to 0 ? (I know that through BJDebugMsg) " although "d" has a value.
Note: It's in function Act