# algrebraic situation

Status
Not open for further replies.

#### TheAncient

Level 7
i am working on a map (no duh) and i have all of the farm, tower, town, and barrack spawn locations for the beginning of the map set in arrays.

Farm[1-16]
Tower[1-16]
Town[1-4]
Barrack[1-4]

Also, there are 4 players which are supposed to gain these units.
Player[8-11]

Each player is supposed to gain 4 farms, 4 towers, 1 town, and 1 barracks.

now since there is supposed to be eventually multiple race choices, i am trying to minimize the head-ache with Integer A and B.

but the problem is at this point i cannot figure out what equation to use in order for it to place a farm in farm[1-4] for player 8, a farm in [5-8] for player 9, a farm in [9-12] for player 10, and a farm in [13-16] for player 10. this situation repeats itself for towers as well.

here is basically the trigger. ignore the cinematic and timer related things.

• Game Start
• Events
• Conditions
• Actions
• Cinematic - Turn cinematic mode Off for (All players)
• Camera - Pan camera for Player 1 (Red) to (Center of Evil Spawn 1 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 2 (Blue) to (Center of Evil Spawn 2 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 3 (Teal) to (Center of Evil Spawn 3 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 4 (Purple) to (Center of Evil Spawn 4 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 5 (Yellow) to (Center of Evil Spawn 5 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 6 (Orange) to (Center of Evil Spawn 6 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 7 (Green) to (Center of Evil Spawn 7 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 8 (Pink) to (Center of Castle 1 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 9 (Gray) to (Center of Castle 2 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 10 (Light Blue) to (Center of Castle 3 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 11 (Dark Green) to (Center of Castle 4 <gen>) over 0.00 seconds
• Camera - Pan camera for Player 12 (Brown) to (Center of Titan Spawn <gen>) over 0.00 seconds
• Countdown Timer - Start income_Timer as a Repeating timer that will expire in 20.00 seconds
• Countdown Timer - Create a timer window for (Last started timer) with title Income in...
• Countdown Timer - Start Sargeras_timer as a One-shot timer that will expire in 120.00 seconds
• Countdown Timer - Create a timer window for (Last started timer) with title Sargeras in...
• For each (Integer A) from 1 to 7, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Race_chosen_integ[(Integer A)] Equal to 0
• Then - Actions
• Unit - Create 1 Void Summoner for Player[(Integer A)] at Evil_Spawn_point[(Integer A)] facing Default building facing degrees
• Else - Actions
• For each (Integer A) from 8 to 11, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Race_chosen_integ[(Integer A)] Equal to 0
• Then - Actions
• Unit - Create 1 Town Hall for Player[(Integer A)] at Town_point[((Integer A) - 7)] facing Default building facing degrees
• Unit - Create 1 Barracks for Player[(Integer A)] at Barrack_point[((Integer A) - 7)] facing Default building facing degrees
• For each (Integer B) from 1 to 4, do (Actions)
• Loop - Actions
• Unit - Create 1 Tower for Player[(Integer A)] at Tower_point[(Integer B)] facing Default building facing degrees
• For each (Integer B) from 1 to 4, do (Actions)
• Loop - Actions
• Unit - Create 1 Farm for Player[(Integer A)] at Farm_point[(Integer B)] facing Default building facing degrees
• Else - Actions

#### Bannar

Level 26
I'm not fan of Integer A & B, although I left one because it may be confusing for you to use 3rd integer variable (as I'm using 'i' and 'n' to help me calculate indexes).
• Set n = 1
• For each (Integer i) from 8 to 11, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• Race_chosen_integ[i] Equal to 0
• Then - Actions
• Unit - Create 1 Town Hall for Player[i] at Town_point[(i - 7)] facing Default building facing degrees
• Unit - Create 1 Barracks for Player[(Integer A)] at Barrack_point[(i - 7)] facing Default building facing degrees
• For each (Integer A) from n to (n + 3), do (Actions)
• Loop - Actions
• Unit - Create 1 Tower for Player[i] at Tower_point[(Integer A)] facing Default building facing degrees
• Unit - Create 1 Farm for Player[i] at Farm_point[(Integer A)] facing Default building facing degrees
• Set n = (n + 4)
• Else - Actions
EDIT: I hope you remember about removing locations which won't be usefull anymore.

#### TheAncient

Level 7
i know they leak eventually, but there are nearly 200 points in variableArrays. how would i make command to destroy them without typing them 1 at a time?

and thanks +rep

#### Bannar

Level 26
You can use function RemoveLocation() in loops to help you with such stuff. Btw, even in trigger above mentioned function could be added to free up memory immidiately:
• For each (Integer A) from n to (n + 3), do (Actions)
• Loop - Actions
• // stuff
• // after creating units in those locations, they are actually no longer needed so:
• Custom script: call RemoveLocation(udg_Tower_point[bj_forLoopAIndex]
• Custom script: call RemoveLocation(udg_Farm_point[bj_forLoopAIndex]
For sure it makes your life easier. And if you created like 200 locations (let's say: location 'p[]') at the begining, removing them may be done with (again loop usage):

• For each (Integer i) from 1 to 200, do (Actions)
• Loop - Actions
• Custom script: call RemoveLocation(udg_p[udg_i])

Status
Not open for further replies.

Replies
4
Views
488
Replies
16
Views
2K
Replies
3
Views
816
Replies
2
Views
536
Replies
8
Views
731