Page 1 of 1

Mass for features

Posted: 19 Nov 2006, 17:10
by PauloMorfeo
At the moment feature definitions have the mass hardcoded:
https://taspring.clan-sy.com/svn/spring ... andler.cpp

Code: Select all

FeatureDef* CFeatureHandler::GetFeatureDef(const std::string name)
{
    fd->mass=fd->metal*0.4f+fd->maxHealth*0.1f;
}
Make it:

Code: Select all

FeatureDef* CFeatureHandler::GetFeatureDef(const std::string name)
{
    float defaultMass= metal*0.4f+fd->maxHealth*0.1f;
    fd->mass= atof (wreckParser.SGetValueDef (defaultMass, name + "\\Mass").c_str ());
}
I don't know what "atof" is and the others get passed a string instead of a float (float defaultMass) so you better change that to .. whatever.
Basically, just make features also have mass defined by the TDFs.

Re: Mass for features

Posted: 19 Nov 2006, 17:30
by NOiZE
PauloMorfeo wrote:Basically, just make features also have mass defined by the TDFs.
+1

Re: Mass for features

Posted: 21 Nov 2006, 12:20
by zwzsg
Agreed. I'm actually surprised it's not already the case.

Posted: 21 Nov 2006, 13:23
by trepan
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: 21 Nov 2006, 19:10
by PauloMorfeo
Seems ok, even though i don't know, for example, what that max(); function does.

I would say to just mimic the way units load the tag "mass" to make it consistent but it would break the balances of already existing mods because features would end up having diferent values than before...

And thanks for adding it. Will be very helpfull to have it already in the next version.

Posted: 21 Nov 2006, 19:54
by rattle
It's like "fd->mass = (fd->mass<0.001f ? 0.001f : fd->mass);", only shorter. Rounds it up to 0.001 if it's smaller than that.

Posted: 21 Nov 2006, 21:29
by trepan
I've been told that 0.74b1 is going to use SVN rev 2684.
The changes for this feature are in r2688/r2689, just a
little too late ;-)

Posted: 22 Nov 2006, 03:11
by PauloMorfeo
:(
:( :( :(

iiik

Posted: 22 Nov 2006, 06:16
by LordMatt
It might get pushed back to a later rev, apparently...