diff --git a/data/stk_config.data b/data/stk_config.data index 5e9c9383a..656b98e83 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -35,7 +35,7 @@ (shortcut-length 120 ) ;; leaving the road and coming back on it more than ;; x 'meters" later is considered to be a shortcut - (enable_networking #f ) + (enable_networking #f ) ;; For now disable networking (explosion-impulse 10000.0 ) ;; explosion impulse on not directly hit karts (explosion-impulse-objects 500.0) ;; explosion impulse for physics objects (smaller ;; else a cone e.g. will be pushed way too far) @@ -58,15 +58,7 @@ ;; at the very bottom of the chassis! ;;(gravity-center-shift 0 0 0.3) - (wheelie-max-speed-ratio 0.5 ) ;; percentage of max speed for wheelies to work - (wheelie-max-pitch 45.0 ) ;; maximum pitch to use when doing a wheelie - (wheelie-pitch-rate 60.0 ) ;; rate/sec with which the kart goes up - (wheelie-restore-rate 90.0 ) ;; rate/sec with which the kart does down - (wheelie-speed-boost 10.0 ) ;; speed boost while doing a wheelie - (wheelie-lean-recovery 1 ) - (wheelie-balance-recovery 2 ) - (wheelie-step 1 ) - (wheelie-power-boost 3 ) ;; increase in engine power, i.e. 1=plus 100% + (nitro-power-boost 3 ) ;; increase in engine power, i.e. 1=plus 100% ;; Bullet physics attributes (brake-factor 2.75 ) @@ -80,7 +72,12 @@ ;; independent of the kart size. (min-speed-radius 0 4.64) (max-speed-radius 12 13.5) - (engine-power 400 ) + ;; Different engine powers for different difficulties: + ;; hard, medium, low level order! + (engine-power 400 300 200 ) + ;; Different maximum speed for different difficulties: + ;; hard, medium, low level order! + (max-speed 32.22 25 20 ) ;; = 116 90 72 km/h (mass 225 ) (suspension-stiffness 48.0 ) (wheel-damping-relaxation 20 ) @@ -91,7 +88,6 @@ (wheel-width 0.3 ) (chassis-linear-damping 0.2 ) (chassis-angular-damping 30.2 ) - (maximum-speed 32.22 ) ;; = 80 km/h (max-speed-reverse-ratio 0.2 ) ;; percentage of max speed for reverse gear (suspension-rest 0.2 ) (suspension-travel-cm 19 ) diff --git a/src/gui/race_gui.cpp b/src/gui/race_gui.cpp index e9ee80294..33a32b1d3 100644 --- a/src/gui/race_gui.cpp +++ b/src/gui/race_gui.cpp @@ -631,16 +631,6 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y, offset_y+(int)(10*minRatio)); else { - if (stk_config->m_game_style==STKConfig::GS_WHEELIE && - speed >= kart->getMaxSpeed()*kart->getWheelieMaxSpeedRatio() ) - { - font_race->PrintShadow("l", (int)(60*minRatio), - offset_x+(int)(70*minRatio), offset_y); - font_race->PrintShadow("^", (int)(60*minRatio), - offset_x+(int)(65*minRatio), - offset_y+(int)(7*minRatio)); - } - float speedRatio = speed/KILOMETERS_PER_HOUR/110.0f; // The following does not work with wheelie or Zipper //float speedRatio = kart->getVelocity()->xyz[1]/(kart->getMaxSpeed(); diff --git a/src/gui/race_options.cpp b/src/gui/race_options.cpp index 3fe38f287..e18e068a4 100644 --- a/src/gui/race_options.cpp +++ b/src/gui/race_options.cpp @@ -186,13 +186,7 @@ void RaceOptions::select() } else if( m_difficulty == RaceManager::RD_EASY ) { -//TEMP: done just for the release after 0.4 because of AI problems -#undef ENABLE_MEDIUM_AI -#if ENABLE_MEDIUM_AI m_difficulty = RaceManager::RD_MEDIUM; -#else - m_difficulty = RaceManager::RD_HARD; -#endif } widget_manager->setWgtText( WTOK_DIFFICULTY, getDifficultyString(m_difficulty) ); break; @@ -200,18 +194,18 @@ void RaceOptions::select() case WTOK_DIFFICULTY_DOWN: if( m_difficulty == RaceManager::RD_HARD ) { -//TEMP: done just for the release after 0.4 because of AI problems -#if ENABLE_MEDIUM_AI m_difficulty = RaceManager::RD_MEDIUM; -#else - m_difficulty = RaceManager::RD_EASY; -#endif } else if( m_difficulty == RaceManager::RD_MEDIUM ) { m_difficulty = RaceManager::RD_EASY; - } - widget_manager->setWgtText( WTOK_DIFFICULTY, getDifficultyString(m_difficulty) ); + } + else if( m_difficulty == RaceManager::RD_EASY ) + { + m_difficulty = RaceManager::RD_HARD; + } + widget_manager->setWgtText( WTOK_DIFFICULTY, + getDifficultyString(m_difficulty) ); break; diff --git a/src/ide/vc9/supertuxkart.vcproj b/src/ide/vc9/supertuxkart.vcproj index f1ab18f94..c5ab8792e 100644 --- a/src/ide/vc9/supertuxkart.vcproj +++ b/src/ide/vc9/supertuxkart.vcproj @@ -983,46 +983,6 @@ > - - - - - - - - - - - - - - - - - - - - @@ -1199,6 +1159,46 @@ > + + + + + + + + + + + + + + + + + + + + getMaximumSpeed(); + m_max_speed = m_kart_properties->getMaxSpeed(); m_max_speed_reverse_ratio = m_kart_properties->getMaxSpeedReverseRatio(); m_speed = 0.0f; @@ -633,52 +633,21 @@ void Kart::draw() } // draw // ----------------------------------------------------------------------------- -/** Returned an additional engine power boost when doing a wheele. +/** Returned an additional engine power boost when using nitro. * \param dt Time step size. */ - -float Kart::handleWheelie(float dt) +float Kart::handleNitro(float dt) { - // For now: handle nitro mode here: - if(stk_config->m_game_style==STKConfig::GS_NITRO) + if(!m_controls.wheelie) return 0.0; + m_collected_energy -= dt; + if(m_collected_energy<0) { - if(!m_controls.wheelie) return 0.0; - m_collected_energy -= dt; - if(m_collected_energy<0) - { - m_collected_energy = 0; - return 0.0; - } - return m_kart_properties->getWheeliePowerBoost() * getMaxPower(); + m_collected_energy = 0; + return 0.0; } - // Handle wheelies - // =============== - if ( m_controls.wheelie && - m_speed >= getMaxSpeed()*getWheelieMaxSpeedRatio()) - { - // Disable the upright constraint, since it will otherwise - // work against the wheelie - m_uprightConstraint->setLimit(M_PI); + return m_kart_properties->getNitroPowerBoost() * getMaxPower(); - if ( m_wheelie_angle < getWheelieMaxPitch() ) - m_wheelie_angle += getWheeliePitchRate() * dt; - else - m_wheelie_angle = getWheelieMaxPitch(); - } - else if ( m_wheelie_angle > 0.0f ) - { - m_wheelie_angle -= getWheelieRestoreRate() * dt; - if ( m_wheelie_angle <= 0.0f ) m_wheelie_angle = 0.0f ; - } - if(m_wheelie_angle <=0.0f) - { - m_uprightConstraint->setLimit(m_kart_properties->getUprightTolerance()); - return 0.0f; - } - - return m_kart_properties->getWheeliePowerBoost() * getMaxPower() - * m_wheelie_angle/getWheelieMaxPitch(); -} // handleWheelie +} // handleNitro // ----------------------------------------------------------------------------- /** This function is called when the race starts. Up to then all brakes are @@ -713,7 +682,7 @@ void Kart::beep() void Kart::updatePhysics (float dt) { m_bounce_back_time-=dt; - float engine_power = getActualWheelForce() + handleWheelie(dt); + float engine_power = getActualWheelForce() + handleNitro(dt); if(m_attachment.getType()==ATTACH_PARACHUTE) engine_power*=0.2f; if(m_controls.accel) // accelerating @@ -830,7 +799,7 @@ void Kart::updatePhysics (float dt) m_speed *= -1.f; //cap at maximum velocity - const float max_speed = m_kart_properties->getMaximumSpeed(); + const float max_speed = m_kart_properties->getMaxSpeed(); if ( m_speed > max_speed ) { const float velocity_ratio = max_speed/m_speed; diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index 0ada518c1..21247f5b0 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -167,16 +167,6 @@ public: {return m_kart_properties->getMaxSteerAngle(getSpeed());} const Vec3& getGravityCenterShift () const {return m_kart_properties->getGravityCenterShift(); } - float getWheelieMaxSpeedRatio () const - {return m_kart_properties->getWheelieMaxSpeedRatio(); } - float getWheelieMaxPitch () const - {return m_kart_properties->getWheelieMaxPitch(); } - float getWheeliePitchRate () const - {return m_kart_properties->getWheeliePitchRate(); } - float getWheelieRestoreRate() const - {return m_kart_properties->getWheelieRestoreRate(); } - float getWheelieSpeedBoost() const - {return m_kart_properties->getWheelieSpeedBoost(); } float getSteerPercent () const {return m_controls.lr; } const KartControl& getControls () const {return m_controls; } @@ -201,7 +191,7 @@ public: * from the server information. */ void setSpeed (float s) {m_speed = s; } void setSuspensionLength(); - float handleWheelie (float dt); + float handleNitro (float dt); float getActualWheelForce(); bool isOnGround () const; bool isEliminated () const {return m_eliminated;} diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index dbc18fcbd..dce4f7939 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -56,13 +56,14 @@ KartProperties::KartProperties() : m_icon_material(0) // Set all other values to undefined, so that it can later be tested // if everything is defined properly. m_mass = m_min_speed_turn = m_angle_at_min = - m_max_speed_turn = m_angle_at_max = m_engine_power = m_brake_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_max_speed_turn = m_angle_at_max = m_brake_factor = + m_engine_power[0] = m_engine_power[1] = m_engine_power[2] = + m_max_speed[0] = m_max_speed[1] = m_max_speed[2] = + m_time_full_steer = m_nitro_power_boost = m_suspension_stiffness = m_wheel_damping_relaxation = m_wheel_base = m_wheel_damping_compression = m_friction_slip = m_roll_influence = - m_wheel_radius = m_wheelie_power_boost = m_chassis_linear_damping = - m_chassis_angular_damping = m_maximum_speed = m_suspension_rest = + m_wheel_radius = m_chassis_linear_damping = + m_chassis_angular_damping = m_suspension_rest = m_max_speed_reverse_ratio = m_jump_velocity = m_upright_tolerance = m_upright_max_force = m_suspension_travel_cm = m_track_connection_accel = m_min_speed_turn = m_angle_at_min = @@ -224,12 +225,7 @@ void KartProperties::getAllData(const lisp::Lisp* lisp) } } - 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 ); - lisp->get("wheelie-restore-rate", m_wheelie_restore_rate ); - lisp->get("wheelie-speed-boost", m_wheelie_speed_boost ); - lisp->get("wheelie-power-boost", m_wheelie_power_boost ); + lisp->get("nitro-power-boost", m_nitro_power_boost ); //bullet physics data lisp->get("suspension-stiffness", m_suspension_stiffness ); @@ -241,7 +237,7 @@ void KartProperties::getAllData(const lisp::Lisp* lisp) lisp->get("chassis-linear-damping", m_chassis_linear_damping ); lisp->get("chassis-angular-damping", m_chassis_angular_damping ); lisp->get("max-speed-reverse-ratio", m_max_speed_reverse_ratio ); - lisp->get("maximum-speed", m_maximum_speed ); + lisp->get("max-speed", m_max_speed ); lisp->get("gravity-center-shift", m_gravity_center_shift ); lisp->get("suspension-rest", m_suspension_rest ); lisp->get("suspension-travel-cm", m_suspension_travel_cm ); @@ -301,7 +297,9 @@ void KartProperties::checkAllSet(const std::string &filename) } CHECK_NEG(m_mass, "mass" ); - CHECK_NEG(m_engine_power, "engine-power" ); + CHECK_NEG(m_engine_power[0], "engine-power[0]" ); + CHECK_NEG(m_engine_power[1], "engine-power[1]" ); + CHECK_NEG(m_engine_power[2], "engine-power[2]" ); CHECK_NEG(m_min_speed_turn, "min-speed-angle" ); CHECK_NEG(m_min_radius, "min-speed-angle" ); CHECK_NEG(m_max_speed_turn, "max-speed-angle" ); @@ -309,12 +307,6 @@ void KartProperties::checkAllSet(const std::string &filename) CHECK_NEG(m_brake_factor, "brake-factor" ); CHECK_NEG(m_time_full_steer, "time-full-steer" ); - CHECK_NEG(m_wheelie_max_speed_ratio, "wheelie-max-speed-ratio" ); - CHECK_NEG(m_wheelie_max_pitch, "wheelie-max-pitch" ); - CHECK_NEG(m_wheelie_pitch_rate, "wheelie-pitch-rate" ); - CHECK_NEG(m_wheelie_restore_rate, "wheelie-restore-rate" ); - CHECK_NEG(m_wheelie_speed_boost, "wheelie-speed-boost" ); - CHECK_NEG(m_wheelie_power_boost, "wheelie-power-boost" ); //bullet physics data CHECK_NEG(m_suspension_stiffness, "suspension-stiffness" ); CHECK_NEG(m_wheel_damping_relaxation, "wheel-damping-relaxation" ); @@ -325,7 +317,9 @@ void KartProperties::checkAllSet(const std::string &filename) // Don't check m_wheel_base here, it is computed later! CHECK_NEG(m_chassis_linear_damping, "chassis-linear-damping" ); CHECK_NEG(m_chassis_angular_damping, "chassis-angular-damping" ); - CHECK_NEG(m_maximum_speed, "maximum-speed" ); + CHECK_NEG(m_max_speed[0], "maximum-speed[0]" ); + CHECK_NEG(m_max_speed[1], "maximum-speed[1]" ); + CHECK_NEG(m_max_speed[2], "maximum-speed[2]" ); CHECK_NEG(m_max_speed_reverse_ratio, "max-speed-reverse-ratio" ); CHECK_NEG(m_suspension_rest, "suspension-rest" ); CHECK_NEG(m_suspension_travel_cm, "suspension-travel-cm" ); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index 5c3f271b4..957ef84de 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -23,6 +23,8 @@ #include #include #include "plib/ssg.h" + +#include "race_manager.hpp" #include "karts/kart_model.hpp" #include "lisp/lisp.hpp" #include "audio/sfx_manager.hpp" @@ -67,19 +69,12 @@ protected: // Physic properties // ----------------- float m_mass; /**< Weight of kart. */ - float m_engine_power; /**< Maximum force from engine. */ + float m_engine_power[3]; /**< Maximum force from engine for each + * difficulty. */ float m_brake_factor; /**< Braking factor * engine_power = * braking force. */ float m_time_full_steer; /**< Time for player karts to reach full * steer angle. */ - 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. */ - float m_wheelie_restore_rate; /**< Rate/sec with which kart does down.*/ - float m_wheelie_speed_boost; /**< Speed boost while doing a wheelie. */ - float m_wheelie_power_boost; /**< Increase in engine power. */ - float m_min_speed_turn, /**< Speed for smallest turn radius. */ m_angle_at_min, /**< Steering angle for minimal turn radius. Computed from radius and @@ -103,8 +98,9 @@ protected: float m_rubber_band_force; /**< Force of an attached rubber band.*/ float m_rubber_band_duration;/**< Duration a rubber band works. */ float m_wheel_base; /**< Wheel base of the kart. */ - - SFXManager::SFXType m_engine_sfx_type; /**< Engine sound effect. */ + float m_nitro_power_boost; /**< Nitro power boost. */ + SFXManager::SFXType + m_engine_sfx_type; /**< Engine sound effect. */ // bullet physics data // ------------------- @@ -116,7 +112,7 @@ protected: float m_wheel_radius; float m_chassis_linear_damping; float m_chassis_angular_damping; - float m_maximum_speed; + float m_max_speed[3]; float m_max_speed_reverse_ratio; Vec3 m_gravity_center_shift; /**< Shift of center of gravity. */ float m_track_connection_accel; /**< Artifical acceleration that pulls a @@ -164,16 +160,10 @@ public: const std::vector& getGroups () const {return m_groups; } float getMass () const {return m_mass; } - float getMaxPower () const {return m_engine_power; } + float getMaxPower () const {return m_engine_power[race_manager->getDifficulty()];} float getTimeFullSteer () const {return m_time_full_steer; } float getBrakeFactor () const {return m_brake_factor; } 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; } - float getWheeliePitchRate () const {return m_wheelie_pitch_rate; } - float getWheelieRestoreRate () const {return m_wheelie_restore_rate; } - float getWheelieSpeedBoost () const {return m_wheelie_speed_boost; } - float getWheeliePowerBoost () const {return m_wheelie_power_boost; } SFXManager::SFXType getEngineSfxType() const {return m_engine_sfx_type; } @@ -187,7 +177,11 @@ public: float getWheelBase () const {return m_wheel_base; } float getChassisLinearDamping () const {return m_chassis_linear_damping; } float getChassisAngularDamping () const {return m_chassis_angular_damping; } - float getMaximumSpeed () const {return m_maximum_speed; } + /** Returns the maximum speed dependent on the difficult level. */ + float getMaxSpeed () const {return + m_max_speed[race_manager->getDifficulty()];} + /** Returns the nitro power boost. */ + float getNitroPowerBoost () const {return m_nitro_power_boost; } const Vec3&getGravityCenterShift() const {return m_gravity_center_shift; } float getSuspensionRest () const {return m_suspension_rest; } float getSuspensionTravelCM () const {return m_suspension_travel_cm; } diff --git a/src/robots/default_robot.cpp b/src/robots/default_robot.cpp index d1a791e79..5d259c623 100755 --- a/src/robots/default_robot.cpp +++ b/src/robots/default_robot.cpp @@ -75,15 +75,17 @@ DefaultRobot::DefaultRobot(const std::string& kart_name, m_max_start_delay = 0.5f; m_min_steps = 0; m_skidding_threshold = 4.0f; + m_nitro_level = NITRO_NONE; break; case RaceManager::RD_MEDIUM: m_wait_for_players = true; m_max_handicap_accel = 0.95f; - m_fallback_tactic = FT_PARALLEL; + m_fallback_tactic = FT_FAREST_POINT; m_item_tactic = IT_CALCULATE; m_max_start_delay = 0.4f; m_min_steps = 1; m_skidding_threshold = 2.0f; + m_nitro_level = NITRO_SOME; break; case RaceManager::RD_HARD: m_wait_for_players = false; @@ -93,6 +95,7 @@ DefaultRobot::DefaultRobot(const std::string& kart_name, m_max_start_delay = 0.1f; m_min_steps = 2; m_skidding_threshold = 1.3f; + m_nitro_level = NITRO_ALL; break; } } // DefaultRobot @@ -464,21 +467,6 @@ void DefaultRobot::handleRaceStart() //----------------------------------------------------------------------------- void DefaultRobot::handleRescue(const float DELTA) { - //TODO: check if we collided against a dynamic object (ej.:kart) or - //against the track's static object. - //The m_crash_time measures if a kart has been crashing for too long -#ifdef RESCUE_IF_CRASHES_WITH_KARTS - m_crash_time += (m_collided && isOnGround()) ? 3.0f * DELTA : -0.25f * DELTA; - if( m_crash_time < 0.0f ) m_crash_time = 0.0f; - - //Reaction to being stuck - if( m_crash_time > 3.0f ) - { - forceRescue(); - m_crash_time = 0.0f; - } -#endif - // check if kart is stuck if(getSpeed()<2.0f && !isRescue() && !RaceManager::getWorld()->isStartPhase()) { @@ -502,7 +490,8 @@ void DefaultRobot::handleNitro() { m_controls.wheelie = false; // Don't use nitro if the kart doesn't have any, is not on ground, - if(getEnergy()==0 || !isOnGround() || hasFinishedRace() ) return; + if(getEnergy()==0 || !isOnGround() || + m_nitro_level==NITRO_NONE || hasFinishedRace() ) return; // If a parachute or anvil is attached, the nitro doesn't give much // benefit. Better wait till later. @@ -531,7 +520,8 @@ void DefaultRobot::handleNitro() // On the last track shortly before the finishing line, use nitro // anyway. Since the kart is faster with nitro, estimate a 30% time // decrease. - if(m_world->getLapForKart(getWorldKartId())==race_manager->getNumLaps()-1) + if(m_world->getLapForKart(getWorldKartId())==race_manager->getNumLaps()-1 && + m_nitro_level == NITRO_ALL) { float finish = m_world->getEstimatedFinishTime(getWorldKartId()); if( 1.3f*getEnergy() >= finish - m_world->getTime() ) @@ -565,9 +555,8 @@ void DefaultRobot::handleNitro() // Kart behind is slower than this kart - no need to use nitro if(kart->getSpeed() < getSpeed()) continue; - // Nitro doesn't give much benefit - better wait and - // see if we can re-overtake once the attachment is gone - m_controls.wheelie = true; + // Only prevent overtaking on highest level + m_controls.wheelie = m_nitro_level==NITRO_ALL; return; } diff --git a/src/robots/default_robot.hpp b/src/robots/default_robot.hpp index 15289290f..842241856 100755 --- a/src/robots/default_robot.hpp +++ b/src/robots/default_robot.hpp @@ -38,6 +38,8 @@ private: //crashing with the track. }; + /** How the AI uses nitro. */ + enum {NITRO_NONE, NITRO_SOME, NITRO_ALL} m_nitro_level; enum ItemTactic { IT_TEN_SECONDS, //Fire after 10 seconds have passed, since the item @@ -73,7 +75,7 @@ private: //mostly on straight lines and on curves //that re too small to need special //handling. - bool m_use_wheelies; //Is the AI allowed to use wheelies? + float m_wheelie_check_dist; //How far to check for the space needed for //wheelies, in percentage. Used only when //m_use_wheelies == true.