- Joined
- Jul 28, 2008
- Messages
- 211
I made a spell:
It crashes the game when the unit gets attacked.
But, when i change the
into
it works fine. So what's the problem?
Thanks in advance.
PS: I know about the BJ but I was too lazy to replace it. I'll do that later.
JASS:
scope Echo initializer Init
globals
private constant integer SPELL_ID = 'A000'
private constant real DURATION = 10.00
private hashtable h = InitHashtable()
endglobals
private function Damage takes integer lvl returns real
return I2R(lvl)
endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Echo_Child takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit c = LoadUnitHandle(h, GetHandleId(t), 0)
local unit target = LoadUnitHandle(h, GetHandleId(t), 1)
local integer lvl = LoadInteger(h, GetHandleId(t), 2)
local real d = GetEventDamage() * Damage(lvl)
local texttag text = CreateTextTag()
call UnitDamageTarget(c, target, d, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call SetTextTagPos(text, GetUnitX(target), GetUnitY(target), 10.00 * 0.023 / 10)
call SetTextTagText(text, I2S(R2I(d)), 10.00 * 0.023 / 10)
call SetTextTagColor(text, 190, 45, 45, 0)
call SetTextTagLifespan(text, 2.00)
call SetTextTagVelocityBJ( text, 64, 90 )
call SetTextTagVisibility(text, true)
set t = null
set c = null
set target = null
call TriggerSleepAction(2.00)
call DestroyTextTag(text)
set text = null
endfunction
private function Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local unit targ = GetSpellTargetUnit()
local trigger t = CreateTrigger()
local triggeraction a = TriggerAddAction(t, function Echo_Child)
call TriggerRegisterUnitEvent(t, targ, EVENT_UNIT_DAMAGED)
call SaveUnitHandle(h, GetHandleId(t), 0, c)
call SaveUnitHandle(h, GetHandleId(t), 1, targ)
call SaveInteger(h, GetHandleId(t), 2, GetUnitAbilityLevel(c, SPELL_ID))
call TriggerSleepAction(DURATION)
call FlushChildHashtable(h, GetHandleId(t))
call TriggerRemoveAction(t, a)
call DestroyTrigger(t)
set t = null
set c = null
set targ = null
set a = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope
It crashes the game when the unit gets attacked.
But, when i change the
JASS:
call UnitDamageTarget(c, target, d, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
JASS:
call UnitDamageTarget(c, c, d, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
Thanks in advance.
PS: I know about the BJ but I was too lazy to replace it. I'll do that later.