Spotted a discussion on the GameCore forums regarding a turn-based game, and mentioned that the simple RTS experiment that I’ve been working on would be somewhat of a starting point for developing this.
So here it is in all of it’s glory:
As far as I know, this template will work with the Default Script library that shipped with 2.0.5, but I may have added a few things. If someone can do some testnig of this and let me know — worst case I can post an updated version of the script library.
Supported Features:
rts-style camera system
well, realistically it’s more of a world-in-conflict style camera system but it’s much better than most rts cameras). To move around the world, either move the mouse to the edge of the screen or simply use the wsad / arrow keys. To rotate the camera, use the middle-mouse button.
multiple unit / selection box
this is also a demonstration of how to use the recently exposed Sprite system that gamecore provides in 2.0.5. You can do things like selection boxes, info boxes above a unit’s head (health / name etc) and so on. Click / drag to select multiple units, right click to get them to move to a destination.
unit grouping / quick select keys
You can group units into quick select groups by selecting them (via the drag-selection as mentioned above) and then pressing shift-number key to assign them to the associated group.
So selecting multiple units and pressing shift-1 would add them to quick select group 1. to select that group in-game you can either press the ‘1’ key or press the associated button on the interface.
mockup ui elements / forms
I have two mockup ui elements implemented:
– unit group selection
– unit formation
both of which do what you might expect. the group selection is basically an on-screen button that does the same thing as pressing the 1–9 keys — and will select the units in that group.
the unit formation will set the specific formation for the unit to move in. this is sort of a simple hack at the moment, doesn’t really do what i want it to, but it sorta works. basically when you click on a destination for the units to move, the script checks to see if you have multiple units selected. if there is only a single unit selected, the unit attempts to move to the exact point that you specified. if you have multiple units selected, it will specify a random offset of the destination point and move the unit accordingly. this is so that a bunch of units don’t fight with each other to try and get to the specific destination (which can result in some funny after effects).
So, that’s about it — should be able to unzip it and open it ‘as is’.
The majority of the ‘fun stuff’ happens in the camera.gsl script located in ‘media/scripts/controllers’ — the other scripts used are the simple bad guy controller AI script that ships with gamecore and the network_character script.
Basically each ‘unit’ in the RTS is an AI controller. The AI controller provides the ‘brain’ for the unit, and checks to see if there are bad guys nearby, etc. The character controller is the low-level move / animation controller and handles all of the low-level details like choosing which animation to play, etc.
By segregating each of the components like this it keeps the individual scripts nice and clean and more importantly, understandable.
The camera.gsl script does everything else — unit selection, grouping, formations etc.
Your mileage may vary, but hopefully this is useful to someone ;}
Related posts:
Quick comments
1) the unit’s don’t have weapons at the moment, so they won’t actually ‘kill’ the bad guy in the world.
2) units should ideally be spawned based on the level, as opposed to being just placed in the world at the start.
3) if you want to edit the individual unit behavior (ie characters), you will want to open the UnitInventory.wld. If you want to edit the gameplay world (ie what actually does the rts stuff), you will want to work on the RTSTest.wld.