| 07-16-2007, 01:10 PM | #1 |
I'm making a new life steal ability, that is supposed to work abit like the firelord ability. What it does is, that the first hit the hero does has a 1% life steal, the next a 2%, the third a 3% etc., up to a maximum %, the counter is then supposed to reset if the hero hasn't done a hit within the last 10 seconds. So far it works as long as to increasing his life steal by 1% per hit, and stopping from increasing if the max % is reached. (The max % per level is 15/20/25%) then it will reset it after 10 seconds, because the check if it's supposed to reset is done by seeing if the life steal ability level has been increased since last time, but as the max level is reached it never will be. Anyone know how to work around this, or another way to do it? Trigger looks like this: JASS:function Trig_Life_Steal_Increase_Conditions takes nothing returns boolean return GetUnitAbilityLevelSwapped('A002', GetAttacker()) > 0 endfunction function Trig_Life_Steal_Increase_Actions takes nothing returns nothing local unit attacker = GetAttacker() local integer lifeSteal = GetUnitAbilityLevel(attacker, 'A003') local integer maxSteal = GetUnitAbilityLevel(attacker, 'A002')*5+10 if lifeSteal != maxSteal then call SetUnitAbilityLevel(attacker, 'A003', lifeSteal+1) call DisplayTextToForce(GetPlayersAll(), "Life steal has been increased to: "+I2S(lifeSteal+1)) endif call PolledWait(10.0) if GetUnitAbilityLevel(attacker, 'A003') == lifeSteal+1 then call SetUnitAbilityLevel(attacker, 'A003', 1) call DisplayTextToForce(GetPlayersAll(), "Life Steal has been reset") else call DisplayTextToForce(GetPlayersAll(), "Life steal has been increased, not resetting") endif set attacker = null endfunction //=========================================================================== function InitTrig_Life_Steal_Increase takes nothing returns nothing set gg_trg_Life_Steal_Increase = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Life_Steal_Increase, EVENT_PLAYER_UNIT_ATTACKED ) call TriggerAddCondition( gg_trg_Life_Steal_Increase, Condition( function Trig_Life_Steal_Increase_Conditions ) ) call TriggerAddAction( gg_trg_Life_Steal_Increase, function Trig_Life_Steal_Increase_Actions ) endfunction |
| 07-16-2007, 03:29 PM | #2 |
Uh, sure that this works at all? What you have to do is creating a timer and call TimerStart(timer,10.00,false,function lifesteal_decrease) everytime that unit attacks. Doing so will reset the timer, your PolledWait won't ever stop, so like, 10 seconds after the first hit will result in cancel. |
| 07-16-2007, 04:58 PM | #3 | |
Quote:
I'm pretty sure it works, yeah. First hit it says Life steal increased to 2, next hit Life steal increased to 3, and after around 10 seconds after first hit it tells me the attack have been made not resetting message, until I reach max, whereas it resets. Well, I will try that you said. Oh, and what do you mean by the wait won't ever stop? It stops perfectly fine after 10 seconds. (Which is what I want it to.) EDIT: Also, to use that timer trick, I would need to use either game cache or Vex's Timer Attach system, right? |
| 07-16-2007, 05:14 PM | #4 |
Perhaps, you'd also have to have a system in place to be certain that the unit is successful with it's attack and also. But your system looks like handles that fine already... What you could try to do is have two levels of the same amount of life drain and switch back and forth between them, so if it's at it's max level subtract one instead of adding one. |
| 07-16-2007, 08:23 PM | #5 |
You ran into your problem because your method is flawed. Had you used a timer, this wouldn't be an issue. |
