Tweaked the logic of parachutes to be more modifiable. There now is an upper bound percentage and lower bound percentage which will be applied if you are driving faster and slower respectively. Also added those values in stk_config.xml to make playtesting easier (ticket #1135)

This commit is contained in:
Bart Cools 2014-02-27 22:17:30 +01:00
parent 14d6e6ae7e
commit 89a336ff9a
4 changed files with 57 additions and 43 deletions

View File

@ -94,8 +94,10 @@
<!-- friction is the friction increase when a parachute is attached.
time is the time an attached parachute is active
time-other is the time a parachute attached from other kart works
done-fraction is the fraction of speed when lost will detach parachute -->
<parachute friction="2.0" time="4.0" time-other="8.0" done-fraction="0.7"/>
lbound-fraction is the lower bound fraction of speed when lost will detach parachute
ubound-fraction is the upper bound fraction of speed when lost will detach parachute
max-speed is a factor that decides the impact of rate of speed (distance between bounds) -->
<parachute friction="2.0" time="4.0" time-other="8.0" lbound-fraction="0.5" ubound-fraction="0.95" max-speed="30"/>
<!-- time is the time till a bomb explodes. time-increase is the time added
to timer when bomb is passed on. -->

View File

@ -109,7 +109,9 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_max_karts, "<karts max=..." );
CHECK_NEG(m_parachute_friction, "parachute-friction" );
CHECK_NEG(m_parachute_done_fraction, "parachute-done-fraction" );
CHECK_NEG(m_parachute_lbound_fraction, "parachute-lbound-fraction" );
CHECK_NEG(m_parachute_ubound_fraction, "parachute-ubound-fraction" );
CHECK_NEG(m_parachute_max_speed, "parachute-max-speed" );
CHECK_NEG(m_parachute_time, "parachute-time" );
CHECK_NEG(m_parachute_time_other, "parachute-time-other" );
CHECK_NEG(m_bomb_time, "bomb-time" );
@ -151,14 +153,15 @@ void STKConfig::load(const std::string &filename)
void STKConfig::init_defaults()
{
m_anvil_weight = m_parachute_friction =
m_parachute_time = m_parachute_done_fraction =
m_parachute_time = m_parachute_lbound_fraction =
m_parachute_time_other = m_anvil_speed_factor =
m_bomb_time = m_bomb_time_increase =
m_anvil_time = m_music_credit_time =
m_delay_finish_time = m_skid_fadeout_time =
m_near_ground = m_item_switch_time =
m_smooth_angle_limit =
m_penalty_time = m_explosion_impulse_objects = UNDEFINED;
m_smooth_angle_limit = m_parachute_ubound_fraction =
m_penalty_time = m_explosion_impulse_objects =
m_parachute_max_speed = UNDEFINED;
m_bubblegum_counter = -100;
m_bubblegum_shield_time = -100;
m_shield_restrict_weapos = false;
@ -300,10 +303,12 @@ void STKConfig::getAllData(const XMLNode * root)
if(const XMLNode *parachute_node= root->getNode("parachute"))
{
parachute_node->get("friction", &m_parachute_friction );
parachute_node->get("time", &m_parachute_time );
parachute_node->get("time-other", &m_parachute_time_other );
parachute_node->get("done-fraction", &m_parachute_done_fraction);
parachute_node->get("friction", &m_parachute_friction );
parachute_node->get("time", &m_parachute_time );
parachute_node->get("time-other", &m_parachute_time_other );
parachute_node->get("lbound-fraction", &m_parachute_lbound_fraction);
parachute_node->get("ubound-fraction", &m_parachute_ubound_fraction);
parachute_node->get("max-speed", &m_parachute_max_speed );
}
if(const XMLNode *bomb_node= root->getNode("bomb"))

View File

@ -60,37 +60,40 @@ public:
m_same_powerup_mode;
static float UNDEFINED;
float m_anvil_weight; /**<Additional kart weight if anvil is
attached. */
float m_anvil_speed_factor; /**<Speed decrease when attached first. */
float m_parachute_friction; /**<Increased parachute air friction. */
float m_parachute_done_fraction; /**<Fraction of speed when lost will
detach parachute. */
float m_parachute_time; /**<Time a parachute is active. */
float m_parachute_time_other; /**<Time a parachute attached to other
karts is active. */
float m_bomb_time; /**<Time before a bomb explodes. */
float m_bomb_time_increase; /**<Time added to bomb timer when it's
passed on. */
float m_anvil_time; /**<Time an anvil is active. */
float m_item_switch_time; /**< Time items will be switched. */
int m_bubblegum_counter; /**< How many times bubble gums must be
driven over before they disappear. */
float m_bubblegum_shield_time; /**<How long a bubble gum shield lasts. */
bool m_shield_restrict_weapos; /**<Wether weapon usage is punished. */
float m_explosion_impulse_objects;/**<Impulse of explosion on moving
objects, e.g. road cones, ... */
float m_penalty_time; /**< Penalty time when starting too
early. */
float m_delay_finish_time; /**<Delay after a race finished before
the results are displayed. */
float m_music_credit_time; /**<Time the music credits are
displayed. */
int m_max_karts; /**<Maximum number of karts. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
bool m_smooth_normals; /**< If normals for raycasts for wheels
should be interpolated. */
float m_anvil_weight; /**<Additional kart weight if anvil is
attached. */
float m_anvil_speed_factor; /**<Speed decrease when attached first. */
float m_parachute_friction; /**<Increased parachute air friction. */
float m_parachute_ubound_fraction; /**<Upper bound fraction of speed when
lost will detach parachute. */
float m_parachute_lbound_fraction; /**<Lower bound fraction of speed when
lost will detach parachute. */
float m_parachute_max_speed; /**<Max speed to rate current speed */
float m_parachute_time; /**<Time a parachute is active. */
float m_parachute_time_other; /**<Time a parachute attached to other
karts is active. */
float m_bomb_time; /**<Time before a bomb explodes. */
float m_bomb_time_increase; /**<Time added to bomb timer when it's
passed on. */
float m_anvil_time; /**<Time an anvil is active. */
float m_item_switch_time; /**< Time items will be switched. */
int m_bubblegum_counter; /**< How many times bubble gums must be
driven over before they disappear. */
float m_bubblegum_shield_time; /**<How long a bubble gum shield lasts. */
bool m_shield_restrict_weapos; /**<Wether weapon usage is punished. */
float m_explosion_impulse_objects; /**<Impulse of explosion on moving
objects, e.g. road cones, ... */
float m_penalty_time; /**< Penalty time when starting too
early. */
float m_delay_finish_time; /**<Delay after a race finished before
the results are displayed. */
float m_music_credit_time; /**<Time the music credits are
displayed. */
int m_max_karts; /**<Maximum number of karts. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
bool m_smooth_normals; /**< If normals for raycasts for wheels
should be interpolated. */
/** If the angle between a normal on a vertex and the normal of the
* triangle are more than this value, the physics will use the normal
* of the triangle in smoothing normal. */

View File

@ -408,8 +408,12 @@ void Attachment::update(float dt)
// Partly handled in Kart::updatePhysics
// Otherwise: disable if a certain percantage of
// initial speed was lost
if(m_kart->getSpeed() <=
m_initial_speed*stk_config->m_parachute_done_fraction)
// This percentage is based on the ratio of
// initial_speed / initial_max_speed
if(m_kart->getSpeed() <= m_initial_speed * (stk_config->m_parachute_lbound_fraction +
((m_initial_speed / stk_config->m_parachute_max_speed) * (stk_config->m_parachute_ubound_fraction -
stk_config->m_parachute_lbound_fraction))))
{
m_time_left = -1;
}