Post news RSS Rallypoints and Loopable Construction

Imagine a really old RTS where you have to keep clicking the construct button to keep making a unit pop up. Looping solves the finger pain by allowing you to tell a factory to keep building until further notice.

Posted by on

Looping
Imagine a really old RTS where you have to keep clicking the construct button to keep making a unit pop up. Looping solves the finger pain by allowing you to tell a factory to keep building until further notice.

This feature is used in games like Supreme Commander so the player can focus on things besides constructing units. As a general rule, macromanagement is generally more fun than micromanagement in an RTS. This is also why my game's economy is simpler than most (but by no means easier, see later in the article).

Rallypoints
Let's say you want all those loop constructed units to go to a rallypoint and not sit near the construction site? Like all modern RTS games, BoS now implements rallypoints. Rallypoints can be set anywhere on the map, so they can be used for gathering a constructed force, or making sure a stream of reinforcements keeps reaching a fight.

Video
Here's a silent movie showing these two features put together. This is nothing revolutionary, but it did take 7 hours to properly code (the rallypoint part took less than 10 minutes, the loop part took longer because of some bugs I just discovered by writing it).


Yay.

Optimizations
Time Dilation, in physics, is a phenomenon where time slows down in high gravity/when you move near the speed of light. On Earth, the best way to simulate this phenomenon is to play Supreme Commander on a 81x81km map with 8 players and a unit cap of 1000. When you watch the counter tick up by one second every 30 seconds, you know that the game has a performance issue.

This isn't the programmer's fault, RTS games have the honor of managing thousands more objects than any other game genre (excepting something like an MMO, but that's a bit different). Unfortunately, no everyday consumer has a CPU with more than a 5GHz clock speed, so this presents an issue.

In BoS, more objects have to be tracked than any other RTS I've seen. There are between 6 and 14 planets, 2000 units per player (1000 ships, 1000 structures), 5000 bullets, 10000 asteroids, and all the looping and subprocedures needed to make them play together.

Even without 3D graphics my PC has to do a lot of work, especially looping. Therefore, I've begun implementing some optimization techniques:

  • Loop Fusion - Merging my FOR loops together in order to save execution time.
  • Removal of local loop control variables - Tricky, but doable, this technique means that a new integer does not need to be created and disposed every time a loop is started.
  • Loop Unrolling - Expanding a loop to affect multiple objects at the same time.

Cruisers
I have added a cruiser factory and a test cruiser called the "Guardian". The cruiser factory takes about twice the energy and 4x the time to construct as a frigate factory, and the average cruiser will take about 10x the time to construct as a frigate. Cruisers also, of course, need more people to man them than a cruiser.


Comments
Have a comment or suggestion? Mail me at masternerdguy@yahoo.com, or using the ModDB message system.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.