Merge branch 'Characteristics' of git://github.com/STK-helper/stk-code into dev
This commit is contained in:
commit
f1b97cdd44
@ -66,7 +66,7 @@
|
||||
speed 10 the radius is 7.5 etc.
|
||||
The actual turn radius is piece-wise linearly interpolated. This
|
||||
allows for tighter turning at lower speeds, and also avoids that
|
||||
the kart becomes too hard to control at high speed (speeds of
|
||||
the kart becomes too hard to control at high speed (speeds
|
||||
higher than 25 can only be reached with powerups).
|
||||
time-full-steer: This is the amount of change in steering depending
|
||||
on current steering. So if the steering is between 0 and 0.5,
|
||||
@ -84,7 +84,8 @@
|
||||
time-reset-steer="0.1" />
|
||||
|
||||
<!-- Speed and acceleration
|
||||
power: The power of the kart
|
||||
power: The power of the kart (the engine power needed to accelerate
|
||||
at a given pace is proportional to mass)
|
||||
max-speed: The base maximum speed of the kart in m/s
|
||||
brake-factor: Value used when braking.
|
||||
brake-time-increase: The brake force is multiplied by
|
||||
@ -93,18 +94,19 @@
|
||||
max-speed-reverse-ratio is the percentage of max speed for reverse
|
||||
gear.
|
||||
-->
|
||||
<engine power="875" max-speed="25" brake-factor="15"
|
||||
<engine power="950" max-speed="25" brake-factor="15"
|
||||
brake-time-increase="6" max-speed-reverse-ratio="0.65" />
|
||||
|
||||
<!-- Simulated gears
|
||||
switch-ratio defines at what ratio of the maximum
|
||||
speed what gear is selected, e.g. 0.25 means that if the speed is
|
||||
bigger or equal to 0.25 * maxSpeed then use gear 1, 0.5 means if
|
||||
the speed is bigger or equal to 0.5 x maxSpeed then gear 2.
|
||||
inferior or equal to 0.25 * maxSpeed then use gear 1, 0.5 means if
|
||||
the speed is inferior or equal to 0.5 x maxSpeed then gear 2.
|
||||
gear-power-increase contains the increase in max power (to simulate
|
||||
different gears), e.g. 2.5 as first entry means: 2.5 * maxPower in gear 1
|
||||
| first | second | third | . -->
|
||||
<gear switch-ratio="0.25 0.7 1.0" power-increase="2.2 1.7 1.3" />
|
||||
<gear switch-ratio="0.2 0.45 0.7 1 1.25"
|
||||
power-increase="2.5 2.1 1.7 1.4 1.2" />
|
||||
|
||||
<!-- Mass of a kart -->
|
||||
<mass value="350" />
|
||||
@ -205,9 +207,9 @@
|
||||
<anvil duration="2.0" weight="150" speed-factor="0.2" />
|
||||
|
||||
<!-- Parachute
|
||||
friction: The friction increase when a parachute is attached.
|
||||
friction: The friction factor when a parachute is attached.
|
||||
duration: The time an attached parachute is active
|
||||
duration-other: The time a parachute attached from other kart works
|
||||
duration-other: Used when the parachute results from item use
|
||||
duration-rank-mult: The multiplier applied to the duration of the
|
||||
parachute on the 1st kart when affected by the item. Scale for
|
||||
intermediary ranks to 1.0 for the last affected.
|
||||
@ -220,9 +222,9 @@
|
||||
detach parachute. E.g. at max-speed 50% of speed must be lost.
|
||||
max-speed: A factor that decides the impact of rate of speed
|
||||
(distance between bounds) -->
|
||||
<parachute friction="2.0" duration="2.0" duration-other="2.6"
|
||||
duration-rank-mult="1.35" duration-speed-mult="2.0"
|
||||
lbound-fraction="0.8" ubound-fraction="0.5" max-speed="23" />
|
||||
<parachute friction="5.0" duration="3" duration-other="2.5"
|
||||
duration-rank-mult="1.5" duration-speed-mult="1.35"
|
||||
lbound-fraction="0.5" ubound-fraction="0.3" max-speed="30" />
|
||||
<!-- Bubblegum
|
||||
duration: How long the bubblegum lasts.
|
||||
speed-fraction: To what fraction of top-speed the speed is reduced.
|
||||
@ -273,7 +275,7 @@
|
||||
fields must have the same size, and must be sorted by
|
||||
increasing times. -->
|
||||
<startup time="0.3 0.5"
|
||||
boost="6 3" />
|
||||
boost="8 4" />
|
||||
|
||||
<!-- Rescue
|
||||
duration: How long it takes the kart to be raised.
|
||||
@ -292,11 +294,12 @@
|
||||
after being hit by an explosion.
|
||||
radius: Kart closer to this value will be affected by
|
||||
an explosion as well. -->
|
||||
<explosion duration="2" radius="5"
|
||||
invulnerability-time="6" />
|
||||
<explosion duration="2" radius="6"
|
||||
invulnerability-time="7" />
|
||||
|
||||
<!-- Nitro
|
||||
engine-force: additional engine power
|
||||
engine-mult: multiply the total engine power by this
|
||||
consumption: nitro consumption - heavier characters can be set
|
||||
to need more nitro than lighter character.
|
||||
small-container: how much energy a small container gives.
|
||||
@ -308,8 +311,9 @@
|
||||
fade-out-time: Duration during which the increased maximum
|
||||
speed due to nitro fades out.
|
||||
max: How much nitro a kart can store. -->
|
||||
<nitro engine-force="600" consumption="1" small-container="1" big-container="3"
|
||||
max-speed-increase="5" duration="1" fade-out-time="2" max="20" />
|
||||
<nitro engine-force="300" engine-mult="1.2" consumption="1"
|
||||
small-container="1" big-container="3"
|
||||
max-speed-increase="5" duration="1" fade-out-time="2.4" max="20" />
|
||||
|
||||
<!-- Slipstream
|
||||
base-speed: the speed for which length and width are valid.
|
||||
@ -331,22 +335,22 @@
|
||||
fade-out-time: How long the slip stream speed increase will
|
||||
gradually be reduced. -->
|
||||
<slipstream base-speed="20" length="8" width="4" inner-factor="0.5"
|
||||
min-collect-time="3" max-collect-time="8" add-power="300" min-speed="8"
|
||||
max-speed-increase="5" duration-factor="1" fade-out-time="2" />
|
||||
min-collect-time="2.5" max-collect-time="8" add-power="300" min-speed="8"
|
||||
max-speed-increase="3" duration-factor="1" fade-out-time="2" />
|
||||
</characteristic>
|
||||
|
||||
<!-- The different difficulties (like easy, medium, hard) -->
|
||||
<difficulties>
|
||||
<characteristic name="easy">
|
||||
<engine power="*0.66" max-speed="*0.6" />
|
||||
<engine power="*0.7" max-speed="*0.6" />
|
||||
<plunger in-face-time="3" />
|
||||
</characteristic>
|
||||
<characteristic name="medium">
|
||||
<engine power="*0.77" max-speed="*0.8" />
|
||||
<engine power="*0.83" max-speed="*0.8" />
|
||||
<plunger in-face-time="4" />
|
||||
</characteristic>
|
||||
<characteristic name="hard">
|
||||
<engine power="*0.89" max-speed="*0.92" />
|
||||
<engine power="*0.92" max-speed="*0.92" />
|
||||
</characteristic>
|
||||
<!-- This doesn't need to be changed because the most fast/heavy/extreme
|
||||
values should also be the default ones. -->
|
||||
@ -356,44 +360,40 @@
|
||||
<!-- The different kart types, that can be specified in the kart.xml file -->
|
||||
<kart-types>
|
||||
<characteristic name="light">
|
||||
<engine power="*0.46" max-speed="*0.92" brake-factor="*1"
|
||||
max-speed-reverse-ratio="*0.77" />
|
||||
<gear switch-ratio="0.20 0.55 1" power-increase="5 4 3" />
|
||||
<mass value="*0.56" />
|
||||
<startup time="0.3 0.5"
|
||||
boost="8.5 4.5" />
|
||||
<explosion time="2.1" radius="5.5"
|
||||
invulnerability-time="7" />
|
||||
<nitro engine-force="350" max-speed-increase="4.5" duration="1.5"
|
||||
fade-out-time="2.5" />
|
||||
<turn radius="0:2.0 10:7.5 25:15 45:30" />
|
||||
<engine power="*0.8" max-speed="*0.95" brake-factor="*1"
|
||||
max-speed-reverse-ratio="*0.8" />
|
||||
<gear switch-ratio="0.1 0.25 0.45 0.7 1.0 4.0"
|
||||
power-increase="2.8 2.3 1.9 1.5 1.25 1.0" />
|
||||
<mass value="*0.6" />
|
||||
<startup boost="*1 *1" />
|
||||
<explosion time="*1" radius="*1" />
|
||||
<nitro engine-force="*0.6" max-speed-increase="*0.9" duration="*1" />
|
||||
<slipstream length="*0.9" collect-time="*0.9"
|
||||
duration-factor="*1" fade-out-time="*1" />
|
||||
</characteristic>
|
||||
<characteristic name="medium">
|
||||
<engine power="*0.63" max-speed="*1" brake-factor="*0.73"
|
||||
max-speed-reverse-ratio="*0.62" />
|
||||
<gear switch-ratio="0.30 0.7 1.0" power-increase="2.2 2.2 2.5" />
|
||||
<mass value="*0.71" />
|
||||
<startup time="0.3 0.5"
|
||||
boost="4.2 2.6" />
|
||||
<explosion time="1.8" radius="5"
|
||||
invulnerability-time="6" />
|
||||
<nitro engine-force="425" consumption="1.4" duration="1" />
|
||||
<turn radius="0:2.3 10:8.625 25:17.25 45:34.5" />
|
||||
<engine power="*0.875" max-speed="*1" brake-factor="*0.8"
|
||||
max-speed-reverse-ratio="*0.75" />
|
||||
<gear switch-ratio="0.1 0.25 0.45 0.7 1 4"
|
||||
power-increase="2.4 2 1.7 1.4 1.2 1" />
|
||||
<mass value="*0.75" />
|
||||
<startup boost="*0.8 *0.8" />
|
||||
<explosion time="*0.8" radius="*0.8" />
|
||||
<nitro engine-force="*0.75" consumption="*1.25" />
|
||||
<slipstream duration-factor="*0.8" fade-out-time="*1" />
|
||||
</characteristic>
|
||||
<characteristic name="heavy">
|
||||
<engine power="*1" max-speed="*1" brake-factor="*0.66"
|
||||
max-speed-reverse-ratio="*1" />
|
||||
<gear switch-ratio="0.45 0.70 1" power-increase="1.5 1.7 2.5" />
|
||||
<turn radius="0:2.6 10:9.75 25:19.5 45:39" />
|
||||
<engine power="*1" max-speed="*1.05" brake-factor="*0.6"
|
||||
max-speed-reverse-ratio="*0.7" />
|
||||
<gear switch-ratio="0.1 0.25 0.45 0.7 1 4"
|
||||
power-increase="2 1.7 1.5 1.3 1.15 1" />
|
||||
<mass value="*1" />
|
||||
<swatter duration="10" distance="3" squash-duration="5"
|
||||
squash-slowdown="0.5" />
|
||||
<startup time="0.3 0.5"
|
||||
boost="3.8 2" />
|
||||
<explosion time="1.5" radius="4"
|
||||
invulnerability-time="6" />
|
||||
<nitro engine-force="600" consumption="2" max-speed-increase="8"
|
||||
duration="0.7" fade-out-time="1.3" />
|
||||
<startup boost="*0.6 *0.6" />
|
||||
<explosion time="*0.6" radius="*0.6" />
|
||||
<nitro engine-force="*1" consumption="*1.67" max-speed-increase="*1.1" />
|
||||
<slipstream length="*1.1" collect-time="*1.1"
|
||||
duration-factor="*0.6" fade-out-time="*1" />
|
||||
</characteristic>
|
||||
|
@ -201,6 +201,8 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
|
||||
return TYPE_FLOAT;
|
||||
case NITRO_ENGINE_FORCE:
|
||||
return TYPE_FLOAT;
|
||||
case NITRO_ENGINE_MULT:
|
||||
return TYPE_FLOAT;
|
||||
case NITRO_CONSUMPTION:
|
||||
return TYPE_FLOAT;
|
||||
case NITRO_SMALL_CONTAINER:
|
||||
@ -437,6 +439,8 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
|
||||
return "NITRO_DURATION";
|
||||
case NITRO_ENGINE_FORCE:
|
||||
return "NITRO_ENGINE_FORCE";
|
||||
case NITRO_ENGINE_MULT:
|
||||
return "NITRO_ENGINE_MULT";
|
||||
case NITRO_CONSUMPTION:
|
||||
return "NITRO_CONSUMPTION";
|
||||
case NITRO_SMALL_CONTAINER:
|
||||
@ -1395,6 +1399,18 @@ float AbstractCharacteristic::getNitroEngineForce() const
|
||||
return result;
|
||||
} // getNitroEngineForce
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getNitroEngineMult() const
|
||||
{
|
||||
float result;
|
||||
bool is_set = false;
|
||||
process(NITRO_ENGINE_MULT, &result, &is_set);
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(NITRO_ENGINE_MULT).c_str());
|
||||
return result;
|
||||
} // getNitroEngineMult
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getNitroConsumption() const
|
||||
{
|
||||
|
@ -185,6 +185,7 @@ public:
|
||||
// Nitro
|
||||
NITRO_DURATION,
|
||||
NITRO_ENGINE_FORCE,
|
||||
NITRO_ENGINE_MULT,
|
||||
NITRO_CONSUMPTION,
|
||||
NITRO_SMALL_CONTAINER,
|
||||
NITRO_BIG_CONTAINER,
|
||||
@ -354,6 +355,7 @@ public:
|
||||
|
||||
float getNitroDuration() const;
|
||||
float getNitroEngineForce() const;
|
||||
float getNitroEngineMult() const;
|
||||
float getNitroConsumption() const;
|
||||
float getNitroSmallContainer() const;
|
||||
float getNitroBigContainer() const;
|
||||
|
@ -2651,6 +2651,54 @@ void Kart::updateEngineSFX(float dt)
|
||||
}
|
||||
} // updateEngineSFX
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Reduces the engine power according to speed
|
||||
*
|
||||
* TODO : find where the physics already apply a linear force decrease
|
||||
* TODO : While this work fine, it should ideally be in physics
|
||||
* However, the function use some kart properties and parachute
|
||||
* effect needs to be applied, so keep both working if moving
|
||||
* \param engine_power : the engine power on which to apply the decrease
|
||||
*/
|
||||
float Kart::applyAirFriction(float engine_power)
|
||||
{
|
||||
//The physics already do that a certain amount of engine force is needed to keep going
|
||||
//at a given speed (~39,33 engine force = 1 speed for a mass of 350)
|
||||
//But it's either too slow to accelerate to a target speed or makes it
|
||||
//too easy to accelerate farther.
|
||||
//Instead of making increasing gears have enormous power gaps, apply friction
|
||||
|
||||
float mass_factor = m_kart_properties->getMass()/350.0f;
|
||||
float compense_linear_slowdown = 39.33f*getSpeed()*mass_factor;
|
||||
|
||||
engine_power += compense_linear_slowdown;
|
||||
|
||||
// The result will always be a positive number
|
||||
float friction_intensity = fabsf(getSpeed());
|
||||
|
||||
// Not a pure quadratic evolution as it would be too brutal
|
||||
friction_intensity *= sqrt(friction_intensity)*5;
|
||||
|
||||
// Apply parachute physics
|
||||
// Currently, all karts have the same base friction
|
||||
// If this is changed, a compensation needs to be added here
|
||||
if(m_attachment->getType()==Attachment::ATTACH_PARACHUTE)
|
||||
friction_intensity *= m_kart_properties->getParachuteFriction();
|
||||
|
||||
if (friction_intensity < 0.0f) friction_intensity = 0.0f;
|
||||
|
||||
// We substract the friction from the engine power
|
||||
// 1)This is the logical behavior
|
||||
// 2)That way, engine boosts remain useful at high speed
|
||||
// 3)It helps heavier karts, who have an higher engine power
|
||||
|
||||
engine_power-=friction_intensity;
|
||||
|
||||
return engine_power;
|
||||
} //applyAirFriction
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the engine power. It considers the engine specs, items that influence
|
||||
* the available power, and braking/steering.
|
||||
@ -2661,9 +2709,11 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
updateNitro(ticks);
|
||||
float engine_power = getActualWheelForce();
|
||||
|
||||
// apply parachute physics if relevant
|
||||
if(m_attachment->getType()==Attachment::ATTACH_PARACHUTE)
|
||||
engine_power*=0.2f;
|
||||
// apply nitro boost if relevant
|
||||
if(getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_NITRO) > 0)
|
||||
{
|
||||
engine_power*= m_kart_properties->getNitroEngineMult();
|
||||
}
|
||||
|
||||
// apply bubblegum physics if relevant
|
||||
if (m_bubblegum_ticks > 0)
|
||||
@ -2689,6 +2739,9 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
m_kart_properties->getSkidVisualTime() == 0)
|
||||
engine_power *= 0.5f;
|
||||
|
||||
// This also applies parachute physics if relevant
|
||||
engine_power = applyAirFriction(engine_power);
|
||||
|
||||
applyEngineForce(engine_power*m_controls.getAccel());
|
||||
|
||||
// Either all or no brake is set, so test only one to avoid
|
||||
@ -2698,14 +2751,20 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
m_vehicle->setAllBrakes(0);
|
||||
m_brake_ticks = 0;
|
||||
}
|
||||
else
|
||||
{ // not accelerating
|
||||
else // not accelerating
|
||||
{
|
||||
//The engine power is still guaranteed >= 0 at this point
|
||||
float braking_power = engine_power;
|
||||
|
||||
// This also applies parachute physics if relevant
|
||||
engine_power = applyAirFriction(engine_power);
|
||||
|
||||
if(m_controls.getBrake())
|
||||
{ // check if the player is currently only slowing down
|
||||
// or moving backwards
|
||||
if(m_speed > 0.0f)
|
||||
{ // Still going forward while braking
|
||||
applyEngineForce(-engine_power*2.5f);
|
||||
applyEngineForce(engine_power-braking_power*3);
|
||||
m_brake_ticks += ticks;
|
||||
// Apply the brakes - include the time dependent brake increase
|
||||
float f = 1.0f + stk_config->ticks2Time(m_brake_ticks)
|
||||
@ -2723,7 +2782,7 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
// The backwards acceleration is artificially increased to
|
||||
// allow players to get "unstuck" quicker if they hit e.g.
|
||||
// a wall.
|
||||
applyEngineForce(-engine_power*2.5f);
|
||||
applyEngineForce(engine_power-braking_power*3);
|
||||
}
|
||||
else // -m_speed >= max speed on this terrain
|
||||
{
|
||||
@ -2732,13 +2791,13 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
|
||||
} // m_speed <00
|
||||
}
|
||||
else // !m_brake
|
||||
else // no braking and no acceleration
|
||||
{
|
||||
m_brake_ticks = 0;
|
||||
// lift the foot from throttle, brakes with 10% engine_power
|
||||
// lift the foot from throttle, let friction slow it down
|
||||
assert(!std::isnan(m_controls.getAccel()));
|
||||
assert(!std::isnan(engine_power));
|
||||
applyEngineForce(-m_controls.getAccel()*engine_power*0.1f);
|
||||
applyEngineForce(engine_power-braking_power);
|
||||
|
||||
// If not giving power (forward or reverse gear), and speed is low
|
||||
// we are "parking" the kart, so in battle mode we can ambush people
|
||||
@ -2746,7 +2805,7 @@ void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
m_vehicle->setAllBrakes(20.0f);
|
||||
else
|
||||
m_vehicle->setAllBrakes(0);
|
||||
} // !m_brake
|
||||
} // no braking and no acceleration
|
||||
} // not accelerating
|
||||
} // updateEnginePowerAndBrakes
|
||||
|
||||
|
@ -264,6 +264,7 @@ protected:
|
||||
void updateEngineSFX(float dt);
|
||||
void updateSpeed();
|
||||
void updateNitro(int ticks);
|
||||
float applyAirFriction (float engine_power);
|
||||
float getActualWheelForce();
|
||||
void playCrashSFX(const Material* m, AbstractKart *k);
|
||||
void loadData(RaceManager::KartType type, bool animatedModel);
|
||||
|
@ -1017,6 +1017,12 @@ float KartProperties::getNitroEngineForce() const
|
||||
return m_cached_characteristic->getNitroEngineForce();
|
||||
} // getNitroEngineForce
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getNitroEngineMult() const
|
||||
{
|
||||
return m_cached_characteristic->getNitroEngineMult();
|
||||
} // getNitroEngineMult
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getNitroConsumption() const
|
||||
{
|
||||
|
@ -469,6 +469,7 @@ public:
|
||||
|
||||
float getNitroDuration() const;
|
||||
float getNitroEngineForce() const;
|
||||
float getNitroEngineMult() const;
|
||||
float getNitroConsumption() const;
|
||||
float getNitroSmallContainer() const;
|
||||
float getNitroBigContainer() const;
|
||||
|
@ -545,7 +545,7 @@ void Skidding::update(int ticks, bool is_on_ground,
|
||||
MaxSpeed::MS_INCREASE_RED_SKIDDING;
|
||||
m_kart->m_max_speed->
|
||||
instantSpeedIncrease(bonus_cat,
|
||||
bonus_speed, bonus_speed,
|
||||
bonus_speed, bonus_speed/2,
|
||||
bonus_force,
|
||||
stk_config->time2Ticks(bonus_time),
|
||||
/*fade-out-time*/ stk_config->time2Ticks(1.0f));
|
||||
|
@ -545,6 +545,8 @@ void XmlCharacteristic::load(const XMLNode *node)
|
||||
&m_values[NITRO_DURATION]);
|
||||
sub_node->get("engine-force",
|
||||
&m_values[NITRO_ENGINE_FORCE]);
|
||||
sub_node->get("engine-mult",
|
||||
&m_values[NITRO_ENGINE_MULT]);
|
||||
sub_node->get("consumption",
|
||||
&m_values[NITRO_CONSUMPTION]);
|
||||
sub_node->get("small-container",
|
||||
|
Loading…
x
Reference in New Issue
Block a user