| 10-06-2006, 04:16 AM | #1 |
ok... i'm making a respawn system for my map, i want the creep camp no to spawn any creep unless there are no hero around, but it seems the trigger not working... can any1 help to detect the error... it seems something is wrong inside the loop JASS:function condition takes nothing returns boolean return ( IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) == true ) endfunction function Revive takes nothing returns nothing local timer t = GetExpiredTimer() local string s = I2S(H2I(t)) local integer i = GetStoredInteger(udg_gc, s, "Group") local integer p = GetStoredInteger(udg_gc,I2S(i), "PO") local integer q = GetStoredInteger(udg_gc,I2S(i), "QO") local integer d = 1 local integer n = 1 loop exitwhen (d == 0) or (n>=60) call TriggerSleepAction( 2 ) set d = CountUnitsInGroup(GetUnitsInRangeOfLocMatching(400.00, GetRectCenter(udg_Areas[i]), Condition( function condition ))) set n = n + 1 endloop call CreateNUnitsAtLoc( 1, udg_UnitType[UnitType], Player(p), GetRandomLocInRect(udg_Areas[i]), bj_UNIT_FACING ) endfunction |
| 10-06-2006, 04:35 AM | #2 |
hmnn the whole trigger is a memory leak, also, where do you declare UnitType the one used at: udg_UnitType[UnitType] ? |
| 10-06-2006, 04:48 AM | #3 |
Well for starters the trigger is incomplete. No InitTrig, etc. set d = CountUnitsInGroup(GetUnitsInRangeOfLocMatching(400.00, GetRectCenter(udg_Areas[i]), Condition( function condition ))) That line leaks like HELL. You're leaking a BoolExpr there and a group. udg_UnitType[UnitType] Vex pointed it out, but I imagine that's the problem -- "UnitType" is undefined. Try this instead. JASS:function Revive_Check takes nothing returns boolean return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) endfunction function Revive takes nothing returns nothing local timer t = GetExpiredTimer() local string s = I2S(H2I(t)) local integer i = GetStoredInteger(udg_gc, s, "Group") local integer p = GetStoredInteger(udg_gc,I2S(i), "PO") local integer q = GetStoredInteger(udg_gc,I2S(i), "QO") local integer n = 1 local group g = CreateGroup() local boolexpr b = Condition(function Revive_Check) local boolean d = false local real x local real y loop exitwhen d or n>=60 call GroupEnumUnitsInRange(g, GetRectCenterX(udg_Areas[i]), GetRectCenterY(udg_Areas[i]), 400, b) set d = (FirstOfGroup(g) == null) set n = n + 1 call GroupClear(g) call TriggerSleepAction(2) endloop set x = GetRandomReal(GetRectMinX(udg_Areas[i]), GetRectMaxX(udg_Areas[i])) set y = GetRandomReal(GetRectMinY(udg_Areas[i]), GetRectMaxY(udg_Areas[i])) call CreateUnit(Player(p), udg_UnitType[0], x, y, GetRandomReal(0, 360)) //Make sure to fix the array index, I just put it to 0. call GroupClear(g) call DestroyGroup(g) call DestroyBoolExpr(b) set g = null set b = null set t = null endfunction |
| 10-06-2006, 05:10 AM | #4 |
I made the base of the trigger. And the variable udg_UnitType[] is declared in the init trigger, that's not the problem, but the array is the problem Zen. Where did you declare UnitType (as local) and where did you set a value? |
| 10-06-2006, 06:02 AM | #5 |
uhm sorry guys i cut down part of the system so it seems to be missing here and there im still kinda new to JASS after all uhm i guess i'll post all my respawn system after arr *i modify alot from what fireeye gave me * the initialisation, basically i'm setting the creeps i wanted to spawn for my creep camp i've fix the leaks according to Rising_Dusk had told me, still not working... p/s also, the UnitGroup array and the Area array are setup in another GUI, i lazy to type it but nothing much for that, just adding the unit into the unitgroup to fire the trigger when all unit in the camp has died JASS:function Trig_Try_Actions takes nothing returns nothing local integer i //Max Value of the Camp local integer p //Player Owner local integer q //Number of Unit camp local integer au //Unit-Type1 out of the CreepPool local integer an //Value of the previous Unit-Type local integer bu //Unit-Type2 out of the CreepPool local integer bn //Value of the previous Unit-Type local integer cu //Unit-Type3 out of the CreepPool local integer cn //Value of the previous Unit-Type local integer du //Unit-Type4 out of the CreepPool local integer dn //Value of the previous Unit-Type local integer eu //Unit-Type5 out of the CreepPool local integer en //Value of the previous Unit-Type local integer fu //Unit-Type6 out of the CreepPool local integer fn //Value of the previous Unit-Type local integer gu //Unit-Type7 out of the CreepPool local integer gn //Value of the previous Unit-Type local integer hu //Unit-Type8 out of the CreepPool local integer hn //Value of the previous Unit-Type //-------------------------------------------------------- call InitGameCacheBJ( "NewRespawnsystem.w3v" ) set udg_gc = GetLastCreatedGameCacheBJ() //-------------------------------------------------------- //CreepPool set udg_UnitType[1] = 'hpea' set udg_UnitType[2] = 'hfoo' set udg_UnitType[3] = 'hkni' set udg_UnitType[4] = 'hgry' set udg_UnitType[5] = 'otbr' set udg_UnitType[6] = 'okod' set udg_UnitType[7] = 'otau' set udg_UnitType[8] = 'odoc' //-------------------------------------------------------- //Camp 1 set i = 8 set p = 2 set q = 2 set au = 1 set an = 2 set bu = 2 set bn = 2 set cu = 3 set cn = 2 set du = 4 set dn = 2 set eu = 5 set en = 2 set fu = 6 set fn = 2 set gu = 7 set gn = 2 set hu = 8 set hn = 2 call StoreInteger(udg_gc,"1","VC",i) call StoreInteger(udg_gc,"1","PO",p) call StoreInteger(udg_gc,"1","QO",q) call StoreInteger(udg_gc,"1","U11",au) call StoreInteger(udg_gc,"1","V11",an) call StoreInteger(udg_gc,"1","U12",bu) call StoreInteger(udg_gc,"1","V12",bn) call StoreInteger(udg_gc,"1","U13",cu) call StoreInteger(udg_gc,"1","V13",cn) call StoreInteger(udg_gc,"1","U14",du) call StoreInteger(udg_gc,"1","V14",dn) call StoreInteger(udg_gc,"1","U21",eu) call StoreInteger(udg_gc,"1","V21",en) call StoreInteger(udg_gc,"1","U22",fu) call StoreInteger(udg_gc,"1","V22",fn) call StoreInteger(udg_gc,"1","U23",gu) call StoreInteger(udg_gc,"1","V23",gn) call StoreInteger(udg_gc,"1","U24",hu) call StoreInteger(udg_gc,"1","V24",hn) //Camp 2 set i = 8 set p = 1 set q = 2 set au = 1 set an = 2 set bu = 2 set bn = 2 set cu = 3 set cn = 2 set du = 4 set dn = 2 set eu = 5 set en = 2 set fu = 6 set fn = 2 set gu = 7 set gn = 2 set hu = 8 set hn = 2 call StoreInteger(udg_gc,"2","VC",i) call StoreInteger(udg_gc,"2","PO",p) call StoreInteger(udg_gc,"2","QO",q) call StoreInteger(udg_gc,"2","U11",au) call StoreInteger(udg_gc,"2","V11",an) call StoreInteger(udg_gc,"2","U12",bu) call StoreInteger(udg_gc,"2","V12",bn) call StoreInteger(udg_gc,"2","U13",cu) call StoreInteger(udg_gc,"2","V13",cn) call StoreInteger(udg_gc,"2","U14",du) call StoreInteger(udg_gc,"2","V14",dn) call StoreInteger(udg_gc,"2","U21",eu) call StoreInteger(udg_gc,"2","V21",en) call StoreInteger(udg_gc,"2","U22",fu) call StoreInteger(udg_gc,"2","V22",fn) call StoreInteger(udg_gc,"2","U23",gu) call StoreInteger(udg_gc,"2","V23",gn) call StoreInteger(udg_gc,"2","U24",hu) call StoreInteger(udg_gc,"2","V24",hn) endfunction //=========================================================================== function InitTrig_RespawnSystem_Init_1 takes nothing returns nothing set gg_trg_RespawnSystem_Init_1 = CreateTrigger( ) call TriggerAddAction( gg_trg_RespawnSystem_Init_1, function Trig_Try_Actions ) endfunction the core of the respawn system JASS:function Revive_Check takes nothing returns boolean return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) endfunction function Revive takes nothing returns nothing local timer t = GetExpiredTimer() local string s = I2S(H2I(t)) local integer i = GetStoredInteger(udg_gc, s, "Group") local integer p = GetStoredInteger(udg_gc,I2S(i), "PO") local integer q = GetStoredInteger(udg_gc,I2S(i), "QO") local integer Loop local integer Random local integer Random2 local integer Value local integer UnitType local integer d local integer n = 1 local group g = CreateGroup() local boolexpr b = Condition(function Revive_Check) local boolean d = true local real x local real y loop exitwhen d or n>=60 call GroupEnumUnitsInRange(g, GetRectCenterX(udg_Areas[i]), GetRectCenterY(udg_Areas[i]), 400, b) set d = (FirstOfGroup(g) == null) set n = n + 1 call GroupClear(g) call TriggerSleepAction(2) endloop set p = p-1 set n = 1 set Random2 = GetRandomInt(1,q) set Loop = GetStoredInteger(udg_gc,I2S(i),"VC") loop exitwhen (Loop == 0) or (n>=500) set Random = GetRandomInt(1,4) set Random = (10*Random2)+Random set UnitType = GetStoredInteger(udg_gc,I2S(i),"U"+I2S(Random)) set Value = GetStoredInteger(udg_gc,I2S(i),"V"+I2S(Random)) if (Loop >= Value) then call CreateUnit(Player(p), udg_UnitType[UnitType], x, y, GetRandomReal(0, 360)) call GroupAddUnitSimple( GetLastCreatedUnit(), udg_UnitGroup[i] ) call SetUnitUserData( GetLastCreatedUnit(), i ) set Loop = Loop - Value endif set n = n + 1 endloop call PauseTimer(t) call DestroyTimer(t) call GroupClear(g) call DestroyGroup(g) call DestroyBoolExpr(b) set g = null set b = null endfunction function Trig_RespawnCreep_Actions takes nothing returns nothing local timer t local string s local integer a local integer i = GetUnitUserData(GetDyingUnit()) call GroupRemoveUnitSimple( GetDyingUnit(), udg_UnitGroup[i] ) if (CountUnitsInGroup(udg_UnitGroup[i]) <= 0) and (i > 0) then set t = CreateTimer() set s = I2S(H2I(t)) call StoreInteger(udg_gc,s,"Group",i) call TimerStart(t, 1.00, true, function Revive) //respawn timer endif set t = null endfunction //=========================================================================== function InitTrig_RespawnCreep takes nothing returns nothing set gg_trg_RespawnCreep = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_RespawnCreep, EVENT_PLAYER_UNIT_DEATH ) call TriggerAddAction( gg_trg_RespawnCreep, function Trig_RespawnCreep_Actions ) endfunction edit : uploaded a testing map ![]() |
| 10-06-2006, 07:40 AM | #6 | |
Quote:
BJ group functions clean up the Boolexpr passed to them. |
| 10-07-2006, 05:26 PM | #7 |
And he forgot the location. |
| 10-07-2006, 05:46 PM | #8 | |
He has the location Quote:
|
| 10-07-2006, 06:05 PM | #9 |
I mean in the very first function. |
