Heloes Hive Workshop
I encountered a weird problem with my code. There is a skill, which gives a unit a dummy skill, slow poison, to be precise. Then, after the unit hits the enemy once, the skill is removed. To this point, it all works. But, when the ability is cast again, triggers don't give casting unit the ability.
Here's the code (two triggers):
First trigger (giving the skill)
It's in polish, but only the names, guess it's nothing wrong.
Second trigger (removing the skill after the target is damaged)
Any solutions?
I encountered a weird problem with my code. There is a skill, which gives a unit a dummy skill, slow poison, to be precise. Then, after the unit hits the enemy once, the skill is removed. To this point, it all works. But, when the ability is cast again, triggers don't give casting unit the ability.
Here's the code (two triggers):
First trigger (giving the skill)
JASS:
function SWK_cond takes nothing returns boolean
if (GetSpellAbilityId() == 'A01Z') then
return true
endif
return false
endfunction
function Trig_Strzal_w_kolano_ON_Actions takes nothing returns nothing
local integer nr = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
set udg_Strzal[nr] = 1
call UnitAddAbility(GetTriggerUnit(), 'A020')
endfunction
//===========================================================================
function InitTrig_Strzal_w_kolano_ON takes nothing returns nothing
set gg_trg_Strzal_w_kolano_ON = CreateTrigger( )
call TriggerAddCondition(gg_trg_Strzal_w_kolano_ON, Condition(function SWK_cond))
call TriggerRegisterAnyUnitEventBJ( gg_trg_Strzal_w_kolano_ON, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_Strzal_w_kolano_ON, function Trig_Strzal_w_kolano_ON_Actions )
endfunction
It's in polish, but only the names, guess it's nothing wrong.
Second trigger (removing the skill after the target is damaged)
JASS:
function S_cond takes nothing returns boolean
if (udg_Strzal[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] == 0) then
return false
endif
return true
endfunction
function dostal_f takes nothing returns nothing
local unit cel = GetTriggerUnit()
local unit atak = GetEventDamageSource()
local integer nr = GetConvertedPlayerId(GetOwningPlayer(atak))
if (udg_Strzal[nr] == 1) then
call UnitRemoveAbility(atak, 'A020')
endif
set udg_Strzal[nr] = 0
set cel = null
set atak = null
endfunction
function Trig_Strzal_Actions takes nothing returns nothing
local trigger dostal = CreateTrigger()
local unit cel = GetTriggerUnit()
call TriggerRegisterUnitEvent(dostal, cel, EVENT_UNIT_DAMAGED)
call TriggerAddAction(dostal, function dostal_f)
set cel = null
set dostal = null
endfunction
//===========================================================================
function InitTrig_Strzal takes nothing returns nothing
set gg_trg_Strzal = CreateTrigger( )
call TriggerAddCondition(gg_trg_Strzal, Condition(function S_cond))
call TriggerRegisterAnyUnitEventBJ( gg_trg_Strzal, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_Strzal, function Trig_Strzal_Actions )
endfunction
Any solutions?