Code
scope Beorn initializer Init
{
define
{
private AbId = 'A02R'
}
private struct Data
{
unit caster
int str
}
private bool B_COND()
{
return GetSpellAbilityId() == AbId
}
private void B_DMG()
{
trigger trig = GetTriggeringTrigger()
Data d = LoadInteger(Hash,GetHandleId(trig),0)
SetHeroStr(d.caster,GetHeroStr(d.caster,false)+R2I(GetEventDamage())/GetHeroStr(d.caster,true),true)
BJDebugMsg(R2S(GetEventDamage())+" получил "+GetUnitName(d.caster))
}
private void B_TIME()
{
timer t = GetExpiredTimer()
int time = LoadInteger(Hash,GetHandleId(t),1)
trigger trig = GetTriggeringTrigger()
Data d = LoadInteger(Hash,GetHandleId(t),0)
BJDebugMsg(GetUnitName(d.caster))
BJDebugMsg(I2S(time))
if time >= 2+1*GetUnitAbilityLevel(d.caster,AbId)
{
TriggerClearActions(trig)
DestroyTrigger(trig)
}
if time >= 4+1*GetUnitAbilityLevel(d.caster,AbId)
{
SetHeroStr(d.caster,d.str,false)
PauseTimer(t)
DestroyTimer(t)
}
time++
SaveInteger(Hash,GetHandleId(t),1,time)
}
private void B_ACT()
{
Data d=Data.create()
d.caster = GetTriggerUnit()
d.str = GetHeroStr(d.caster,false)
timer t = CreateTimer()
trigger trig = CreateTrigger()
TriggerRegisterUnitEvent(trig,GetTriggerUnit(), EVENT_UNIT_DAMAGED)
TriggerAddAction(trig,function B_DMG)
SaveInteger(Hash,GetHandleId(t),0,d)
SaveInteger(Hash,GetHandleId(t),1,0)
TimerStart(t,1.,true,function B_TIME)
}
private void Init()
{
gg_trg_Beorn4=CreateTrigger()
TriggerRegisterAnyUnitEventBJ(gg_trg_Beorn4,EVENT_PLAYER_UNIT_SPELL_EFFECT)
TriggerAddCondition(gg_trg_Beorn4,Condition(function B_COND))
TriggerAddAction(gg_trg_Beorn4,function B_ACT)
}
}
Почему-то не запускает B_DMG? Может из-за события, просто 1-ый раз пробую запускать триггер в триггере, скажите, что не так?