Well, either i'm writing nonsense in JASS (which is more likely) or I found a bug in PJASS (very unlikely).
This is a trigger i wanted to implement in my Unit Defense Map, based on an old StarCraft Map. The trigger should catch any enter or leave of a unit in a distinct region, add the unit to a unitgroup array and count the units beeing in that group. Once there are more than 10 or 20 units in one group it should remove every unit in that region of the same type and create another in the middle of that region.
After JassCraft crashed one time and i had to recover my trigger from RAM via dump, i finally finished the trigger.
I'd love to get any help, because i can't find anything wrong with this trigger.
It was written mostly in JassCraft, only the init trigger was created by world editor.
Trigger in JASS
globals
JASS:
globals
trigger gg_trg_HGM_Exchange
rect gg_rct_HGMASuperunitsExchange
group array udg_hydraexgrp
group array udg_marineexgrp
group array udg_ghostexgrp
group array udg_archonexgrp
integer array udg_archonex
integer array udg_marineex
integer array udg_ghostex
integer array udg_hydraex
endglobals
InitTrigger
JASS:
function InitTrig_HGM_Exchange takes nothing returns nothing
set gg_trg_HGM_Exchange = CreateTrigger ( )
call TriggerRegisterEnterRectSimple ( gg_trg_HGM_Exchange , gg_rct_HGMASuperunitsExchange )
call TriggerRegisterLeaveRectSimple ( gg_trg_HGM_Exchange , gg_rct_HGMASuperunitsExchange )
call TriggerAddAction ( gg_trg_HGM_Exchange , function Trig_HGM_Exchange_Actions )
endfunction
Actions
JASS:
function Trig_HGM_Exchange_Actions takes nothing returns nothing
local unit uniten =GetEnteringUnit ()
local unit unitle =GetLeavingUnit ()
local player playeren =GetOwningPlayer (uniten )
local player playerle =GetOwningPlayer (unitle )
local integer playerenid =(GetPlayerId (playeren )+1 )
local integer playerleid =(GetPlayerId (playerle )+1 )
local integer index =1
if GetUnitTypeId (uniten )=='z001' then
set udg_marineex [playerenid ]=udg_marineex [playerenid ] + 1
call GroupAddUnit (udg_marineexgrp [playerenid ], uniten )
endif
if GetUnitTypeId (uniten )=='h000' then
set udg_ghostex [playerenid ]=udg_ghostex [playerenid ] + 1
call GroupAddUnit (udg_ghostexgrp [playerenid ], uniten )
endif
if GetUnitTypeId (uniten )=='z000' then
set udg_hydraex [playerenid ]=udg_hydraex [playerenid ] + 1
call GroupAddUnit (udg_hydraexgrp [playerenid ], uniten )
endif
if GetUnitTypeId (uniten )=='h001' then
set udg_archonex [playerenid ]=udg_archonex [playerenid ] + 1
call GroupAddUnit (udg_archonexgrp [playerenid ], uniten )
endif
if GetUnitTypeId (unitle )=='z001' then
set udg_marineex [playerleid ]=udg_marineex [playerleid ] - 1
call GroupRemoveUnit (udg_marineexgrp [playerleid ], uniten )
endif
if GetUnitTypeId (unitle )=='h000' then
set udg_ghostex [playerleid ]=udg_ghostex [playerleid ] - 1
call GroupRemoveUnit (udg_ghostexgrp [playerleid ], uniten )
endif
if GetUnitTypeId (unitle )=='z000' then
set udg_hydraex [playerleid ]=udg_hydraex [playerleid ] - 1
call GroupRemoveUnit (udg_hydraexgrp [playerleid ], uniten )
endif
if GetUnitTypeId (unitle )=='h001' then
set udg_archonex [playerleid ]=udg_archonex [playerleid ] - 1
call GroupRemoveUnit (udg_archonexgrp [playerleid ], uniten )
endif
loop
if udg_marineex [index ]>=20 then
call Trig_HGM_Exchange_Super_Marine ()
endif
if udg_ghostex [index ]>=20 then
call Trig_HGM_Exchange_Super_Ghost ()
endif
if udg_hydraex [index ]>=20 then
call Trig_HGM_Exchange_Super_Hydra ()
endif
if udg_archonex [index ]>=10 then
call Trig_HGM_Exchange_Super_Archon ()
endif
set index =index +1
exitwhen index >7
endloop
set uniten =null
set unitle =null
set playeren =null
set playerle =null
endfunction
FunctionsCalled
JASS:
function Trig_HGM_Exchange_Super_Archon takes nothing returns nothing
local integer index =1
local location locex =GetRectCenter (gg_rct_HGMASuperunitsExchange )
loop
if udg_archonex [index ]>=10 then
ForGroup (udg_archonexgrp [index ], function Trig_HGM_Exchange_SuperUnit_Remove )
set udg_archonex [index ]=0
call CreateUnitAtLoc (Player (index -1 ), 'h00D' , locex , 270.0 )
endif
set index =index +1
exitwhen index >7
endloop
call RemoveLocation (locex )
endfunction
function Trig_HGM_Exchange_Super_Hydra takes nothing returns nothing
local integer index =1
local location locex =GetRectCenter (gg_rct_HGMASuperunitsExchange )
loop
if udg_hydraex [index ]>=10 then
ForGroup (udg_hydraexgrp [index ], function Trig_HGM_Exchange_SuperUnit_Remove )
set udg_hydraex [index ]=0
call CreateUnitAtLoc (Player (index -1 ), 'z006' , locex , 270.0 )
endif
set index =index +1
exitwhen index >7
endloop
call RemoveLocation (locex )
endfunction
function Trig_HGM_Exchange_Super_Ghost takes nothing returns nothing
local integer index =1
local location locex =GetRectCenter (gg_rct_HGMASuperunitsExchange )
loop
if udg_ghostex [index ]>=10 then
ForGroup (udg_ghostexgrp [index ], function Trig_HGM_Exchange_SuperUnit_Remove )
set udg_ghostex [index ]=0
call CreateUnitAtLoc (Player (index -1 ), 'h00E' , locex , 270.0 )
endif
set index =index +1
exitwhen index >7
endloop
call RemoveLocation (locex )
endfunction
function Trig_HGM_Exchange_Super_Marine takes nothing returns nothing
local integer index =1
local location locex =GetRectCenter (gg_rct_HGMASuperunitsExchange )
loop
if udg_marineex [index ]>=10 then
ForGroup (udg_marineexgrp [index ], function Trig_HGM_Exchange_SuperUnit_Remove )
set udg_marineex [index ]=0
call CreateUnitAtLoc (Player (index -1 ), 'z007' , locex , 270.0 )
endif
set index =index +1
exitwhen index >7
endloop
call RemoveLocation (locex )
endfunction
function Trig_HGM_Exchange_SuperUnit_Remove takes nothing returns nothing
local unit unitp =GetEnumUnit ()
call RemoveUnit (unitp )
endfunction
Thanks in advance
Deaod
dit: Attached the Trigger. Thats an exact copy of what was checked by PJASS in Jasscraft and newgen.