Add tag "Power" to unit definitions
Posted: 03 Dec 2006, 03:10
We have in class CUnit:
And in:
void CUnitDefHandler::ParseTAUnit(std::string file, int id)
If "Power" is loaded from the unit definition, we could control ourselves how much each unit gives of XP to enemies or, for example, remove completely experience by making all units have really low "Power" (0.001 or something?).
Should be easy to do and very similar to the adition of mass to features (wouldn't also change anything in the inner works of Spring):
Code: Select all
float power; //indicate the relative power of the unit, used for experience calulations etcvoid CUnitDefHandler::ParseTAUnit(std::string file, int id)
Code: Select all
ud.power = (ud.metalCost + ud.energyCost/60.0f);
if(ud.power<1e-3f){
...
ud.power=1e-3f;
}Should be easy to do and very similar to the adition of mass to features (wouldn't also change anything in the inner works of Spring):
How about something like this? (it compiles)
P.S. I haven't actually checked if the max() safety is requiredCode: Select all
const string massStr = wreckParser.SGetValueDef("", name + "\\Mass"); if (massStr.empty()) { // generate the mass from the metal and health values fd->mass = (fd->metal * 0.4f) + (fd->maxHealth * 0.1f); } else { fd->mass = (float)atof(massStr.c_str()); } fd->mass = max(0.001f, fd->mass);