RTS game tools experiements.

are you running a list to give orders, and a set of bools and logic?

shoot=true
move forward =true
turn =-.2
etc?

or even states?

this way the ‘orders’ system can not hit every unit every frame?

The infantry will use a class based FSM system. Currently they have only one state though. :smiley:

The good thing about classes is you can set them up to run as frequently or as seldom as you like. I can update sprite animations every 4 tics, simple movement towards current target destination every tic and update navigation every 20 frames. When out of sight I can drop that to every 60 frames and stop updating animations.

EDIT:
I should explain a bit more…

Each infantry man has a very simple AI. In essence they have a target position which is offset from the formation object which they belong to and they will try to move to that position.

To start with they get a vector towards that point. If there are any obstacles nearby they will get a vector away from that object and these vectors are mixed together with the vector towards their final destination. So at all times they will move away from nearby obstacles and towards their goal. Finally the length of the vector is reduced to the speed at which they can move and compared with a camera vector to find out which of 8 facings from the sprite they should use (n,ne,e,se,s,sw,w,nw). If they find themselves far away from their destination and with movement vectors which are canceling each other out they will try to move towards their nearest friendly agent, hopefully getting unstuck from where ever they got trapped.


This is just the normal movement state. When they start shooting they will be in the shooting state, which will have different rules. In the shooting state they will find the nearest enemy formation and then the nearest enemy from that formation. They will try to eliminate them using their weapon. If they get killed they will enter the dead state and no longer move towards their goal.

The whole infantry code is very simple, that’s why it runs so fast.

Well, there’s a demo to try out…

swarm_sprites.zip (154 KB)

I’d like to know how well it runs, what’s your frame rate etc…
and also how does the control system feel?

left click on any individual infantry man to select the formation he’s a part of, then right click to move that formation to a point on the floor. In the game I’m influenced by selecting a formation would bring up the health bars for each member of the formation, but I want something more subtle than that. The formation arrows are going to be color coded for your faction, perhaps in the shape and design of a flag:


if I continue with the development, the infantry formations would use the same A* pathfinding as the tanks or other vehicles, so they wouldn’t move straight through obstacles as they do here.

Some other things that would be added:

Formation changes, spread out in to a slow moving skirmish line or bunch up to march at flank speed.

An orders bar, give orders to the formations using the UI, change formation, go prone or enter defensive formation, retreat, use grenades etc… maybe some special abilities for veteran units, such as quick firing or sharp shooting or quick march or hide or whatever.

Multiple selection, select multiple units with a bounding box.

Of course in teh full version there would be varying ground heights and camera controls and all that jazz…

p.s. feel free to use any code or any other stuff from the demo which seems useful.
There’s a nice bpy script for auto naming and separation of sprites there that might be of some use.

1 Like