Add configurable parameter for zipper max speed

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3889 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
davemk 2009-08-19 14:28:07 +00:00
parent 779003befe
commit 344f203d18
4 changed files with 29 additions and 22 deletions

View File

@ -48,6 +48,7 @@
(zipper-time 3.5 ) ;; time a zipper is active
(zipper-force 250.0 ) ;; additional zipper force
(zipper-speed-gain 4.5 ) ;; one time additional speed
(zipper-max-speed-fraction 0.2 ) ;; fraction of max speed allowed past regular max speed
(shortcut-length 90 ) ;; leaving the road and coming back on it more than
;; x 'meters" later is considered to be a shortcut

View File

@ -56,14 +56,14 @@ void STKConfig::load(const std::string &filename)
}
catch(std::exception& err)
{
fprintf(stderr, "Error while parsing KartProperties '%s':\n",
fprintf(stderr, "Error while parsing KartProperties '%s':\n",
filename.c_str());
fprintf(stderr, "%s", err.what());
fprintf(stderr, "\n");
}
delete root;
// Check that all necessary values are indeed set
// Check that all necessary values are indeed set
// -----------------------------------------------
#define CHECK_NEG( a,strA) if(a<=UNDEFINED) { \
@ -104,6 +104,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_zipper_time, "zipper-time" );
CHECK_NEG(m_zipper_force, "zipper-force" );
CHECK_NEG(m_zipper_speed_gain, "zipper-speed-gain" );
CHECK_NEG(m_zipper_max_speed_fraction, "zipper-max-speed-fraction" );
CHECK_NEG(m_final_camera_time, "final-camera-time" );
CHECK_NEG(m_explosion_impulse, "explosion-impulse" );
CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects" );
@ -128,14 +129,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_anvil_weight = m_parachute_friction =
m_parachute_time = m_parachute_done_fraction =
m_parachute_time_other = m_anvil_speed_factor =
m_bomb_time = m_bomb_time_increase =
m_anvil_time = m_zipper_time =
m_zipper_force = m_zipper_speed_gain =
m_explosion_impulse = m_explosion_impulse_objects =
m_music_credit_time = m_slowdown_factor =
m_zipper_max_speed_fraction =
m_explosion_impulse = m_explosion_impulse_objects =
m_music_credit_time = m_slowdown_factor =
m_delay_finish_time = m_skid_fadeout_time =
m_final_camera_time = m_near_ground = UNDEFINED;
m_max_karts = -100;
@ -193,6 +195,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
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("zipper-max-speed-fraction", m_zipper_max_speed_fraction);
lisp->get("explosion-impulse", m_explosion_impulse );
lisp->get("explosion-impulse-objects", m_explosion_impulse_objects);
lisp->get("max-karts", m_max_karts );
@ -210,7 +213,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
lisp->get("delay-finish-time", m_delay_finish_time );
lisp->get("music-credit-time", m_music_credit_time );
lisp->getVector("menu-background", m_menu_background );
lisp->getVector("mainmenu-background", m_mainmenu_background );
lisp->getVector("mainmenu-background", m_mainmenu_background );
lisp->get("enable_networking", m_enable_networking );
std::string title_music;
lisp->get("title-music", title_music );

View File

@ -30,33 +30,35 @@ class MusicInformation;
* includes the list of default kart physics parameters which are used for
* each kart (but which can be overwritten for each kart, too).
*/
class STKConfig
class STKConfig
{
protected:
KartProperties m_kart_properties; /**< Default kart properties. */
public:
static float UNDEFINED;
float m_anvil_weight; /**<Additional kart weight if anvil is
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
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
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
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_zipper_time; /**<Duration a zipper is active. */
float m_zipper_force; /**<Additional force added to the
float m_zipper_force; /**<Additional force added to the
acceleration. */
float m_zipper_speed_gain; /**<Initial one time speed gain. */
float m_zipper_max_speed_fraction;/**<Fraction of max speed allowed past
regular max speed */
float m_final_camera_time; /**<Time for the movement of the final
* camera. */
float m_explosion_impulse; /**<Impulse affecting each non-hit kart.*/
float m_explosion_impulse_objects;/**<Impulse of explosion on moving
float m_explosion_impulse_objects;/**<Impulse of explosion on moving
objects, e.g. road cones, ... */
float m_delay_finish_time; /**<Delay after a race finished before
the results are displayed. */
@ -68,9 +70,9 @@ public:
int m_max_history; /**<Maximum number of frames to save in
a history files. */
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
float m_slowdown_factor; /**<Used in terrain specific slowdown. */
float m_near_ground; /**<Determines when a kart is not near
float m_near_ground; /**<Determines when a kart is not near
* ground anymore and the upright
* constraint is disabled to allow for
* more violent explosions. */
@ -79,20 +81,20 @@ public:
int m_min_track_version, /**<The minimum and maximum .track file */
m_max_track_version; /**<version supported by this binary. */
bool m_enable_networking;
std::vector<float>
m_leader_intervals; /**<Interval in follow the leader till
std::vector<float>
m_leader_intervals; /**<Interval in follow the leader till
last kart is reomved. */
std::vector<int>
m_scores; /**<Scores depending on position. */
MusicInformation
MusicInformation
*m_title_music; /**<Filename of the title music to play.*/
std::vector<std::string>
m_mainmenu_background; /**<Picture used as menu background. */
std::vector<std::string>
m_menu_background; /**<Picture used as background for other menus. */
/** Empty constructor. The actual work is done in load. */
STKConfig() {};
void init_defaults ();

View File

@ -692,7 +692,8 @@ void Kart::handleZipper()
btVector3 v = m_body->getLinearVelocity();
float current_speed = v.length();
float speed = std::min(current_speed+stk_config->m_zipper_speed_gain,
getMaxSpeedOnTerrain());
getMaxSpeedOnTerrain() *
(1 + stk_config->m_zipper_max_speed_fraction));
m_vehicle->activateZipper(speed);
} // handleZipper