Thread: ABuff System
View Single Post
Old 09-13-2010, 12:44 PM   #194
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

I'm not sure why your game crashes, but I can see why this wouldn't work. The display buff is not meant to be applied directly, but by the poison buff. That is why it is a REFCOUNT buff: it keeps track of how many poison buffs are on the unit.

Using the library I wrote previously, your spell would look something like this:

Collapse JASS:
library shadowheart initializer Init requires ABuff, Poison, IntuitiveDamageSystem

    // CALIBRATION SECTION

    globals
        private constant integer abiID           = 'A009' //Autocast Spell
        private constant integer bufID           = 'B004' //Buff of Autocast
    endglobals

    // SPELL CODE
    
    private function con takes nothing returns boolean
        return GetUnitAbilityLevel(GetTriggerUnit(), bufID) > 0
    endfunction
    
    private function act takes nothing returns nothing
        local unit c = GetTriggerDamageSource()
        local unit t = GetTriggerDamageTarget()
        local player p = GetOwningPlayer(c)
        local integer lvl = GetUnitAbilityLevel(c, abiID)
        //Actions
        call UnitRemoveAbility( t, bufID )
        call ABuffApply( Poison_bufftype, t, c, 4.0, lvl, 0 )
        set c    = null
        set t    = null
        set p    = null
    endfunction

    // SPELL INITIALIZATION

    private function Init takes nothing returns nothing
        local trigger trg = CreateTrigger()
        call TriggerAddAction(trg, function act)
        call TriggerAddCondition(trg, Condition(function con))
        call TriggerRegisterDamageEvent(trg, 1)
    endfunction

endscope
__________________
Anitarf is offline   Reply With Quote