Let me tell you about my trials and tribulations. I decide to switch back to Windows Vista for some games I haven't played in a while (that and the newest EVE release is not so how with wine, framerate issues). So, I start my game and.....
Cannot find any units....I had accidentally deleted the units folder! So, I recreated the units...Mysteriously I cannot build any units. I had to fix that, the windows file system (The : in C:\) was throwing off my code. Next, I had to fix the fact that a \ is a "literal" and had to find a way to replace every \ with a /.
Anyhow, I then was able to make some real progress.
It's here folks: Unit Rotation! Now when you give them a destination, they rotate to face it and then thrust for it. This provides a delay, for example in combat, when units cannot immediately escape. Also, it just looks awesome.
This was not easy to implement. I used a formula to calculate a theta (the angle change) between the NPC and its destination, it goes something like this:
That formula has a minor drawback. Extremely long horizontal paths negate it, giving angles greater than 360 degrees. So, I simply made it so if a relatively horizontal path was detected it rotated totally horizontal. Solved.
One funny thing was that to get it to rotate, I had to totally rewrite a lot of my graphics rendering and creation code, but it was worth it.
Ever wanted to select all units of a type? In most RTS games, this task comes up frequently. So, I have implemented a group select using Ctrl-Click. It's very straight forward. It allows you to give orders to all the units of a certain type.
With rotation and group select implemented, the path has been paved to creating fitting code. The reason these were needed is that you don't want to manually fit every frigate, you want to be able to fit all of a certain type as well.
Questions? Comments? Feel free to contact me via ModDB.com or via firstname.lastname@example.org .