Parachute improvements (#2768)

* Change grand-prix node for the new GP point system

* New GP point system

* Add parachute characteristics for rank and speed time multipliers

* Add new parachute characteristics

* typo fix

* Add rank and speed parachutes characteristics

* Add rank and speed parachute characteristics

* Add rank and speed parachute characteristics

* Add rank and speed parachute characteristics

* Add rank and speed parachute characteristics

* Add logic for parachute time scaling according to rank

* Add logic for parachute time scaling according to speed

* Separate GP and parachute branches

* Separate GP and parachute branches
This commit is contained in:
Alayan-stk-2 2017-02-06 00:54:32 +01:00 committed by auriamg
parent 5d30393641
commit 8858d4d86f
9 changed files with 100 additions and 10 deletions

View File

@ -202,16 +202,21 @@
friction: The friction increase 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-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.
duration-speed-mult: Applied in all cases, multitplier to duration
of the parachute at max-speed. Scale to 1.0 at 0 speed.
lbound-fraction: The lower bound fraction of speed when lost will
detach parachute. E.g. at nearly 0 speed, only 5% of speed
detach parachute. E.g. at nearly 0 speed, only 20% of speed
need to be lost.
ubound-fraction: The upper bound fraction of speed when lost will
detach parachute. E.g. at max-speed 30% of speed must be lost.
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="4.0" duration-other="8.0"
lbound-fraction="0.95" ubound-fraction="0.7" max-speed="23" />
<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" />
<!-- Bubblegum
duration: How long the bubblegum lasts.
speed-fraction: To what fraction of top-speed the speed is reduced.

View File

@ -171,10 +171,25 @@ void Attachment::set(AttachmentType type, float time,
// by slowing down.
if(m_type==ATTACH_PARACHUTE)
{
const KartProperties *kp = m_kart->getKartProperties();
float speed_mult;
m_initial_speed = m_kart->getSpeed();
// if going very slowly or backwards, braking won't remove parachute
if(m_initial_speed <= 1.5) m_initial_speed = 1.5;
float f = m_initial_speed / kp->getParachuteMaxSpeed();
float temp_mult = kp->getParachuteDurationSpeedMult();
// duration can't be reduced by higher speed
if (temp_mult < 1.0f) temp_mult = 1.0f;
if (f > 1.0f) f = 1.0f; // cap fraction
speed_mult = 1.0f + (f * (temp_mult - 1.0f));
m_time_left = m_time_left * speed_mult;
if (UserConfigParams::m_graphical_effects)
{
// .blend was created @25 (<10 real, slow computer), make it faster

View File

@ -368,9 +368,9 @@ void Powerup::use()
case PowerupManager::POWERUP_PARACHUTE:
{
AbstractKart* player_kart = NULL;
//Attach a parachutte(that last twice as long as the
//one from the bananas) to all the karts that
//are in front of this one.
//Attach a parachute(that last 1,3 time as long as the
//one from the bananas and is affected by the rank multiplier)
//to all the karts that are in front of this one.
for(unsigned int i = 0 ; i < world->getNumKarts(); ++i)
{
AbstractKart *kart=world->getKart(i);
@ -382,8 +382,24 @@ void Powerup::use()
}
if(m_kart->getPosition() > kart->getPosition())
{
float rank_mult, position_factor;
//0 if the one before the item user ; 1 if first ; scaled inbetween
if (kart->getPosition() == 1)
{
position_factor = 1.0f;
}
else //m_kart position is always >= 3
{
float rank_factor;
rank_factor = (float)(kart->getPosition() - 1) / (float)(m_kart->getPosition() - 2);
position_factor = 1.0f - rank_factor;
}
rank_mult = 1 + (position_factor * (kp->getParachuteDurationRankMult() - 1));
kart->getAttachment()->set(Attachment::ATTACH_PARACHUTE,
kp->getParachuteDurationOther());
(kp->getParachuteDurationOther() * rank_mult));
if(kart->getController()->isLocalPlayerController())
player_kart = kart;

View File

@ -126,6 +126,10 @@ AbstractCharacteristic::ValueType AbstractCharacteristic::getType(
return TYPE_FLOAT;
case PARACHUTE_DURATION_OTHER:
return TYPE_FLOAT;
case PARACHUTE_DURATION_RANK_MULT:
return TYPE_FLOAT;
case PARACHUTE_DURATION_SPEED_MULT:
return TYPE_FLOAT;
case PARACHUTE_LBOUND_FRACTION:
return TYPE_FLOAT;
case PARACHUTE_UBOUND_FRACTION:
@ -350,6 +354,10 @@ std::string AbstractCharacteristic::getName(CharacteristicType type)
return "PARACHUTE_DURATION";
case PARACHUTE_DURATION_OTHER:
return "PARACHUTE_DURATION_OTHER";
case PARACHUTE_DURATION_RANK_MULT:
return "PARACHUTE_DURATION_RANK_MULT";
case PARACHUTE_DURATION_SPEED_MULT:
return "PARACHUTE_DURATION_SPEED_MULT";
case PARACHUTE_LBOUND_FRACTION:
return "PARACHUTE_LBOUND_FRACTION";
case PARACHUTE_UBOUND_FRACTION:
@ -926,6 +934,30 @@ float AbstractCharacteristic::getParachuteDurationOther() const
return result;
} // getParachuteDurationOther
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getParachuteDurationRankMult() const
{
float result;
bool is_set = false;
process(PARACHUTE_DURATION_RANK_MULT, &result, &is_set);
if (!is_set)
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
getName(PARACHUTE_DURATION_RANK_MULT).c_str());
return result;
} // getParachuteDurationRankMult
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getParachuteDurationSpeedMult() const
{
float result;
bool is_set = false;
process(PARACHUTE_DURATION_SPEED_MULT, &result, &is_set);
if (!is_set)
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
getName(PARACHUTE_DURATION_SPEED_MULT).c_str());
return result;
} // getParachuteDurationSpeedMult
// ----------------------------------------------------------------------------
float AbstractCharacteristic::getParachuteLboundFraction() const
{

View File

@ -130,6 +130,8 @@ public:
PARACHUTE_FRICTION,
PARACHUTE_DURATION,
PARACHUTE_DURATION_OTHER,
PARACHUTE_DURATION_RANK_MULT,
PARACHUTE_DURATION_SPEED_MULT,
PARACHUTE_LBOUND_FRACTION,
PARACHUTE_UBOUND_FRACTION,
PARACHUTE_MAX_SPEED,
@ -300,6 +302,8 @@ public:
float getParachuteFriction() const;
float getParachuteDuration() const;
float getParachuteDurationOther() const;
float getParachuteDurationRankMult() const;
float getParachuteDurationSpeedMult() const;
float getParachuteLboundFraction() const;
float getParachuteUboundFraction() const;
float getParachuteMaxSpeed() const;

View File

@ -753,6 +753,18 @@ float KartProperties::getParachuteDurationOther() const
return m_cached_characteristic->getParachuteDurationOther();
} // getParachuteDurationOther
// ----------------------------------------------------------------------------
float KartProperties::getParachuteDurationRankMult() const
{
return m_cached_characteristic->getParachuteDurationRankMult();
} // getParachuteDurationRankMult
// ----------------------------------------------------------------------------
float KartProperties::getParachuteDurationSpeedMult() const
{
return m_cached_characteristic->getParachuteDurationSpeedMult();
} // getParachuteDurationSpeedMult
// ----------------------------------------------------------------------------
float KartProperties::getParachuteLboundFraction() const
{

View File

@ -467,6 +467,8 @@ public:
float getParachuteFriction() const;
float getParachuteDuration() const;
float getParachuteDurationOther() const;
float getParachuteDurationRankMult() const;
float getParachuteDurationSpeedMult() const;
float getParachuteLboundFraction() const;
float getParachuteUboundFraction() const;
float getParachuteMaxSpeed() const;

View File

@ -435,6 +435,10 @@ void XmlCharacteristic::load(const XMLNode *node)
&m_values[PARACHUTE_DURATION]);
sub_node->get("duration-other",
&m_values[PARACHUTE_DURATION_OTHER]);
sub_node->get("duration-rank-mult",
&m_values[PARACHUTE_DURATION_RANK_MULT]);
sub_node->get("duration-speed-mult",
&m_values[PARACHUTE_DURATION_SPEED_MULT]);
sub_node->get("lbound-fraction",
&m_values[PARACHUTE_LBOUND_FRACTION]);
sub_node->get("ubound-fraction",

View File

@ -38,7 +38,7 @@ Camera: distance, forwardUpAngle, backwardUpAngle
Jump: animationTime
Lean: max, speed
Anvil: duration, weight, speedFactor
Parachute: friction, duration, durationOther, lboundFraction, uboundFraction, maxSpeed
Parachute: friction, duration, durationOther, durationRankMult, durationSpeedMult, lboundFraction, uboundFraction, maxSpeed
Bubblegum: duration, speedFraction, torque, fadeInTime, shieldDuration
Zipper: duration, force, speedGain, maxSpeedIncrease, fadeOutTime
Swatter: duration, distance, squashDuration, squashSlowdown