- Joined
- Nov 30, 2007
- Messages
- 1,202
Noticed I forgot to actually create the trigger. GG. Another question though, if i only want to use integer array stackTime and real array stackDmg and not actually Stack array. How do I change it without having to define the array size inside the struct?
Another similar question: How do i put the variables from the Target struct with the prefix "stack" inside the Stack struct but refer to them through target?
JASS:
library FireSystem
globals
Stack array stack
private constant integer FIRE_DMG = 'A000'
endglobals
struct Fire
endstruct
struct Stack
private integer stackTime
private real stackDmg
static group stackGroup = CreateGroup()
static integer count
static method onAttackFilter takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_STRUCTURE) and GetUnitAbilityLevel(GetAttacker(), FIRE_DMG) > 0
endmethod
static method onAttack takes nothing returns boolean
local unit attacked = GetTriggerUnit()
if Stack.onAttackFilter(attacked) then
call BJDebugMsg(GetUnitName(attacked))
endif
return false
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Stack.onAttack))
endmethod
endstruct
endlibrary
Another similar question: How do i put the variables from the Target struct with the prefix "stack" inside the Stack struct but refer to them through target?
JASS:
library FireSystem
globals
Target array target
private constant integer FIRE_DMG = 'A000'
private constant integer STACK_DURATION = 10
endglobals
struct Stack
static group gr
static integer count
endstruct
struct Target
unit u
real stackDmg // Can I put these inside my Stack struct and how would I find them through target[i]?
real stackTime
private static method onAttackFilter takes unit u returns boolean
return IsUnitType(u, UNIT_TYPE_STRUCTURE) and GetUnitAbilityLevel(GetAttacker(), FIRE_DMG) > 0
endmethod
private static method onAttack takes nothing returns boolean
local unit attacked = GetTriggerUnit()
local integer i = GetUnitUserData(attacked)
if Target.onAttackFilter(attacked) then
if target[i] == null then
set target[i] = Target.create()
set target[i].u = attacked
endif
endif
set attacked = null
return false
endmethod
private static method create takes nothing returns Target
return .allocate()
endmethod
static method onInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddCondition(t, Condition(function Target.onAttack))
endmethod
endstruct
endlibrary
Last edited: