- Joined
- Dec 12, 2008
- Messages
- 7,376
The TIMEOUT constant could be moved outside the module
You can make it public and use BuffGenerator_TIMEOUT inside the module =D
You can make it public and use BuffGenerator_TIMEOUT inside the module =D
// ForEachBuff Modules
module ForEachBuff
static method ForEachBuff takes unit enumUnit returns nothing
local Buff this=total
endmodule
module ForEachBuffLoop
@implement ForEachBuff@ //This way the above module is optional, because JassHelper only includes the first "implement"
loop
exitwhen this==0
if UnitHasBuff(enumUnit,this) then
endmodule
module ForEachBuffNull
endif
set this=this-1
endloop
endmodule
module ForEachBuffEnd
@implement ForEachBuffNull@ //Same as the above
endmethod
endmodule
Updated to v3.2 and implemented this.I recommend changing the ForEachBuff module (changes are highlighted):
JASS:// ForEachBuff Modules module ForEachBuff static method ForEachBuff takes unit enumUnit returns nothing local Buff this=total endmodule module ForEachBuffLoop @implement ForEachBuff@ //This way the above module is optional, because JassHelper only includes the first "implement" loop exitwhen this==0 if UnitHasBuff(enumUnit,this) then endmodule module ForEachBuffNull endif set this=this-1 endloop endmodule module ForEachBuffEnd @implement ForEachBuffNull@ //Same as the above endmethod endmodule
implement ForEachBuffLoop
// code here
implement ForEachBuffEnd
On ForEachBuff module "this" refers to current buff of the loop.I think it's weird in one of your functions you declare a local variable "i" and then declare "this" which simply points to "i", is there a reason for it?
module BuffStruct
static method operator buff takes nothing returns integer
return Buff.index__q[thistype.typeid]
endmethod
// code bla bla ble
private static method onInit takes nothing returns nothing
set Buff.index__q[thistype.typeid] = InitBuff(AURAID, BUFFID, function thistype.m)
endmethod
endmodule
//You can change these to let the unit ID be the variable stored, and "GetBuffEventUnit" can just do "GetUnitById(buffID)".
function GetBuffEventUnit takes nothing returns unit
return eu
endfunction
function GetBuffEventUnitId takes nothing returns integer
return GetUnitUserData(eu)
endfunction
Nestharus said:You aren't handling recursive events. As this stands, events fired inside of events will break =).
call DisableTrigger(GetTriggeringTrigger())
// your code
call EnableTrigger(GetTriggeringTrigger())
RemoveUnit(u1) //fires event
//Remove all units owned by deindexed unit
loop
//get next unit owned by u1
call RemoveUnit(ownedUnit)
//if you disable the deindexer here, the owned unit will not
//be deindexed, meaning that you will leak indexes. The events
//have to fire in order for the owned unit to be deindexed. This
//code runs inside of a fire event, meaning that it needs proper
//recursion handling so that the event can be recursively run within
//itself like this example.
//without recursion, you will not be able to remove any units within
//a deindex event and you will not be able to create any units within
//an index event
endloop