private constant integer LEAVE_DETECTION_ABILITY = 'AIDS'
struct Combo extends array
integer combo // The number of combo points a unit has
private static method AIDS_onEffect takes nothing returns boolean
local thistype this
local boolean spell = GetSpellAbilityId()==mangle or GetSpellAbilityId()==claw // Because hardcoding is bad
if GetUnitTypeId(GetTriggerUnit())==feralDruid and spell then
set this=thistype[GetTriggerUnit()] // thistype[x] - Return the Combo struct for the unit x
if this.combo!=5 then
call UnitRemoveAbility(this.unit, combo[this.combo]) // Does JASS allow combo and combo[]? I hope so, else you have to rename combo.
set this.combo=this.combo+1
call UnitAddAbility(u, combo[this.combo])
endif
endif
return false
endmethod
private static method AIDS_onCreate takes nothing returns nothing
set this.combo=0 // in case of revival and such
endmethod
private static method AIDS_onInit takes nothing returns nothing
local trigger trig=CreateTrigger()
local integer index=0
call TriggerAddCondition(trig, Condition(thistype.onEffect))
loop
call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index=index+1
exitwhen index==bj_MAX_PLAYER_SLOTS
endloop
endmethod
//! runtextmacro AIDS()
endstruct
library Combo initializer OnInit uses AIDS, GT
globals
private constant integer UNIT_ID = 'h000' // raw code of unit feral druid
private constant integer MANGLE_ID = 'A000' // raw code of ability mangle
private constant integer CLAW_ID = 'A001' // raw code of ability claw
private integer array COMBO
public integer array Data
endglobals
private function OnCast takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id
if GetUnitTypeId(u) == UNIT_ID then
set id = GetUnitId(u)
if Data[id] != 5 then
call UnitRemoveAbility(u, COMBO[Data[id]])
set Data[id] = Data[id] + 1
call UnitAddAbility(u, COMBO[Data[id]])
endif
endif
set u = null
return false
endfunction
private function OnInit takes nothing returns nothing
local trigger t = CreateTrigger()
call GT_RegisterStartsEffectEvent(t, MANGLE_ID)
call GT_RegisterStartsEffectEvent(t, CLAW_ID)
call TriggerAddCondition(t, Condition(function OnCast))
set t = null
// set up your COMBO array values
endfunction
endlibrary
library Example uses Combo
private function Example takes nothing returns nothing
local unit u = SomeUnit // just an example, let's say it's a unit
local integer i
set Combo_Data[GetUnitId(u)] = 1 // use this instead of SetUnitUserData(u, 1)
set i = Combo_Data[GetUnitId(u)] // use this instead of GetUnitUserData(u)
endfunction
endlibrary
library ComboPoints initializer onInit uses AIDS, GT
globals
integer array COMBO
public integer array Data
endglobals
private function onCast takes nothing returns boolean
local unit u = GetTriggerUnit()
local integer id
if GetUnitTypeId(u) == feralDruid then
set id = GetUnitId(u)
if Data[id] != 5 then
call UnitRemoveAbility(u, COMBO[Data[id]])
set Data[id] = Data[id] + 1
call UnitAddAbility(u, COMBO[Data[id]])
endif
endif
set u = null
return false
endfunction
private function OnInit takes nothing returns nothing
call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), mangle), Condition(function onCast))
call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), claw), Condition(function onCast))
// set up your COMBO array values
set COMBO[0] = 'A009'
set COMBO[1] = 'A00E'
set COMBO[2] = 'A00F'
set COMBO[3] = 'A00G'
set COMBO[4] = 'A00H'
set COMBO[5] = 'A00I'
endfunction
endlibrary
scope FerociousBite initializer init
private function Chance takes integer level returns integer
return level * 2
endfunction
private function Damage takes integer level returns real
return (level * 0.5) + 0.5
endfunction
private function Conditions takes nothing returns boolean
local real fbDamage
local unit u = GetTriggerUnit()
//local integer ud = GetUnitUserData(u)
local integer UD = COMBO_Data[GetUnitId(u)]
if (GetSpellAbilityId() == ferociousBite and UD > 0) then
set fbDamage = (GetHeroAgi(u, true) * Damage(UD))
call UnitDamageTarget(u, GetSpellTargetUnit(), fbDamage, true, false, ATTACK_TYPE_MELEE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call UnitRemoveAbility(u, COMBO[UD])
if (GetRandomInt(1, 100) <= Chance(GetUnitAbilityLevel(u, ferociousBite)) and UD >= 4) then
//call SetUnitUserData(u, ud - 3)
set UD = UD - 3
else
//call SetUnitUserData(u, 0)
set UD = 0
endif
call UnitAddAbility(u, COMBO[UD])
elseif (GetSpellAbilityId() == ferociousBite and UD <= 0) then
call IssueImmediateOrder(u, "stop")
call SimError(GetOwningPlayer(u), "You need at least one combo point!")
endif
set u = null
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer index = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(index), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set index = index + 1
exitwhen index == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Conditions))
set t = null
endfunction
endscope
library Test
globals
public integer MyInt // you would need to refer this as Test_MyInt outside of the Test library
endglobals
endlibrary
library Wow
globals
public integer MyInt // you would need to refer this as Wow_MyInt outside of the Wow library
endglobals
endlibrary
library Combo
globals
public integer MyInt // you would need to refer this as Combo_MyInt outside of the Combo library
endglobals
endlibrary
Public variables need the prefix of the scope/library when using outside the scope/library that was createdAs the variables are public you can just use Data[GetUnitId(yourunit)]
Those three little examples were honestly a perfect explanation.Public global's prefix is basically the library name. So, it should be "ComboPoints_Data".