HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Is it a bug or did i do something wrong

04-19-2007, 01:22 AM#1
Joker
Collapse JASS:
//Created By: Joker(Div)

//************************************************************************//
//           Constant Function (acts like global variables)               //
//************************************************************************//

constant function Trig_Gaping_Wound_AbilityId takes nothing returns integer
    return 'A004'  //Ability ID
endfunction

constant function Trig_Gaping_Wound_SpellEffect takes nothing returns string
    return "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl" //The blood effect
endfunction

constant function Trig_Gaping_Wound_DamagePercent takes nothing returns real
    return 0.01 //The percent at which it starts will be higher 0.01 every level
endfunction

constant function Trig_Gaping_Wound_DamageInterval takes nothing returns real
    return 1. //The interval of the damage
endfunction


//************************************************************************//
//                        Spell Functions                                 //
//************************************************************************//

function Trig_Gaping_Wound_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Trig_Gaping_Wound_AbilityId()
endfunction

function Trig_Gaping_Wound_Effect_Core takes timer t returns nothing
    local unit a = GetHandleUnit( t, "target" )
    local unit b = GetHandleUnit( t, "caster" )
    local real al = GetUnitState( b, UNIT_STATE_LIFE )
    local real i = GetHandleReal( t, "count" )
    local integer lvl = GetUnitAbilityLevel( a, Trig_Gaping_Wound_AbilityId() )

call BJDebugMsg( R2S(i) )
    if i > 0 and al > 0.405 then
        call DestroyEffect( AddSpecialEffectTarget( Trig_Gaping_Wound_SpellEffect(), a, "chest" ) )
        call SetUnitState( a, UNIT_STATE_LIFE, al - (al * i) )
    else
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
   endif
    
    call SetHandleReal( t, "count", GetHandleReal( t, "count" ) - 0.01 )
    set a = null
    set b = null
endfunction

function Trig_Gaping_Wound_Effect takes nothing returns nothing
    call Trig_Gaping_Wound_Effect_Core( GetExpiredTimer() )
endfunction

function Trig_Gaping_Wound_Actions_Core takes timer t, unit a, unit b, real i returns nothing
    call SetHandleHandle( t, "caster", b )
    call SetHandleHandle( t, "target", a )
    call SetHandleReal( t, "count", 0.1 + i )
    call TimerStart( t, Trig_Gaping_Wound_DamageInterval(), true, function Trig_Gaping_Wound_Effect )
endfunction

function Trig_Gaping_Wound_Actions takes nothing returns nothing
    local unit a = GetSpellTargetUnit()
    local unit b = GetTriggerUnit()
    local real al = GetUnitState( a, UNIT_STATE_LIFE )
    local real i = GetUnitAbilityLevel( b, Trig_Gaping_Wound_AbilityId() ) * Trig_Gaping_Wound_DamagePercent()
   
    call DestroyEffect( AddSpecialEffect( Trig_Gaping_Wound_SpellEffect(), GetUnitX(a), GetUnitY(a) ) )
    call SetUnitState( a, UNIT_STATE_LIFE, al - al * (0.1 + i ) )
       
    call Trig_Gaping_Wound_Actions_Core( CreateTimer(), a, b, i )
    set a = null
endfunction

//===========================================================================
function InitTrig_Gaping_Wound takes nothing returns nothing
    set gg_trg_Gaping_Wound = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Gaping_Wound, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Gaping_Wound, Condition( function Trig_Gaping_Wound_Conditions ) )
    call TriggerAddAction( gg_trg_Gaping_Wound, function Trig_Gaping_Wound_Actions )
    call Preload( Trig_Gaping_Wound_SpellEffect() )
endfunction

This was fine until i accidentally erased something so i redid that erased part. Now, it takes about 90% of the targets hp the 1st time, then does nothing else except showing the Special Effect. It does work every once in a while, but it sometimes heals too...
04-20-2007, 06:56 PM#2
Anitarf
Well, what do you want the spell to do?

If I had to guess, I would say the problem is that you get the current life of the caster in the timer callback function, I suspect you actualy wanted the life of the target there instead.

I see that in Trig_Gaping_Wound_Effect_Core you are trying to get the level of the ability of the target instead of the caster, but since you don't use the integer lvl anywhere this mistake shouldn't affect anything.
04-20-2007, 07:29 PM#3
Joker
oh, damn thx

+rep