Making Code Graceful...
Posted: Tue Oct 04, 2011 10:12 am
I am making essentially a singleplayer version of territories. If at any time either team controls all of the flags, the game ends and they are victorious. If, at the end of 15 minutes, neither team controls all of the flags, then the team that controls the most wins. If there is a tie, the game enters into overtime and the first team to have more flags than his opponent at anytime wins. There are 5 flags.
Easy enough to figure out a way to script that. The challenge, for me, is getting the script to be as small as possible. I want the least number of map actions conceivable to still convey this gametype, because everything else going on in the map requires TONS of map actions.
My plan: Have Tuni's testing for each subject list around the flag during regulation time. The first tests to see if light units are at flag 1, if so test to see if dark units are there, if not test flag1 again. If dark units are there, test flag 1 for light units again, if not move on to flag 2. Test flag 2 for light units, if present test for dark, if not go back and test flag1 again. etcetcetc... That cycle continues for all the flags, and as soon as the light team is uncontested, they win. Duplicate that code and flip it so it tests dark first, and you have a seperate cycle to see if dark wins at any point.
At end of game: Test each flag for light units, and if they are there than reveal a special "point scoring" unit off map. Same for dark. Two GEOM's count the number of points for each team, send the results to a MATH action that compares, and if one team has more than the other, that team wins.
If Tie: Hide the point units with a mass unit control, and repeat end of game test again and again until one team has the advantage.
Is this truly the most cost-effective way, map action wise, to do this? I'm including below the script through regulation time to show just how inefficient this method is. End of game and Overtime don't look much better.
I'd appreciate any action-saving ideas.
Light Forces Have NW Flag? [Test Unit]
initially_active
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Failure
Dark Forces Have NW Flag?
}
Dark Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Success
Light Forces Have NW Flag?
Activates on Failure
Light Forces Have NE Flag?
}
Light Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NE Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Light Forces Have SE Flag?
}
Light Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have SE Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Light Forces Have SW Flag?
}
Light Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have SW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Light Forces Have Center Flag?
}
Light Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have Center Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Light Victory
}
{}-----------------------------------------------------------------
Light Forces Dead? [Test Unit]
deactivates_on_successful_execution
0.00, 0.00
{
Link
LIGHT FORCES SUBJ
PLAYER FORCES SUBJ
Unit Count Equal To
0
Activates on Success
Dark Victory
}
Dark Victory [Endgame Condition]
deactivates_on_trigger
0.00, 0.00
{
Dark Victory Flag
}
Dark Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Failure
Light Forces Have NW Flag?
}
Light Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Success
Dark Forces Have NW Flag?
Activates on Failure
Dark Forces Have NE Flag?
}
Dark Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NE Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Dark Forces Have SE Flag?
}
Dark Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have SE Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Dark Forces Have SW Flag?
}
Dark Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have SW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Dark Forces Have Center Flag?
}
Dark Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have Center Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Dark Victory
}
{}-----------------------------------------------------------------
That's 20 actions just for regulation time, for those keeping score at home.
Easy enough to figure out a way to script that. The challenge, for me, is getting the script to be as small as possible. I want the least number of map actions conceivable to still convey this gametype, because everything else going on in the map requires TONS of map actions.
My plan: Have Tuni's testing for each subject list around the flag during regulation time. The first tests to see if light units are at flag 1, if so test to see if dark units are there, if not test flag1 again. If dark units are there, test flag 1 for light units again, if not move on to flag 2. Test flag 2 for light units, if present test for dark, if not go back and test flag1 again. etcetcetc... That cycle continues for all the flags, and as soon as the light team is uncontested, they win. Duplicate that code and flip it so it tests dark first, and you have a seperate cycle to see if dark wins at any point.
At end of game: Test each flag for light units, and if they are there than reveal a special "point scoring" unit off map. Same for dark. Two GEOM's count the number of points for each team, send the results to a MATH action that compares, and if one team has more than the other, that team wins.
If Tie: Hide the point units with a mass unit control, and repeat end of game test again and again until one team has the advantage.
Is this truly the most cost-effective way, map action wise, to do this? I'm including below the script through regulation time to show just how inefficient this method is. End of game and Overtime don't look much better.
I'd appreciate any action-saving ideas.
Light Forces Have NW Flag? [Test Unit]
initially_active
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Failure
Dark Forces Have NW Flag?
}
Dark Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Success
Light Forces Have NW Flag?
Activates on Failure
Light Forces Have NE Flag?
}
Light Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NE Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Light Forces Have SE Flag?
}
Light Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have SE Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Light Forces Have SW Flag?
}
Light Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have SW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Light Forces Have Center Flag?
}
Light Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have Center Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Light Forces Have NW Flag?
}
Dark Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Light Victory
}
{}-----------------------------------------------------------------
Light Forces Dead? [Test Unit]
deactivates_on_successful_execution
0.00, 0.00
{
Link
LIGHT FORCES SUBJ
PLAYER FORCES SUBJ
Unit Count Equal To
0
Activates on Success
Dark Victory
}
Dark Victory [Endgame Condition]
deactivates_on_trigger
0.00, 0.00
{
Dark Victory Flag
}
Dark Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Failure
Light Forces Have NW Flag?
}
Light Forces Have NW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Closed Polygon Flag
true
Polygon
149.454, 65.499
142.344, 68.583
144.321, 74.624
149.272, 76.004
153.168, 71.147
Activates on Success
Dark Forces Have NW Flag?
Activates on Failure
Dark Forces Have NE Flag?
}
Dark Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have NE Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have NE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
48.079, 73.143
41.979, 72.272
39.997, 76.633
42.834, 81.192
48.372, 77.879
Activates on Failure
Dark Forces Have SE Flag?
}
Dark Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have SE Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have SE Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
56.342, 143.594
52.452, 137.741
46.963, 143.219
52.688, 146.838
Activates on Failure
Dark Forces Have SW Flag?
}
Dark Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have SW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have SW Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
153.450, 134.278
147.211, 133.913
146.493, 141.061
151.106, 140.764
153.663, 137.510
Activates on Failure
Dark Forces Have Center Flag?
}
Dark Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
1
Unit Count Greater Than
0
Activates on Success
Light Forces Have Center Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Dark Forces Have NW Flag?
}
Light Forces Have Center Flag? [Test Unit]
deactivates_on_execution
0.00, 0.00
{
Team Index
0
Unit Count Greater Than
0
Activates on Success
Dark Forces Have NW Flag?
Closed Polygon Flag
true
Polygon
99.766, 107.114
95.278, 105.616
91.290, 107.610
91.432, 112.004
94.659, 115.524
98.284, 114.219
100.401, 110.553
Activates on Failure
Dark Victory
}
{}-----------------------------------------------------------------
That's 20 actions just for regulation time, for those keeping score at home.