I solved, solution here
Thank you .
Hi people, I came here because I have an strange problem triggering events with real variables :\.
The other days I was making a library (unit indexing type, and I know, there are a lot of systems right now), all works fine except for the events.
As I say, no error unless we get here:
Triggers that have the event:
Doesn't fire :\.
I was checking, dropping
If anyone can help me I would be very grateful. I will continue checking.
Greetings and thanks.
Thank you .
Hi people, I came here because I have an strange problem triggering events with real variables :\.
The other days I was making a library (unit indexing type, and I know, there are a lot of systems right now), all works fine except for the events.
JASS:
library LUIS initializer Init
globals
// 1.00 = Index event
// 2.00 = DeIndex event
//real udg_LUIS_EVENT = 0.00
private constant integer LEAVER_ABILITY = 'LUIS'
private integer array recycle
private integer recycleCount = 0
private unit array units
private integer count = 0
/*private trigger onIndex = CreateTrigger()
private trigger onDeIndex = CreateTrigger()*/
private unit EVENT_UNIT = null
// you will not die for another hashtable :3
private hashtable ht = InitHashtable()
endglobals
function TriggerRegisterIndexEvent takes trigger t returns event
return TriggerRegisterVariableEvent(t, "udg_LUIS_EVENT", EQUAL, 1.00)
endfunction
function TriggerRegisterDeIndexEvent takes trigger t returns nothing
call TriggerRegisterVariableEvent(t, "udg_LUIS_EVENT", EQUAL, 2.00)
endfunction
/*function RegisterIndexEvent takes code c returns nothing
call TriggerAddCondition(onIndex, Filter(c))
call TriggerAddAction(onIndex, c)
endfunction*/
function GetIndexedUnit takes nothing returns unit
return EVENT_UNIT
endfunction
function GetDeIndexedUnit takes nothing returns unit
return EVENT_UNIT
endfunction
function GetUnitId takes unit u returns integer
return LoadInteger(ht, GetHandleId(u), 0)
endfunction
function GetUnitById takes integer i returns unit
return units[i]
endfunction
function LockUnit takes unit u, boolean b returns nothing
call SaveBoolean(ht, GetHandleId(u), 1, b)
endfunction
function IsUnitIndexed takes unit u returns boolean
return HaveSavedInteger(ht, GetHandleId(u), 0)
endfunction
function IsUnitLocked takes unit u returns boolean
return LoadBoolean(ht, GetHandleId(u), 1)
endfunction
private function IndexUnit takes unit u returns nothing
local integer i
if (IsUnitIndexed(u) == false and IsUnitLocked(u) == false) then
if (recycleCount == 0) then
set count = count + 1
set i = count
else
set i = recycle[recycleCount]
set recycleCount = recycleCount - 1
endif
call SaveInteger(ht, GetHandleId(u), 0, i)
call LockUnit(u, false)
call UnitAddAbility(u, LEAVER_ABILITY)
call UnitMakeAbilityPermanent(u, true, LEAVER_ABILITY)
set EVENT_UNIT = u
set udg_LUIS_EVENT = 1.00
set udg_LUIS_EVENT = 0.00
set EVENT_UNIT = null
endif
endfunction
private function DeIndexUnit takes unit u returns nothing
local integer handleId
local integer id
if (GetUnitAbilityLevel(u, LEAVER_ABILITY) == 0 and IsUnitIndexed(u)) then
set handleId = GetHandleId(u)
set id = GetUnitId(u)
set recycleCount = recycleCount + 1
set recycle[recycleCount] = id
set units[id] = null
set EVENT_UNIT = u
set udg_LUIS_EVENT = 1.00
set udg_LUIS_EVENT = 0.00
set EVENT_UNIT = null
call SaveInteger(ht, handleId, 0, 0)
call RemoveSavedInteger(ht, handleId, 0)
call SaveBoolean(ht, handleId, 1, false)
call RemoveSavedBoolean(ht, handleId, 1)
endif
endfunction
private function OnEnter takes nothing returns boolean
call IndexUnit(GetFilterUnit())
return false
endfunction
private function OnLeave takes nothing returns boolean
call DeIndexUnit(GetFilterUnit())
return false
endfunction
private function Init takes nothing returns nothing
local integer i = bj_MAX_PLAYERS
local trigger t = CreateTrigger()
local boolexpr oL = Condition(function OnLeave)
local region r = CreateRegion()
local player p
local unit u
loop
exitwhen i < 0
set p = Player(i)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, oL)
call SetPlayerAbilityAvailable(p, LEAVER_ABILITY, false)
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, null)
loop
set u = FirstOfGroup(bj_lastCreatedGroup)
exitwhen u == null
call GroupRemoveUnit(bj_lastCreatedGroup, u)
call IndexUnit(u)
endloop
set i = i - 1
endloop
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(CreateTrigger(), r, Condition(function OnEnter))
set t = null
set oL = null
set r = null
set p = null
endfunction
endlibrary
As I say, no error unless we get here:
JASS:
set udg_LUIS_EVENT = 1.00
set udg_LUIS_EVENT = 0.00
Triggers that have the event:
JASS:
TriggerRegisterVariableEvent(t, "udg_LUIS_EVENT", EQUAL, 1.00)
Doesn't fire :\.
I was checking, dropping
BJDebugMsg
like a crazy man, but I can't find the failure.If anyone can help me I would be very grateful. I will continue checking.
Greetings and thanks.
Last edited: