From fac59355c0bfdc5d9dba5228e47ca78ea541b3e7 Mon Sep 17 00:00:00 2001 From: hikerstk Date: Thu, 6 Mar 2008 13:32:51 +0000 Subject: [PATCH] 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 --- data/stk_config.data | 15 +++++------ src/attachment.cpp | 15 ++++++++--- src/attachment.hpp | 1 + src/kart.cpp | 4 +-- src/kart.hpp | 3 --- src/kart_properties.cpp | 14 +++------- src/kart_properties.hpp | 7 ----- src/stk_config.cpp | 59 ++++++++++++++++++++--------------------- src/stk_config.hpp | 3 ++- 9 files changed, 55 insertions(+), 66 deletions(-) diff --git a/data/stk_config.data b/data/stk_config.data index 346d97ede..819f7f327 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -17,11 +17,12 @@ (parachute-friction 2.0 ) ;; friction increase when a parachute is sttached (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-done-fraction 0.7 ) ;; fraction of speed when lost will detach parachute (bomb-time 30.0 ) ;; time till a bomb explodes (bomb-time-increase -5.0 ) ;; time added to timer when bomb is passed on (anvil-time 2.0 ) ;; time an anvil 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 (shortcut-skipped-segments 5 ) ;; skipping more than this number of segments ;; is considered to be a shortcut @@ -38,11 +39,6 @@ (kart-defaults (wheel-base 1.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 ) (corn-f 4 ) (corn-r 4 ) @@ -61,9 +57,10 @@ (inertia 5.0 ) ;; Bullet physics attributes - (bullet-engine-power 400 ) - (bullet-mass 225 ) - (bullet-max-steer-angle 25 ) + (brake-factor 2.75 ) + (max-steer-angle 6.4 ) + (engine-power 400 ) + (mass 225 ) (suspension-stiffness 8.0 ) (wheel-damping-relaxation 2.3 ) (wheel-damping-compression 4.4 ) diff --git a/src/attachment.cpp b/src/attachment.cpp index ed8b1c33c..3ecb70925 100644 --- a/src/attachment.cpp +++ b/src/attachment.cpp @@ -91,10 +91,11 @@ void Attachment::hitGreenHerring() break; default: random_attachment = rand()%3; } // switch - + switch (random_attachment) { case 0: set( ATTACH_PARACHUTE, stk_config->m_parachute_time+leftover_time); + m_initial_speed = m_kart->getSpeed(); // if ( m_kart == m_kart[0] ) // sound -> playSfx ( SOUND_SHOOMF ) ; break ; @@ -130,8 +131,16 @@ void Attachment::update(float dt) switch (m_type) { - case ATTACH_PARACHUTE: // handled in Kart::updatePhysics - case ATTACH_ANVIL: // handled in Kart::updatePhysics + case ATTACH_PARACHUTE: // 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) + { + 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_MAX: break; case ATTACH_BOMB: if(m_time_left<=0.0) diff --git a/src/attachment.hpp b/src/attachment.hpp index f7062beb1..3dc785002 100644 --- a/src/attachment.hpp +++ b/src/attachment.hpp @@ -38,6 +38,7 @@ private: attachmentType m_type; // attachment type Kart *m_kart; // kart the attachment is attached to 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 Kart *m_previous_owner; // used by bombs so that it's not passed // back to previous owner diff --git a/src/kart.cpp b/src/kart.cpp index 2b9d84f79..ecd10356e 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -846,7 +846,7 @@ void Kart::updatePhysics (float dt) 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, 1); @@ -1136,7 +1136,7 @@ void Kart::placeModel () sgMat4 wheel_rot; 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); diff --git a/src/kart.hpp b/src/kart.hpp index 90f972170..794a2a8cb 100644 --- a/src/kart.hpp +++ b/src/kart.hpp @@ -186,9 +186,6 @@ public: float getHeightCOG () const {return m_kart_properties->getHeightCOG();} float getFrictionSlip () const {return m_kart_properties->getFrictionSlip();} 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 {return m_kart_properties->getGravityCenterShift(); } float getWheelieMaxSpeedRatio () const diff --git a/src/kart_properties.cpp b/src/kart_properties.cpp index ee7db30a9..4ffb38c9a 100644 --- a/src/kart_properties.cpp +++ b/src/kart_properties.cpp @@ -134,15 +134,11 @@ void KartProperties::getAllData(const lisp::Lisp* lisp) lisp->get("wheel-base", m_wheel_base); 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("brake-factor", m_brake_factor); - lisp->get("bullet-mass", m_mass); - lisp->get("tire-grip", m_tire_grip); - 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("mass", m_mass); + lisp->get("max-steer-angle", m_max_steer_angle); lisp->get("wheelie-max-speed-ratio", m_wheelie_max_speed_ratio ); lisp->get("wheelie-max-pitch", m_wheelie_max_pitch ); 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_brake_factor = stk_config->m_brake_factor; 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_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_pitch = stk_config->m_wheelie_max_pitch; m_wheelie_pitch_rate = stk_config->m_wheelie_pitch_rate; diff --git a/src/kart_properties.hpp b/src/kart_properties.hpp index 97088c651..6ea95c29a 100644 --- a/src/kart_properties.hpp +++ b/src/kart_properties.hpp @@ -57,12 +57,8 @@ protected: float m_height_cog; // height of center of gravity float m_engine_power; // maximum force from engine 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_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_pitch; // maximum pitch for wheelies 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 getHeightCOG () const {return m_height_cog; } 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 getWheelieMaxSpeedRatio() const {return m_wheelie_max_speed_ratio;} float getWheelieMaxPitch () const {return m_wheelie_max_pitch; } diff --git a/src/stk_config.cpp b/src/stk_config.cpp index b05ded1af..fd2ac1660 100644 --- a/src/stk_config.cpp +++ b/src/stk_config.cpp @@ -59,11 +59,7 @@ void STKConfig::load(const std::string filename) CHECK_NEG(m_max_karts, "max-karts" ); 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_inertia, "m_inertia" ); CHECK_NEG(m_height_cog, "heightCOG" ); CHECK_NEG(m_wheel_base, "wheel-base" ); 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_power_boost, "wheelie-power-boost" ); - CHECK_NEG(m_parachute_friction, "parachute-friction" ); - CHECK_NEG(m_time_full_steer, "time-full-steer" ); + CHECK_NEG(m_parachute_friction, "parachute-friction" ); + 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 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_max_speed_reverse_ratio, "max-speed-reverse-ratio" ); 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_increase, "bomb-time-increase" ); CHECK_NEG(m_anvil_time, "anvil-time" ); @@ -120,16 +118,16 @@ void STKConfig::load(const std::string filename) */ void STKConfig::init_defaults() { - m_wheel_base = m_height_cog = m_mass = - m_corn_r = m_max_steer_angle = - m_corn_f = m_inertia = m_anvil_weight = m_parachute_friction = + m_wheel_base = m_height_cog = m_mass = m_max_steer_angle = + 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_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_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_parachute_time_other = m_shortcut_segments = + m_shortcut_segments = //bullet physics data m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_damping_compression = 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 // --------------------------------------------------------------- - lisp->get("anvil-weight", m_anvil_weight ); - lisp->get("shortcut-skipped-segments", m_shortcut_segments ); - lisp->get("anvil-speed-factor", m_anvil_speed_factor ); - 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-other", m_parachute_time_other); - lisp->get("bomb-time", m_bomb_time ); - lisp->get("bomb-time-increase", m_bomb_time_increase ); - lisp->get("anvil-time", m_anvil_time ); - lisp->get("zipper-time", m_zipper_time ); - lisp->get("zipper-force", m_zipper_force ); - lisp->get("zipper-speed-gain", m_zipper_speed_gain ); - lisp->get("explosion-impulse", m_explosion_impulse ); + lisp->get("anvil-weight", m_anvil_weight ); + lisp->get("shortcut-skipped-segments", m_shortcut_segments ); + lisp->get("anvil-speed-factor", m_anvil_speed_factor ); + lisp->get("parachute-friction", m_parachute_friction ); + lisp->get("parachute-time", m_parachute_time ); + lisp->get("parachute-time-other", m_parachute_time_other ); + lisp->get("parachute-done-fraction", m_parachute_done_fraction ); + lisp->get("jump-impulse", m_jump_impulse ); + lisp->get("bomb-time", m_bomb_time ); + lisp->get("bomb-time-increase", m_bomb_time_increase ); + lisp->get("anvil-time", m_anvil_time ); + lisp->get("zipper-time", m_zipper_time ); + lisp->get("zipper-force", m_zipper_force ); + 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("max-karts", m_max_karts ); - lisp->get("grid-order", m_grid_order ); - lisp->get("title-music", m_title_music ); + lisp->get("max-karts", m_max_karts ); + lisp->get("grid-order", m_grid_order ); + lisp->get("title-music", m_title_music ); // Get the default KartProperties // ------------------------------ diff --git a/src/stk_config.hpp b/src/stk_config.hpp index 0e8d82885..a646f19b7 100644 --- a/src/stk_config.hpp +++ b/src/stk_config.hpp @@ -29,9 +29,10 @@ public: float m_anvil_weight; // Additional kart weight if anvil is attached float m_anvil_speed_factor; // To decrease speed once when attached 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_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_increase; // time added to bomb timer when it's passed on float m_anvil_time; // time an anvil is active