KvickaN
TH.net Regular
- Reaction score
- 24
Hi!
The map is a TD where each induvidual player spawn its own wave by using an ability in the players "builder unit". I think there's some problem when many players uses his/her ability at the same time.
The problem is that when playing the map online, spawning gets buggy, it's supposed to spawn 25 or 50 units (depending on level) but it seems like it's random every time. Sometimes 18, sometimes 28 etc. (It works great offline, spawning all 50 with no problem)
At first, I thought it was because of it being the same ability, so I made 9 separate abilities so that each player has their own unique ability id. That did not solve the problem... I have also tried splitting the trigger into 9 of the same but each trigger only responding to the specific player that casts ability. This resulted in the exact same thing, same problem.
Please help!
This is the trigger:
Pathing 1 red
Pathing 2 red
Pathing 3 red
Pathing 4 red
If you see anything obvious I would be grateful for some help!
Edit: I think solving my problem involves Local Variables, will try to read up on this. Help still appreciated!
Edit: Yes! Adding this worked:
local integer bj_forLoopAIndex
local integer bj_forLoopAIndexEnd
The map is a TD where each induvidual player spawn its own wave by using an ability in the players "builder unit". I think there's some problem when many players uses his/her ability at the same time.
The problem is that when playing the map online, spawning gets buggy, it's supposed to spawn 25 or 50 units (depending on level) but it seems like it's random every time. Sometimes 18, sometimes 28 etc. (It works great offline, spawning all 50 with no problem)
At first, I thought it was because of it being the same ability, so I made 9 separate abilities so that each player has their own unique ability id. That did not solve the problem... I have also tried splitting the trigger into 9 of the same but each trigger only responding to the specific player that casts ability. This resulted in the exact same thing, same problem.
Please help!
This is the trigger:
Code:
Spawn Level
Events
Unit - A unit Finishes casting an ability
Conditions
(Ability being cast) Equal to GoSpawn[(Player number of (Owner of (Triggering unit)))]
Actions
Set Level[(Player number of (Owner of (Triggering unit)))] = (Level[(Player number of (Owner of (Triggering unit)))] + 1)
Leaderboard - Change the label for (Owner of (Triggering unit)) in LEADERBOARD to ((Name of (Owner of (Triggering unit))) + ( |c00ffffff@lvl:|r |c00FFFF00 + (String(Level[(Player number of (Owner of (Triggering unit)))]))))
Unit - Set Max Mana of (Random unit from (Units owned by (Owner of (Triggering unit)) of type |cFFFF0000Summoner|r)) to 0
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level[(Player number of (Owner of (Triggering unit)))] Equal to 10) or ((Level[(Player number of (Owner of (Triggering unit)))] Equal to 17) or (Level[(Player number of (Owner of (Triggering unit)))] Equal to 20))
Then - Actions
Set Points[(Player number of (Owner of (Triggering unit)))] = (Center of TempLoc[(Player number of (Owner of (Triggering unit)))])
Unit - Create 1 MonsterType[Level[(Player number of (Owner of (Triggering unit)))]] for Player 12 (Brown) at Points[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
Custom script: call RemoveLocation(udg_Points[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Set LastCUnit[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
Set TempMovePoint1[(Player number of (Owner of (Triggering unit)))] = (Center of MovePoint1[(Player number of (Owner of (Triggering unit)))])
Unit - Order LastCUnit[(Player number of (Owner of (Triggering unit)))] to Move To TempMovePoint1[(Player number of (Owner of (Triggering unit)))]
Custom script: call RemoveLocation(udg_TempMovePoint1[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Game - Display to (All players) for 5.00 seconds the text: ((Spawning level: |c00FFFF00 + (String(Level[(Player number of (Owner of (Triggering unit)))]))) + (|r - + ((Name of LastCUnit[(Player number of (Owner of (Triggering unit)))]) + (( for + pc[(Player number of (Owner of (Triggering unit)))]) + ((Name of (Own
For each (Integer A) from 1 to 25, do (Actions)
Loop - Actions
If ((Number of units in (Units in PlayerArea[(Player number of (Owner of (Triggering unit)))] owned by Player 12 (Brown))) Greater than 4) then do (Wait until ((Number of units in (Units in PlayerArea[(Player number of (Owner of (Triggering unit)))] owned by Player 12 (Brown))) Less than 5), checking every 0.10 seconds) else do (Do nothing)
If (PlayerChances[(Player number of (Owner of (Triggering unit)))] Less than or equal to 0) then do (Skip remaining actions) else do (Wait 3.00 game-time seconds)
Set Points[(Player number of (Owner of (Triggering unit)))] = (Center of TempLoc[(Player number of (Owner of (Triggering unit)))])
Unit - Create 1 MonsterType[Level[(Player number of (Owner of (Triggering unit)))]] for Player 12 (Brown) at Points[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
Custom script: call RemoveLocation(udg_Points[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Set LastCUnit[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
Set TempMovePoint1[(Player number of (Owner of (Triggering unit)))] = (Center of MovePoint1[(Player number of (Owner of (Triggering unit)))])
Unit - Order LastCUnit[(Player number of (Owner of (Triggering unit)))] to Move To TempMovePoint1[(Player number of (Owner of (Triggering unit)))]
Custom script: call RemoveLocation(udg_TempMovePoint1[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Unit - Set Max Mana of (Random unit from (Units owned by (Owner of (Triggering unit)) of type |cFFFF0000Summoner|r)) to 10
Else - Actions
Set Points[(Player number of (Owner of (Triggering unit)))] = (Center of TempLoc[(Player number of (Owner of (Triggering unit)))])
Unit - Create 1 MonsterType[Level[(Player number of (Owner of (Triggering unit)))]] for Player 12 (Brown) at Points[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
Custom script: call RemoveLocation(udg_Points[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Set LastCUnit[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
Set TempMovePoint1[(Player number of (Owner of (Triggering unit)))] = (Center of MovePoint1[(Player number of (Owner of (Triggering unit)))])
Unit - Order LastCUnit[(Player number of (Owner of (Triggering unit)))] to Move To TempMovePoint1[(Player number of (Owner of (Triggering unit)))]
Custom script: call RemoveLocation(udg_TempMovePoint1[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Game - Display to (All players) for 5.00 seconds the text: ((Spawning level: |c00FFFF00 + (String(Level[(Player number of (Owner of (Triggering unit)))]))) + (|r - + ((Name of LastCUnit[(Player number of (Owner of (Triggering unit)))]) + (( for + pc[(Player number of (Owner of (Triggering unit)))]) + ((Name of (Own
For each (Integer A) from 1 to 50, do (Actions)
Loop - Actions
If ((Number of units in (Units in PlayerArea[(Player number of (Owner of (Triggering unit)))] owned by Player 12 (Brown))) Greater than 7) then do (Wait until ((Number of units in (Units in PlayerArea[(Player number of (Owner of (Triggering unit)))] owned by Player 12 (Brown))) Less than 8), checking every 0.10 seconds) else do (Do nothing)
If (PlayerChances[(Player number of (Owner of (Triggering unit)))] Less than or equal to 0) then do (Skip remaining actions) else do (Wait 0.30 game-time seconds)
Set Points[(Player number of (Owner of (Triggering unit)))] = (Center of TempLoc[(Player number of (Owner of (Triggering unit)))])
Unit - Create 1 MonsterType[Level[(Player number of (Owner of (Triggering unit)))]] for Player 12 (Brown) at Points[(Player number of (Owner of (Triggering unit)))] facing Default building facing degrees
Custom script: call RemoveLocation(udg_Points[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Set LastCUnit[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
Set TempMovePoint1[(Player number of (Owner of (Triggering unit)))] = (Center of MovePoint1[(Player number of (Owner of (Triggering unit)))])
Unit - Order LastCUnit[(Player number of (Owner of (Triggering unit)))] to Move To TempMovePoint1[(Player number of (Owner of (Triggering unit)))]
Custom script: call RemoveLocation(udg_TempMovePoint1[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
Unit - Set Max Mana of (Random unit from (Units owned by (Owner of (Triggering unit)) of type |cFFFF0000Summoner|r)) to 10
Pathing 1 red
Code:
red 1
Events
Unit - A unit enters red1 <gen>
Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Actions
Set RedMovePoints[2] = (Center of MovePoint2[1])
Unit - Order (Entering unit) to Move To RedMovePoints[2]
Custom script: call RemoveLocation(udg_RedMovePoints[2])
Code:
red 2
Events
Unit - A unit enters red2 <gen>
Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Actions
Set RedMovePoints[3] = (Center of MovePoint3[1])
Unit - Order (Entering unit) to Move To RedMovePoints[3]
Custom script: call RemoveLocation(udg_RedMovePoints[3])
Code:
red 3
Events
Unit - A unit enters red3 <gen>
Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Actions
Set RedMovePoints[4] = (Center of MovePoint4[1])
Unit - Order (Entering unit) to Move To RedMovePoints[4]
Custom script: call RemoveLocation(udg_RedMovePoints[4])
Code:
red 4 to end
Events
Unit - A unit enters red4 <gen>
Conditions
(Owner of (Entering unit)) Equal to Player 12 (Brown)
Actions
Set RedMovePoints[5] = (Center of MovePoint5[1])
Unit - Order (Entering unit) to Move To RedMovePoints[5]
Custom script: call RemoveLocation(udg_RedMovePoints[5])
If you see anything obvious I would be grateful for some help!
Edit: I think solving my problem involves Local Variables, will try to read up on this. Help still appreciated!
Edit: Yes! Adding this worked:
local integer bj_forLoopAIndex
local integer bj_forLoopAIndexEnd
Last edited: