HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Bouncing Buff on death, limited duration and something with Caster System

04-20-2008, 05:49 PM#1
Burning Rose
I'm making a spell that gives a target unit a buff that heals them over time. Then, if they die, the buff is spread to other units (Starts with two, increases each level). I've been using Attached Timers to tell whether or not it's the newest buffs (So that old casts of it don't end newer casts on the same unit). Anyways, At first I tried using UnitDamageUnitTimed with a negative value because the instructions said that made it a heal over time (apparently not >_>). Now I use all three of these functions:
Collapse JASS:
function Trig_Cauterize_Conditions takes nothing returns boolean
    return (GetSpellAbilityId() == 'A08P')
endfunction

function Cauterize_Run_Out takes nothing returns nothing
    local timer dur = GetExpiredTimer()
    local unit targ = GetAttachedUnit(dur, "target")
    local timer check = GetAttachedTimer(targ, "cautbuff")
    if check == dur then
        call UnitRemoveAbility(targ, 'A026')
    endif
    call DestroyTimer(dur)
    set dur = null
    set check = null
    set targ = null
endfunction

function Trig_Cauterize_Actions takes nothing returns nothing
    local unit lord = GetTriggerUnit()
    local player p = GetOwningPlayer(lord)
    local unit targ = GetSpellTargetUnit()
    local real heal = (GetUnitState(targ, UNIT_STATE_MAX_LIFE)) / 50
    local timer dur = CreateTimer()
    local integer lev = GetUnitAbilityLevel(lord, 'A08P')
    call TimerStart(dur, 20, false, function Cauterize_Run_Out)
    call UnitDamageUnitTimed(lord, 0, 1, 20, targ, "Abilities\\Spells\\Other\\SoulBurn\\SoulBurnbuff.mdl", "overhead", ATTACK_TYPE_CHAOS, DAMAGE_TYPE_FIRE)
    call AttachObject(dur, "target", targ)
    call AttachObject(targ, "cautbuff", dur)
    call UnitAddAbility(targ, 'A026')
    call AttachInt(targ, "cautlev", lev)
    set lord = null
    set p = null
    set targ = null
    set dur = null
endfunction

//===========================================================================
function InitTrig_Cauterize takes nothing returns nothing
    set gg_trg_Cauterize = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cauterize, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Cauterize, Condition( function Trig_Cauterize_Conditions ) )
    call TriggerAddAction( gg_trg_Cauterize, function Trig_Cauterize_Actions )
endfunction
Collapse JASS:
function Trig_Cauterize_Death_Conditions takes nothing returns boolean
    return (GetUnitAbilityLevel(GetTriggerUnit(), 'A026') > 0)
endfunction

function Cauterize_New_Filter takes nothing returns boolean
    return (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false) and (IsUnitAlly(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true) and (GetUnitAbilityLevel(GetFilterUnit(),'A026') == 0) and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.45)
endfunction

function Trig_Cauterize_Death_Actions takes nothing returns nothing
    local unit dead = GetTriggerUnit()
    local group g = CreateGroup()
    local unit f = GetTriggerUnit()
    local string model = GetAbilityEffectById('A026', EFFECT_TYPE_MISSILE, 1)
    local integer lev = GetAttachedInt(dead, "cautlev")
    local integer i = -1
    local real radius = (I2R(lev) * 30) + 200.0
    local real heal
    local timer dur = CreateTimer()
    local location loc
    call GroupEnumUnitsInRange(g, GetUnitX(dead), GetUnitY(dead), 400, Condition(function Cauterize_New_Filter))
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null or i == lev
        call GroupRemoveUnit(g, f)
        if (f != null) and (f != dead) then
            set heal = ((GetUnitState(f, UNIT_STATE_MAX_LIFE)) / 50)
            set loc = GetUnitLoc(f)
            call ProjectileLaunchToUnit(model, 1300, 0.15, GetUnitX(f), GetUnitY(f), GetLocationZ(loc), f, 40)
            call UnitDamageUnitTimed(dead, 0, 1, 20, f, "Abilities\\Spells\\Other\\SoulBurn\\SoulBurnbuff.mdl", "overhead", ATTACK_TYPE_CHAOS, DAMAGE_TYPE_FIRE)
            call TimerStart(dur, 20, false, function Cauterize_Run_Out)
            call AttachObject(dur, "target", f)
            call AttachObject(f, "cautbuff", dur)
            call UnitAddAbility(f, 'A026')
            call AttachInt(f, "cautlev", lev)
            set i = i + 1
            call RemoveLocation(loc)
        endif
    endloop
    call DestroyGroup(g)
    set dead = null
    set loc = null
    set f = null
    set dur = null
endfunction
//===========================================================================
function InitTrig_Cauterize_Death takes nothing returns nothing
    set gg_trg_Cauterize_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Cauterize_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Cauterize_Death, Condition( function Trig_Cauterize_Death_Conditions ) )
    call TriggerAddAction( gg_trg_Cauterize_Death, function Trig_Cauterize_Death_Actions )
endfunction

Right now when it bounces, it lasts for a few seconds and then dissapears. This seems to happen with both the Timer and the Special Effect (Which i'm doing with UnitDamageUnitTimed simply because it removes it on death.

Not to mention the projectile just sort of flies everywhere looking really strange.

Collapse JASS:
function Cauterize_Heal_Filter takes nothing returns boolean
    return (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.45) and (GetUnitAbilityLevel(GetFilterUnit(),'A026') > 0)
endfunction

function Trig_Cauterize_heal_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit f
    local real heal
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function Cauterize_Heal_Filter))
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null
        set heal = (GetUnitState(f, UNIT_STATE_MAX_LIFE)) / 50
        call SetUnitState(f, UNIT_STATE_LIFE, (GetUnitState(f, UNIT_STATE_LIFE) + heal))
        call GroupRemoveUnit(g, f)
    endloop
    call DestroyGroup(g)
    set f = null
endfunction

//===========================================================================
function InitTrig_Cauterize_heal takes nothing returns nothing
    set gg_trg_Cauterize_heal = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Cauterize_heal, 1.00 )
    call TriggerAddAction( gg_trg_Cauterize_heal, function Trig_Cauterize_heal_Actions )
endfunction

And yes, I'm sure there are a few ways in general to improve this, but mainly I want to know why it isn't working >_>. Although improvements to efficiency would be nice to hear about as well, Working at all is first priority :P
04-21-2008, 06:42 AM#2
Pyrogasm
I'd assume all of those weird functions I don't recognize are from the Caster System?
04-21-2008, 09:22 PM#3
Burning Rose
>_> Yeah. Probably.
04-21-2008, 10:02 PM#4
Anitarf
This would be so easy to do with my ABuff system...

...just saying.
04-21-2008, 10:04 PM#5
Burning Rose
Yeah the Whole "not overwriting new ones" probably would be, and I plan on implementing that soon.
As in it is currently sitting on my desktop waiting for me to be done with a school project >_>.

But that part seems to work right. The problem is that it isn't bouncing right >_<