Thread: ABuff System
View Single Post
Old 09-13-2010, 09:18 AM   #192
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

First of all, for the green vertex colouring, you need to use a REFCOUNT buff, otherwise the unit will turn non-green whenever a poison buff expires, even if the unit still has other poison buffs on it. You can then package this setup into a library which other spells can then use:

Collapse JASS:
library Poison initializer Init requires ABuff

    globals
        public aBuffType bufftype
        private aBuffType display
    endglobals
    
    private function DisplayCreate takes aBuff eventBuff returns nothing
        call SetUnitVertexColor(eventBuff.target.u, 0, 255, 0, 255)
    endfunction
    private function DisplayCleanup takes aBuff eventBuff returns nothing
        call SetUnitVertexColor(eventBuff.target.u, 255, 255, 255, 255)
    endfunction

    private function Create takes aBuff eventBuff returns nothing
        call ABuffApply(display, eventBuff.target.u, eventBuff.caster, 0.0, eventBuff.level, 0)
    endfunction
    private function Cleanup takes aBuff eventBuff returns nothing
        call ABuffRemove(GetABuffFromBuffedUnitByType(eventBuff, display))
    endfunction
    private function Periodic takes aBuff eventBuff returns nothing
        call UnitDamageTargetEx(eventBuff.caster, eventBuff.target.u, 40.*ABuff_PERIODIC_EVENT_PERIOD, ATTACK_TYPE_HERO, DAMAGE_TYPE_EXTRA, true)
    endfunction
    
    private function Init takes nothing returns nothing
        set bufftype = aBuffType.create()
        set bufftype.category = ABuff_STACKING
        set bufftype.countsAsBuff = false
        set bufftype.eventCreate = Create
        set bufftype.eventCleanup = Cleanup
        set bufftype.eventPeriodic = Periodic

        set display = aBuffType.create()
        set display.category = ABuff_REFCOUNT
        set display.ignoreAsBuff = true
        set display.eventCreate = DisplayCreate
        set dispaly.eventCleanup = DisplayCleanup
    endfunction

endscope
__________________
Anitarf is offline   Reply With Quote