How to organize unit variables?
Never made any RTS, but I think it'd be a good idea to make use of HashTable object / Ini object to store some game configuration data like:
- game speed
- gamma correction
(name: "AppConfiguration")
Another HashTable object / Ini object to store units constant configuration:
- unit starting HP (when new object created, set its HP to this value)
- unit cost
- unit speed (when new object created, adjust its maximal speed and stuff to this value)
- unit armor class
- unit damage
(name: "GameConstant")
Another one for storing varying game data like upgrades.
(name: "GameState")
And provide every unit with set of Private Variables that are unique for every instance:
- unit HP
- unit Order Type (move/attack/gather/stop/hold)
- unit Referenced Object (like pointer to enemy object for attacking or resources object for gathering etc.)
- unit Destination Position (if not ordering to go into another unit but on "clean" location)
Saving/loading game is quite easy because all object's transferring private variables should be done automatically (haven't tested yet).
If you're familiar with programming, then it's quite simple to imagine that you can handle game logic with "foreach object" easily and access objects through their Unique ID like substitute for references.