=================================B U F F S Y S T E M====================================
This system has two parts:
- CREATE_BUFF_OBJECT: Create ability and buff to use for this system.
+ When the first time you create buff object, you MUST CLOSED Jassnewgen and RE-OPEN it.
+ If you use JNGP 2.0, dont worry about external object each times you save map (RECOMMENDED).
+ If you use JNGP v5d or else, please put CREATE_BUFF_OBJECT to a seperate trigger (DISABLE it when create buff finished).
- CREATE_BUFF: Create core code that you have to create if you want to use this system.
+ Create a struct contents all things of a specific buff.
+ Put in a seperate trigger or inside Buff Trigger.
REQUIREMENTS
- JassNewGen Pack v5d or higher.
Link: (blizzardmodding.info/4263/the-jass-newgen-pack-jngp-2-0/)
- Vexorian - Jass Helper 0.A.2.B
Link: (www.wc3c.net/showthread.php?t=88142)
- Vexorian - Timer Utils
Link: (www.wc3c.net/showthread.php?t=101322)
- Nestharus - Unit Indexer
Link: (www.hiveworkshop.com/forums/spells-569/unit-indexer-v5-3-0-1-a-260859/)
- Nestharus - Trigger
Link: (www.hiveworkshop.com/forums/spells-569/trigger-v1-1-0-2-a-260933/)
HOW TO USE:
STEP 1: Create buff object through textmacro CREATE_BUFF_OBJECT.
//! textmacro CREATE_BUFF_OBJECT takes RAWCODE, NAME, ICON, DESCRIPTION
+ RAWCODE: I recommended you use 3 DIGITS.
+ EXAMPLE:
//! runtextmacro CREATE_BUFF_OBJECT("rag","Rage", "ReplaceableTexturesCommandButtonsBTNAncestralSpirit.blp", "This unit is affected by Rage.")
+ Above line that you have created a buff called "Rage" with AbilityId = 'Arag', BuffId = 'Brag'.
STEP 2: Create specific buff struct.
//! textmacro CREATE_BUFF takes RAWCODE, NAME
+ RAWCODE: I recommended you use 3 DIGITS (same as with RAWCODE of buff object)
+ EXAMPLE:
//! runtextmacro CREATE_BUFF("rag","Rage")
struct BuffRage extends array will be created.
if you want to apply BuffRage to a specific unit (whichUnit) use this function:
call BuffRage[whichUnit].apply()
apply a buff: call Buff$NAME$[whichUnit].apply()
To remove a buff from a specific unit use this function:
call BuffRage[whichUnit].remove()
remove a buff: call Buff$NAME$[whichUnit].remove()
To apply a buff to a unit for a duration, you can set buff duration:
set BuffRage[whichUnit].duration = real Duration
The buff will exist pernament if you didnt set duration or set duration <= 0
Extra function:
function RegisterApplyBuff$NAME$Event takes boolexpr whichBoolexpr returns TriggerCondition
function RegisterRemoveBuff$NAME$Event takes boolexpr whichBoolexpr returns TriggerCondition
STEP 3: Feel free to use and modify.
The EXAMPLE is inside Buff trigger and Test Category.
===========================================N O T I C E====================================================
If you want to USE this system, you MUST have KNOWLEDGE about vJASS. At least, you must understand how to use.
===========================================C R E D I T====================================================
Special thanks to:
Veroxian
Nestharus
The Hiveworkshop
library Buff requires UnitIndexer, TimerUtils
//! textmacro CREATE_BUFF_OBJECT takes RAWCODE, NAME, ICON, DESCRIPTION
//! external ObjectMerger w3a Aasl A$RAWCODE$ ansf "(Buff System)" anam "$NAME$" abuf 1 B$RAWCODE$ Slo1 1 0 aare 1 0 atar 1 self
//! external ObjectMerger w3h Basl B$RAWCODE$ fnsf "(Buff System)" ftip "$NAME$" fube "$DESCRIPTION$" fart "$ICON$"
//! endtextmacro
//! textmacro CREATE_BUFF takes RAWCODE, NAME
struct Buff$NAME$ extends array
readonly static integer Ability = 'A$RAWCODE$'
readonly static integer Id = 'B$RAWCODE$'
readonly static Trigger ApplyTrigger
readonly static Trigger RemoveTrigger
readonly static unit TriggerUnit
readonly timer Timer
static method onRemove takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = GetTimerData(t)
set TriggerUnit = null
call this.remove()
call ReleaseTimer(t)
endmethod
method operator duration= takes real t returns nothing
if t > 0 then
if this.Timer != null then
call PauseTimer(this.Timer)
call ReleaseTimer(this.Timer)
endif
set this.Timer = NewTimerEx(this)
call TimerStart(this.Timer, t, false, function thistype.onRemove)
else
if this.Timer != null then
call PauseTimer(this.Timer)
call ReleaseTimer(this.Timer)
endif
endif
endmethod
method operator duration takes nothing returns real
return TimerGetRemaining(this.Timer)
endmethod
method apply takes nothing returns nothing
set TriggerUnit = null
if GetUnitAbilityLevel(this.unit, Ability) == 0 then
set TriggerUnit = this.unit
call ApplyTrigger.fire()
call UnitMakeAbilityPermanent(this.unit, true, Ability)
call UnitAddAbility(this.unit, Ability)
endif
endmethod
method remove takes nothing returns nothing
set TriggerUnit = null
if GetUnitAbilityLevel(this.unit, Ability) != 0 then
set TriggerUnit = this.unit
call RemoveTrigger.fire()
call UnitRemoveAbility(this.unit, Ability)
call UnitRemoveAbility(this.unit, Id)
endif
endmethod
private static method onInit takes nothing returns nothing
set ApplyTrigger = Trigger.create(false)
set RemoveTrigger = Trigger.create(false)
endmethod
implement GlobalUnitIndex
endstruct
function RegisterApplyBuff$NAME$Event takes boolexpr whichBoolexpr returns TriggerCondition
return Buff$NAME$.ApplyTrigger.register(whichBoolexpr)
endfunction
function RegisterRemoveBuff$NAME$Event takes boolexpr whichBoolexpr returns TriggerCondition
return Buff$NAME$.RemoveTrigger.register(whichBoolexpr)
endfunction
//! endtextmacro
/* Put your textmacro here */
// 2 lines below is test Create Buff.
//! runtextmacro CREATE_BUFF_OBJECT("rag","Rage", "ReplaceableTexturesCommandButtonsBTNAncestralSpirit.blp", "This unit is affected by Rage.")
//! runtextmacro CREATE_BUFF("rag", "Rage")
endlibrary
scope test initializer inittest
globals
unit uu
endglobals
private function a takes nothing returns boolean
local unit u = BuffRage.TriggerUnit
call SetWidgetLife(u, 1)
call BJDebugMsg(GetUnitName(u) + " is applied Rage Buff!!!")
return false
endfunction
private function b takes nothing returns boolean
local unit u = BuffRage.TriggerUnit
call SetWidgetLife(u, 220)
call BJDebugMsg(GetUnitName(u) + " is removed Rage Buff!!!")
return false
endfunction
private function inittest takes nothing returns nothing
set uu = CreateUnit(Player(0), 'hpea', 0, 0, 0)
call RegisterApplyBuffRageEvent(Filter(function a))
call RegisterRemoveBuffRageEvent(Filter(function b))
call BuffRage[uu].apply()
set BuffRage[uu].duration = 5
endfunction
endscope