Heloes Hive Workshop!
Due to Critical Hit skill's flaws I'm trying to make a triggered skill of this sort. I do it by making a leveled skill based on Critical Strike, which, at lvl 1, does nothing, but at lvl 2 it has 100% chance to critically hit. I encountered a weird problem. It is, the trigger does set the level to 2 when the counter reaches given value (determinated hero's chance to critically hit), but it wouldn't then swap to lvl 1 back.
Here's the code:
variables:
krytyk is hero's chance to hit (1-400) and krytyk_licznik is the counter counting randomly from 1 to 400.
The max chance to hit is 25%, hence the if-then-else down there
Any ideas?
Due to Critical Hit skill's flaws I'm trying to make a triggered skill of this sort. I do it by making a leveled skill based on Critical Strike, which, at lvl 1, does nothing, but at lvl 2 it has 100% chance to critically hit. I encountered a weird problem. It is, the trigger does set the level to 2 when the counter reaches given value (determinated hero's chance to critically hit), but it wouldn't then swap to lvl 1 back.
Here's the code:
variables:
krytyk is hero's chance to hit (1-400) and krytyk_licznik is the counter counting randomly from 1 to 400.
The max chance to hit is 25%, hence the if-then-else down there
JASS:
function Trig_Krytyk_cios_Conditions takes nothing returns boolean
return GetOwningPlayer(GetAttacker()) != Player(11)
endfunction
function krytol_bach takes nothing returns nothing
local integer nr = GetConvertedPlayerId(GetOwningPlayer(GetEventDamageSource()))
local unit bo = GetEventDamageSource()
local integer kr = udg_krytyk[nr]
local integer licznik = udg_krytyk_licznik[nr]
if (kr > 100) then
set kr = 100
endif
if (kr <= licznik) then
call SetUnitAbilityLevel(bo, 'A000', 2)
else
call SetUnitAbilityLevel(bo, 'A000', 1)
endif
set bo = null
endfunction
function Trig_Krytyk_cios_Actions takes nothing returns nothing
local unit cel = GetTriggerUnit()
local trigger krytol = CreateTrigger()
call DisplayTextToForce(GetPlayersAll(), I2S(udg_krytyk_licznik[1]))
call TriggerRegisterUnitEvent(krytol, cel, EVENT_UNIT_DAMAGED)
call TriggerAddAction(krytol, function krytol_bach)
call TriggerSleepAction(1)
call DestroyTrigger(krytol)
set cel = null
set krytol = null
endfunction
//===========================================================================
function InitTrig_Krytyk_cios takes nothing returns nothing
set gg_trg_Krytyk_cios = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Krytyk_cios, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_Krytyk_cios, Condition( function Trig_Krytyk_cios_Conditions ) )
call TriggerAddAction( gg_trg_Krytyk_cios, function Trig_Krytyk_cios_Actions )
endfunction
Any ideas?