HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Spell - Burning Adrenaline - Trouble

01-18-2007, 01:33 PM#1
Fulla
Burning Adrenaline
Replenishes the Heroes health overtime, equivalent to a % of his missing hitpoints.

The exitwhen wont work (exit when Hero no longer has buff).
Im not sure how to do it?

Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Burning Adrenaline                          \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\


// Burning Adrenaline Hero Ability
constant function Burning_Adrenaline_AbilId takes nothing returns integer
    return 'A052'
endfunction

// Burning Adrenaline Buff
constant function Burning_Adrenaline_BuffId takes nothing returns integer
    return 'A052'
endfunction

// % of missing hitpoints healed per second
constant function Burning_Adrenaline_Life takes integer lvl returns real
    if (lvl != 5) then
        return (lvl * 0) + 0.01
    endif
    return 0.06
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Burning_Adrenaline_Cons takes nothing returns boolean
    return GetSpellAbilityId() == Burning_Adrenaline_AbilId()
endfunction

function Burning_Adrenaline_Acts takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local integer lvl = GetUnitAbilityLevel(caster, Burning_Adrenaline_AbilId())
    local real life = Burning_Adrenaline_Life(lvl)
    local real maxlife
    local real currentlife
    local real newlife
    
    call TriggerSleepAction(1.00)
    loop
        exitwhen UnitHasBuffBJ(caster, Burning_Adrenaline_BuffId()) == false then
        set maxlife = GetUnitState(caster, UNIT_STATE_MAX_LIFE)
        set currentlife = GetUnitState(caster, UNIT_STATE_LIFE)
        set new life = maxlife - currentlife
        call SetUnitState(caster, UNIT_STATE_LIFE, currentlife + (newlife * life))
        call TriggerSleepAction(1.00)
    endloop
    
    set caster = null
endfunction

//===========================================================================
function InitTrig_Burning_Adrenaline takes nothing returns nothing
    set gg_trg_Burning_Adrenaline = CreateTrigger()
    call TriggerAddCondition(gg_trg_Burning_Adrenaline, Condition(function Burning_Adrenaline_Cons))
    call TriggerAddAction(gg_trg_Burning_Adrenaline, function Burning_Adrenaline_Acts)
    call GenericDamage_QueueByAttack(gg_trg_Burning_Adrenaline)
endfunction
01-18-2007, 01:48 PM#2
rain9441
Consider changing the Acts function code into a timer function, otherwise you'll notice that the effects arent exactly as desired. TriggerSleepAction is in real seconds, not ingame seconds, so if the buff lasts 10 seconds, you may only get 7 'iterations' of the loop when gamespeed is fast, or 13-14 iterations of the loop if gamespeed is slow.

In Burning_Adrenaline_Life, You sure you want to multiply level * 0? Maybe level * 0.01 or (I2R(level)*0.01) ?

exitwhen GetUnitAbilityLevel(caster, BuffId) == 0 will kill the loop when the unit no longer has the buff (or dead, etc)
01-18-2007, 02:03 PM#3
Fulla
Ah, I had a then at end of exitwhen, ROAR :-(

yea, I got it wrong way, round mean to add 0 not times by :D.

Think I got it now thx.