1) Cleanup of unused data in stk_config/kart_properties

2) Removed 'magic' constant 0.0044 from steering
   computation; replaced by DEGREE_TO_RAD, which means
   that steering values in stk_config.data and .kart files 
   have to be divided by about 3.9
3) Added early cancellation of parachute when a slow down
   of 30% is reached (defined in stk_config.data). This allows
   karts to brake and get rid of the parachute earlier.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1641 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-03-06 13:32:51 +00:00
parent 29a8b1b338
commit fac59355c0
9 changed files with 55 additions and 66 deletions

View File

@ -17,11 +17,12 @@
(parachute-friction 2.0 ) ;; friction increase when a parachute is sttached (parachute-friction 2.0 ) ;; friction increase when a parachute is sttached
(parachute-time 4.0 ) ;; time an attached parachute is active (parachute-time 4.0 ) ;; time an attached parachute is active
(parachute-time-other 8.0 ) ;; time a parachute attached from other kart is active (parachute-time-other 8.0 ) ;; time a parachute attached from other kart is active
(parachute-done-fraction 0.7 ) ;; fraction of speed when lost will detach parachute
(bomb-time 30.0 ) ;; time till a bomb explodes (bomb-time 30.0 ) ;; time till a bomb explodes
(bomb-time-increase -5.0 ) ;; time added to timer when bomb is passed on (bomb-time-increase -5.0 ) ;; time added to timer when bomb is passed on
(anvil-time 2.0 ) ;; time an anvil is active (anvil-time 2.0 ) ;; time an anvil is active
(zipper-time 3.0 ) ;; time a zipper is active (zipper-time 3.0 ) ;; time a zipper is active
(zipper-force 800.0 ) ;; additional zipper force (zipper-force 800.0 ) ;; additional zipper force
(zipper-speed-gain 10.0 ) ;; one time additional speed boost given by zippers (zipper-speed-gain 10.0 ) ;; one time additional speed boost given by zippers
(shortcut-skipped-segments 5 ) ;; skipping more than this number of segments (shortcut-skipped-segments 5 ) ;; skipping more than this number of segments
;; is considered to be a shortcut ;; is considered to be a shortcut
@ -38,11 +39,6 @@
(kart-defaults (kart-defaults
(wheel-base 1.2 ) (wheel-base 1.2 )
(heightCOG 0.2 ) (heightCOG 0.2 )
(engine-power 400 )
(brake-factor 2.75)
(brake-force 2.5 )
(mass 125 )
(max-steer-angle 55 )
(time-full-steer 0.3 ) (time-full-steer 0.3 )
(corn-f 4 ) (corn-f 4 )
(corn-r 4 ) (corn-r 4 )
@ -61,9 +57,10 @@
(inertia 5.0 ) (inertia 5.0 )
;; Bullet physics attributes ;; Bullet physics attributes
(bullet-engine-power 400 ) (brake-factor 2.75 )
(bullet-mass 225 ) (max-steer-angle 6.4 )
(bullet-max-steer-angle 25 ) (engine-power 400 )
(mass 225 )
(suspension-stiffness 8.0 ) (suspension-stiffness 8.0 )
(wheel-damping-relaxation 2.3 ) (wheel-damping-relaxation 2.3 )
(wheel-damping-compression 4.4 ) (wheel-damping-compression 4.4 )

View File

@ -91,10 +91,11 @@ void Attachment::hitGreenHerring()
break; break;
default: random_attachment = rand()%3; default: random_attachment = rand()%3;
} // switch } // switch
switch (random_attachment) switch (random_attachment)
{ {
case 0: set( ATTACH_PARACHUTE, stk_config->m_parachute_time+leftover_time); case 0: set( ATTACH_PARACHUTE, stk_config->m_parachute_time+leftover_time);
m_initial_speed = m_kart->getSpeed();
// if ( m_kart == m_kart[0] ) // if ( m_kart == m_kart[0] )
// sound -> playSfx ( SOUND_SHOOMF ) ; // sound -> playSfx ( SOUND_SHOOMF ) ;
break ; break ;
@ -130,8 +131,16 @@ void Attachment::update(float dt)
switch (m_type) switch (m_type)
{ {
case ATTACH_PARACHUTE: // handled in Kart::updatePhysics case ATTACH_PARACHUTE: // Partly handled in Kart::updatePhysics
case ATTACH_ANVIL: // 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)
{
m_time_left = -1;
}
break;
case ATTACH_ANVIL: // handled in Kart::updatePhysics
case ATTACH_NOTHING: // Nothing to do, but complete all cases for switch case ATTACH_NOTHING: // Nothing to do, but complete all cases for switch
case ATTACH_MAX: break; case ATTACH_MAX: break;
case ATTACH_BOMB: if(m_time_left<=0.0) case ATTACH_BOMB: if(m_time_left<=0.0)

View File

@ -38,6 +38,7 @@ private:
attachmentType m_type; // attachment type attachmentType m_type; // attachment type
Kart *m_kart; // kart the attachment is attached to Kart *m_kart; // kart the attachment is attached to
float m_time_left; // time left till attachment expires float m_time_left; // time left till attachment expires
float m_initial_speed; // for parachutes only
ssgSelector *m_holder; // where the attachment is put on the kart ssgSelector *m_holder; // where the attachment is put on the kart
Kart *m_previous_owner; // used by bombs so that it's not passed Kart *m_previous_owner; // used by bombs so that it's not passed
// back to previous owner // back to previous owner

View File

@ -846,7 +846,7 @@ void Kart::updatePhysics (float dt)
getBody()->setLinearVelocity( velocity ); getBody()->setLinearVelocity( velocity );
} }
const float steering = getMaxSteerAngle() * m_controls.lr * 0.00444f; const float steering = DEGREE_TO_RAD(getMaxSteerAngle()) * m_controls.lr;
m_vehicle->setSteeringValue(steering, 0); m_vehicle->setSteeringValue(steering, 0);
m_vehicle->setSteeringValue(steering, 1); m_vehicle->setSteeringValue(steering, 1);
@ -1136,7 +1136,7 @@ void Kart::placeModel ()
sgMat4 wheel_rot; sgMat4 wheel_rot;
sgMakeRotMat4( wheel_rot, 0, RAD_TO_DEGREE(-m_wheel_rotation), 0); sgMakeRotMat4( wheel_rot, 0, RAD_TO_DEGREE(-m_wheel_rotation), 0);
sgMakeRotMat4( wheel_steer, getSteerAngle()/getMaxSteerAngle() * 30.0f , 0, 0); sgMakeRotMat4( wheel_steer, m_controls.lr * 30.0f , 0, 0);
sgMultMat4(wheel_front, wheel_steer, wheel_rot); sgMultMat4(wheel_front, wheel_steer, wheel_rot);

View File

@ -186,9 +186,6 @@ public:
float getHeightCOG () const {return m_kart_properties->getHeightCOG();} float getHeightCOG () const {return m_kart_properties->getHeightCOG();}
float getFrictionSlip () const {return m_kart_properties->getFrictionSlip();} float getFrictionSlip () const {return m_kart_properties->getFrictionSlip();}
float getMaxSteerAngle () const {return m_kart_properties->getMaxSteerAngle();} float getMaxSteerAngle () const {return m_kart_properties->getMaxSteerAngle();}
float getCornerStiffF () const {return m_kart_properties->getCornerStiffF();}
float getCornerStiffR () const {return m_kart_properties->getCornerStiffR();}
float getInertia () const {return m_kart_properties->getInertia(); }
float getGravityCenterShift () const float getGravityCenterShift () const
{return m_kart_properties->getGravityCenterShift(); } {return m_kart_properties->getGravityCenterShift(); }
float getWheelieMaxSpeedRatio () const float getWheelieMaxSpeedRatio () const

View File

@ -134,15 +134,11 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
lisp->get("wheel-base", m_wheel_base); lisp->get("wheel-base", m_wheel_base);
lisp->get("heightCOG", m_height_cog); lisp->get("heightCOG", m_height_cog);
lisp->get("bullet-engine-power", m_engine_power); lisp->get("engine-power", m_engine_power);
lisp->get("time-full-steer", m_time_full_steer); lisp->get("time-full-steer", m_time_full_steer);
lisp->get("brake-factor", m_brake_factor); lisp->get("brake-factor", m_brake_factor);
lisp->get("bullet-mass", m_mass); lisp->get("mass", m_mass);
lisp->get("tire-grip", m_tire_grip); lisp->get("max-steer-angle", m_max_steer_angle);
lisp->get("bullet-max-steer-angle", m_max_steer_angle);
lisp->get("corn-f", m_corn_f);
lisp->get("corn-r", m_corn_r);
lisp->get("inertia", m_inertia);
lisp->get("wheelie-max-speed-ratio", m_wheelie_max_speed_ratio ); lisp->get("wheelie-max-speed-ratio", m_wheelie_max_speed_ratio );
lisp->get("wheelie-max-pitch", m_wheelie_max_pitch ); lisp->get("wheelie-max-pitch", m_wheelie_max_pitch );
lisp->get("wheelie-pitch-rate", m_wheelie_pitch_rate ); lisp->get("wheelie-pitch-rate", m_wheelie_pitch_rate );
@ -198,11 +194,7 @@ void KartProperties::init_defaults()
m_time_full_steer = stk_config->m_time_full_steer; m_time_full_steer = stk_config->m_time_full_steer;
m_brake_factor = stk_config->m_brake_factor; m_brake_factor = stk_config->m_brake_factor;
m_mass = stk_config->m_mass; m_mass = stk_config->m_mass;
m_tire_grip = stk_config->m_tire_grip;
m_max_steer_angle = stk_config->m_max_steer_angle; m_max_steer_angle = stk_config->m_max_steer_angle;
m_corn_f = stk_config->m_corn_f;
m_corn_r = stk_config->m_corn_r;
m_inertia = stk_config->m_inertia;
m_wheelie_max_speed_ratio = stk_config->m_wheelie_max_speed_ratio; m_wheelie_max_speed_ratio = stk_config->m_wheelie_max_speed_ratio;
m_wheelie_max_pitch = stk_config->m_wheelie_max_pitch; m_wheelie_max_pitch = stk_config->m_wheelie_max_pitch;
m_wheelie_pitch_rate = stk_config->m_wheelie_pitch_rate; m_wheelie_pitch_rate = stk_config->m_wheelie_pitch_rate;

View File

@ -57,12 +57,8 @@ protected:
float m_height_cog; // height of center of gravity float m_height_cog; // height of center of gravity
float m_engine_power; // maximum force from engine float m_engine_power; // maximum force from engine
float m_brake_factor; // braking factor * engine_power = braking force float m_brake_factor; // braking factor * engine_power = braking force
float m_tire_grip; // grip of tires in longitudinal direction
float m_max_steer_angle; // maximum steering angle float m_max_steer_angle; // maximum steering angle
float m_time_full_steer; // time for player karts to reach full steer angle float m_time_full_steer; // time for player karts to reach full steer angle
float m_corn_f;
float m_corn_r;
float m_inertia;
float m_wheelie_max_speed_ratio; // percentage of maximum speed for wheelies float m_wheelie_max_speed_ratio; // percentage of maximum speed for wheelies
float m_wheelie_max_pitch; // maximum pitch for wheelies float m_wheelie_max_pitch; // maximum pitch for wheelies
float m_wheelie_pitch_rate; // rate/sec with which kart goes up float m_wheelie_pitch_rate; // rate/sec with which kart goes up
@ -122,9 +118,6 @@ public:
float getWheelBase () const {return m_wheel_base; } float getWheelBase () const {return m_wheel_base; }
float getHeightCOG () const {return m_height_cog; } float getHeightCOG () const {return m_height_cog; }
float getMaxSteerAngle () const {return m_max_steer_angle; } float getMaxSteerAngle () const {return m_max_steer_angle; }
float getCornerStiffF () const {return m_corn_f; }
float getCornerStiffR () const {return m_corn_r; }
float getInertia () const {return m_inertia; }
float getMaxSpeedReverseRatio() const {return m_max_speed_reverse_ratio;} float getMaxSpeedReverseRatio() const {return m_max_speed_reverse_ratio;}
float getWheelieMaxSpeedRatio() const {return m_wheelie_max_speed_ratio;} float getWheelieMaxSpeedRatio() const {return m_wheelie_max_speed_ratio;}
float getWheelieMaxPitch () const {return m_wheelie_max_pitch; } float getWheelieMaxPitch () const {return m_wheelie_max_pitch; }

View File

@ -59,11 +59,7 @@ void STKConfig::load(const std::string filename)
CHECK_NEG(m_max_karts, "max-karts" ); CHECK_NEG(m_max_karts, "max-karts" );
CHECK_NEG(m_grid_order, "grid-order" ); CHECK_NEG(m_grid_order, "grid-order" );
CHECK_NEG(m_corn_r, "m_corn_r" );
CHECK_NEG(m_corn_f, "m_corn_f" );
CHECK_NEG(m_mass, "mass" ); CHECK_NEG(m_mass, "mass" );
CHECK_NEG(m_inertia, "m_inertia" );
CHECK_NEG(m_height_cog, "heightCOG" ); CHECK_NEG(m_height_cog, "heightCOG" );
CHECK_NEG(m_wheel_base, "wheel-base" ); CHECK_NEG(m_wheel_base, "wheel-base" );
CHECK_NEG(m_engine_power, "engine-power" ); CHECK_NEG(m_engine_power, "engine-power" );
@ -81,8 +77,12 @@ void STKConfig::load(const std::string filename)
CHECK_NEG(m_wheelie_step, "wheelie-step" ); CHECK_NEG(m_wheelie_step, "wheelie-step" );
CHECK_NEG(m_wheelie_power_boost, "wheelie-power-boost" ); CHECK_NEG(m_wheelie_power_boost, "wheelie-power-boost" );
CHECK_NEG(m_parachute_friction, "parachute-friction" ); CHECK_NEG(m_parachute_friction, "parachute-friction" );
CHECK_NEG(m_time_full_steer, "time-full-steer" ); CHECK_NEG(m_parachute_done_fraction, "parachute-done-fraction" );
CHECK_NEG(m_parachute_time, "parachute-time" );
CHECK_NEG(m_parachute_time_other, "parachute-time-other" );
CHECK_NEG(m_time_full_steer, "time-full-steer" );
//bullet physics data //bullet physics data
CHECK_NEG(m_suspension_stiffness, "suspension-stiffness" ); CHECK_NEG(m_suspension_stiffness, "suspension-stiffness" );
@ -97,8 +97,6 @@ void STKConfig::load(const std::string filename)
CHECK_NEG(m_maximum_speed, "maximum-speed" ); CHECK_NEG(m_maximum_speed, "maximum-speed" );
CHECK_NEG(m_max_speed_reverse_ratio, "max-speed-reverse-ratio" ); CHECK_NEG(m_max_speed_reverse_ratio, "max-speed-reverse-ratio" );
CHECK_NEG(m_gravity_center_shift, "gravity-center-shift" ); CHECK_NEG(m_gravity_center_shift, "gravity-center-shift" );
CHECK_NEG(m_parachute_time, "parachute-time" );
CHECK_NEG(m_parachute_time_other, "parachute-time-other" );
CHECK_NEG(m_bomb_time, "bomb-time" ); CHECK_NEG(m_bomb_time, "bomb-time" );
CHECK_NEG(m_bomb_time_increase, "bomb-time-increase" ); CHECK_NEG(m_bomb_time_increase, "bomb-time-increase" );
CHECK_NEG(m_anvil_time, "anvil-time" ); CHECK_NEG(m_anvil_time, "anvil-time" );
@ -120,16 +118,16 @@ void STKConfig::load(const std::string filename)
*/ */
void STKConfig::init_defaults() void STKConfig::init_defaults()
{ {
m_wheel_base = m_height_cog = m_mass = m_wheel_base = m_height_cog = m_mass = m_max_steer_angle =
m_corn_r = m_max_steer_angle = m_anvil_weight = m_parachute_friction =
m_corn_f = m_inertia = m_anvil_weight = m_parachute_friction = m_parachute_time = m_parachute_done_fraction = m_parachute_time_other =
m_engine_power = m_jump_impulse = m_brake_factor = m_engine_power = m_jump_impulse = m_brake_factor =
m_anvil_speed_factor = m_time_full_steer = m_wheelie_max_pitch = m_anvil_speed_factor = m_time_full_steer = m_wheelie_max_pitch =
m_wheelie_max_speed_ratio = m_wheelie_pitch_rate = m_wheelie_restore_rate = m_wheelie_max_speed_ratio = m_wheelie_pitch_rate = m_wheelie_restore_rate =
m_wheelie_speed_boost = m_wheelie_speed_boost =
m_parachute_time = m_bomb_time = m_bomb_time_increase= m_anvil_time = m_bomb_time = m_bomb_time_increase= m_anvil_time =
m_zipper_time = m_zipper_force = m_zipper_speed_gain = m_zipper_time = m_zipper_force = m_zipper_speed_gain =
m_parachute_time_other = m_shortcut_segments = m_shortcut_segments =
//bullet physics data //bullet physics data
m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_damping_compression = m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_damping_compression =
m_friction_slip = m_roll_influence = m_wheel_radius = m_wheel_width = m_friction_slip = m_roll_influence = m_wheel_radius = m_wheel_width =
@ -150,24 +148,25 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
// Get the values which are not part of the default KartProperties // Get the values which are not part of the default KartProperties
// --------------------------------------------------------------- // ---------------------------------------------------------------
lisp->get("anvil-weight", m_anvil_weight ); lisp->get("anvil-weight", m_anvil_weight );
lisp->get("shortcut-skipped-segments", m_shortcut_segments ); lisp->get("shortcut-skipped-segments", m_shortcut_segments );
lisp->get("anvil-speed-factor", m_anvil_speed_factor ); lisp->get("anvil-speed-factor", m_anvil_speed_factor );
lisp->get("parachute-friction", m_parachute_friction ); lisp->get("parachute-friction", m_parachute_friction );
lisp->get("jump-impulse", m_jump_impulse ); lisp->get("parachute-time", m_parachute_time );
lisp->get("parachute-time", m_parachute_time ); lisp->get("parachute-time-other", m_parachute_time_other );
lisp->get("parachute-time-other", m_parachute_time_other); lisp->get("parachute-done-fraction", m_parachute_done_fraction );
lisp->get("bomb-time", m_bomb_time ); lisp->get("jump-impulse", m_jump_impulse );
lisp->get("bomb-time-increase", m_bomb_time_increase ); lisp->get("bomb-time", m_bomb_time );
lisp->get("anvil-time", m_anvil_time ); lisp->get("bomb-time-increase", m_bomb_time_increase );
lisp->get("zipper-time", m_zipper_time ); lisp->get("anvil-time", m_anvil_time );
lisp->get("zipper-force", m_zipper_force ); lisp->get("zipper-time", m_zipper_time );
lisp->get("zipper-speed-gain", m_zipper_speed_gain ); lisp->get("zipper-force", m_zipper_force );
lisp->get("explosion-impulse", m_explosion_impulse ); lisp->get("zipper-speed-gain", m_zipper_speed_gain );
lisp->get("explosion-impulse", m_explosion_impulse );
lisp->get("explosion-impulse-objects", m_explosion_impulse_objects); lisp->get("explosion-impulse-objects", m_explosion_impulse_objects);
lisp->get("max-karts", m_max_karts ); lisp->get("max-karts", m_max_karts );
lisp->get("grid-order", m_grid_order ); lisp->get("grid-order", m_grid_order );
lisp->get("title-music", m_title_music ); lisp->get("title-music", m_title_music );
// Get the default KartProperties // Get the default KartProperties
// ------------------------------ // ------------------------------

View File

@ -29,9 +29,10 @@ public:
float m_anvil_weight; // Additional kart weight if anvil is attached float m_anvil_weight; // Additional kart weight if anvil is attached
float m_anvil_speed_factor; // To decrease speed once when attached float m_anvil_speed_factor; // To decrease speed once when attached
float m_parachute_friction; // Increased air friction when parachute float m_parachute_friction; // Increased air friction when parachute
float m_jump_impulse; // percentage of gravity when jumping 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; // time a parachute is active
float m_parachute_time_other; // time a parachute attached to other karts is active float m_parachute_time_other; // time a parachute attached to other karts is active
float m_jump_impulse; // percentage of gravity when jumping
float m_bomb_time; // time before a bomb explodes 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_bomb_time_increase; // time added to bomb timer when it's passed on
float m_anvil_time; // time an anvil is active float m_anvil_time; // time an anvil is active