Page 1 of 1

Add tag "Power" to unit definitions

Posted: 03 Dec 2006, 03:10
by PauloMorfeo
We have in class CUnit:

Code: Select all

	float power;						//indicate the relative power of the unit, used for experience calulations etc
And in:
void 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;
	}
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):
How about something like this? (it compiles ;-) )

Code: 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);
P.S. I haven't actually checked if the max() safety is required

Posted: 03 Dec 2006, 16:44
by renrutal
Sometimes I think the devs should just find a way to add support to user made variables.

Posted: 03 Dec 2006, 18:51
by SwiftSpear
renrutal wrote:Sometimes I think the devs should just find a way to add support to user made variables.
It's called the OSRTS project.

Posted: 03 Dec 2006, 19:04
by hrmph
SwiftSpear wrote:It's called the OSRTS project.
I wish they would choose that name as the permanent one! Sounds a lot better than command IMO. ;) (/offtopic)