Merge branch 'origin/game_protocol'
This commit is contained in:
commit
e58d86d4d5
@ -133,7 +133,7 @@ void STKConfig::load(const std::string &filename)
|
||||
Log::fatal("StkConfig", "Invalid default port values.");
|
||||
}
|
||||
CHECK_NEG(m_max_karts, "<karts max=..." );
|
||||
CHECK_NEG(m_item_switch_time, "item-switch-time" );
|
||||
CHECK_NEG(m_item_switch_ticks, "item switch-time" );
|
||||
CHECK_NEG(m_bubblegum_counter, "bubblegum disappear counter");
|
||||
CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects" );
|
||||
CHECK_NEG(m_max_skidmarks, "max-skidmarks" );
|
||||
@ -146,7 +146,7 @@ void STKConfig::load(const std::string &filename)
|
||||
CHECK_NEG(m_delay_finish_time, "delay-finish-time" );
|
||||
CHECK_NEG(m_music_credit_time, "music-credit-time" );
|
||||
CHECK_NEG(m_leader_time_per_kart, "leader time-per-kart" );
|
||||
CHECK_NEG(m_penalty_time, "penalty-time" );
|
||||
CHECK_NEG(m_penalty_ticks, "penalty-time" );
|
||||
CHECK_NEG(m_max_display_news, "max-display-news" );
|
||||
CHECK_NEG(m_replay_max_time, "replay max-time" );
|
||||
CHECK_NEG(m_replay_delta_angle, "replay delta-angle" );
|
||||
@ -173,10 +173,11 @@ void STKConfig::init_defaults()
|
||||
m_bomb_time = m_bomb_time_increase =
|
||||
m_explosion_impulse_objects = 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_default_track_friction = m_default_moveable_friction =
|
||||
UNDEFINED;
|
||||
m_near_ground =
|
||||
m_smooth_angle_limit = m_default_track_friction =
|
||||
m_default_moveable_friction = UNDEFINED;
|
||||
m_item_switch_ticks = -100;
|
||||
m_penalty_ticks = -100;
|
||||
m_physics_fps = -100;
|
||||
m_bubblegum_counter = -100;
|
||||
m_shield_restrict_weapos = false;
|
||||
@ -275,7 +276,9 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
|
||||
if (const XMLNode *startup_node= root->getNode("startup"))
|
||||
{
|
||||
startup_node->get("penalty", &m_penalty_time );
|
||||
float f;
|
||||
startup_node->get("penalty", &f);
|
||||
m_penalty_ticks = time2Ticks(f);
|
||||
}
|
||||
|
||||
if (const XMLNode *news_node= root->getNode("news"))
|
||||
@ -356,7 +359,9 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
if(const XMLNode *switch_node= root->getNode("switch"))
|
||||
{
|
||||
switch_node->get("items", &m_switch_items );
|
||||
switch_node->get("time", &m_item_switch_time);
|
||||
float f;
|
||||
if( switch_node->get("time", &f) )
|
||||
m_item_switch_ticks = stk_config->time2Ticks(f);
|
||||
}
|
||||
|
||||
if(const XMLNode *bubblegum_node= root->getNode("bubblegum"))
|
||||
|
@ -59,22 +59,24 @@ public:
|
||||
* - SAME: give it one more item of the type it currently has.
|
||||
* - ONLY_IF_SAME: only give it one more item if the randomly chosen item
|
||||
* has the same type as the currently held item. */
|
||||
enum {POWERUP_MODE_NEW,
|
||||
POWERUP_MODE_SAME,
|
||||
POWERUP_MODE_ONLY_IF_SAME}
|
||||
m_same_powerup_mode;
|
||||
enum {
|
||||
POWERUP_MODE_NEW,
|
||||
POWERUP_MODE_SAME,
|
||||
POWERUP_MODE_ONLY_IF_SAME
|
||||
}
|
||||
m_same_powerup_mode;
|
||||
|
||||
static float UNDEFINED;
|
||||
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_item_switch_time; /**< Time items will be switched. */
|
||||
int m_item_switch_ticks; /**< Time items will be switched. */
|
||||
int m_bubblegum_counter; /**< How many times bubble gums must be
|
||||
driven over before they disappear. */
|
||||
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
|
||||
int m_penalty_ticks; /**< Penalty time when starting too
|
||||
early. */
|
||||
float m_delay_finish_time; /**<Delay after a race finished before
|
||||
the results are displayed. */
|
||||
@ -105,9 +107,6 @@ public:
|
||||
/** Default friction to be used for any moveable, e.g. karts, balls. */
|
||||
float m_default_moveable_friction;
|
||||
|
||||
/** Default FPS rate for physics. */
|
||||
int m_physics_fps;
|
||||
|
||||
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
|
||||
float m_skid_fadeout_time; /**<Time till skidmarks fade away. */
|
||||
float m_near_ground; /**<Determines when a kart is not near
|
||||
@ -115,9 +114,9 @@ public:
|
||||
* constraint is disabled to allow for
|
||||
* more violent explosions. */
|
||||
int m_min_kart_version, /**<The minimum and maximum .kart file */
|
||||
m_max_kart_version; /**<version supported by this binary. */
|
||||
m_max_kart_version; /**<version supported by this binary. */
|
||||
int m_min_track_version, /**<The minimum and maximum .track file */
|
||||
m_max_track_version; /**<version supported by this binary. */
|
||||
m_max_track_version; /**<version supported by this binary. */
|
||||
int m_max_display_news; /**<How often a news message is displayed
|
||||
before it is ignored. */
|
||||
|
||||
@ -135,8 +134,8 @@ public:
|
||||
used to give a handicap to AIs */
|
||||
|
||||
std::vector<float>
|
||||
m_leader_intervals; /**<Interval in follow the leader till
|
||||
last kart is reomved. */
|
||||
m_leader_intervals; /**<Interval in follow the leader till
|
||||
last kart is reomved. */
|
||||
float m_leader_time_per_kart; /**< Additional time to each leader
|
||||
interval for each additional kart. */
|
||||
std::vector<int> m_switch_items; /**< How to switch items. */
|
||||
@ -187,19 +186,24 @@ private:
|
||||
* loaded a user specified config file. */
|
||||
bool m_has_been_loaded;
|
||||
|
||||
/** Default FPS rate for physics. */
|
||||
int m_physics_fps;
|
||||
|
||||
|
||||
public:
|
||||
STKConfig();
|
||||
~STKConfig();
|
||||
void init_defaults ();
|
||||
void getAllData (const XMLNode * root);
|
||||
void load (const std::string &filename);
|
||||
STKConfig();
|
||||
~STKConfig();
|
||||
void init_defaults();
|
||||
void getAllData(const XMLNode * root);
|
||||
void load(const std::string &filename);
|
||||
const std::string &getMainMenuPicture(int n);
|
||||
const std::string &getBackgroundPicture(int n);
|
||||
|
||||
void getAllScores(std::vector<int> *all_scores, int num_karts);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the default kart properties for each kart. */
|
||||
const KartProperties &
|
||||
getDefaultKartProperties() const {return *m_default_kart_properties; }
|
||||
getDefaultKartProperties() const { return *m_default_kart_properties; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the kart properties for a certain type of kart.
|
||||
@ -210,6 +214,15 @@ public:
|
||||
{
|
||||
return *m_kart_properties.at(type);
|
||||
} // getKartProperties
|
||||
// ------------------------------------------------------------------------
|
||||
/** Converts a tick value (in physics time step size) into seconds. */
|
||||
float ticks2Time(int ticks) { return float(ticks)/m_physics_fps; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Converts a time value into ticks (of physics time steps). */
|
||||
int time2Ticks(float t) { return int(t * m_physics_fps); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the physics frame per seconds rate. */
|
||||
int getPhysicsFPS() const { return m_physics_fps; }
|
||||
}
|
||||
; // STKConfig
|
||||
|
||||
|
@ -167,8 +167,8 @@ void Camera::setupCamera()
|
||||
m_aspect = (float)((float)(m_viewport.getWidth()) / (float)(m_viewport.getHeight()));
|
||||
|
||||
m_scaling = core::vector2df(
|
||||
irr_driver->getActualScreenSize().Width / m_viewport.getWidth() ,
|
||||
irr_driver->getActualScreenSize().Height / m_viewport.getHeight());
|
||||
float(irr_driver->getActualScreenSize().Width) / m_viewport.getWidth() ,
|
||||
float(irr_driver->getActualScreenSize().Height) / m_viewport.getHeight());
|
||||
|
||||
m_fov = DEGREE_TO_RAD * stk_config->m_camera_fov
|
||||
[race_manager->getNumLocalPlayers() > 0 ?
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "graphics/material.hpp"
|
||||
@ -31,14 +32,15 @@
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
|
||||
const float burst_time = 0.1f;
|
||||
|
||||
/** Creates an explosion effect. */
|
||||
Explosion::Explosion(const Vec3& coord, const char* explosion_sound, const char * particle_file)
|
||||
: HitSFX(coord, explosion_sound)
|
||||
{
|
||||
// short emision time, explosion, not constant flame
|
||||
m_remaining_time = burst_time;
|
||||
|
||||
m_explosion_ticks = stk_config->time2Ticks(2.0f);
|
||||
m_remaining_ticks = stk_config->time2Ticks(0.1f);
|
||||
m_emission_frames = 0;
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
@ -84,22 +86,22 @@ Explosion::~Explosion()
|
||||
* \param dt Time step size.
|
||||
* \return true If the explosion is finished.
|
||||
*/
|
||||
bool Explosion::updateAndDelete(float dt)
|
||||
bool Explosion::updateAndDelete(int ticks)
|
||||
{
|
||||
// The explosion sfx is shorter than the particle effect,
|
||||
// so no need to save the result of the update call.
|
||||
HitSFX::updateAndDelete(dt);
|
||||
HitSFX::updateAndDelete(ticks);
|
||||
|
||||
m_emission_frames++;
|
||||
m_remaining_time -= dt;
|
||||
m_remaining_ticks -= ticks;
|
||||
|
||||
// Do nothing more if the animation is still playing
|
||||
if (m_remaining_time>0) return false;
|
||||
if (m_remaining_ticks>0) return false;
|
||||
|
||||
// Otherwise check that the sfx has finished, otherwise the
|
||||
// sfx will get aborted 'in the middle' when this explosion
|
||||
// object is removed.
|
||||
if (m_remaining_time > -explosion_time)
|
||||
if (m_remaining_ticks > -m_explosion_ticks)
|
||||
{
|
||||
#ifndef SERVER_ONLY
|
||||
// if framerate is very low, emit for at least a few frames, in case
|
||||
@ -122,3 +124,4 @@ bool Explosion::updateAndDelete(float dt)
|
||||
|
||||
return false; // not finished
|
||||
} // updateAndDelete
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define HEADER_EXPLOSION_HPP
|
||||
|
||||
#include "graphics/hit_sfx.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
namespace irr
|
||||
@ -33,23 +34,26 @@ class Vec3;
|
||||
class SFXBase;
|
||||
class ParticleEmitter;
|
||||
|
||||
const float explosion_time = 2.0f;
|
||||
|
||||
/**
|
||||
* \ingroup graphics
|
||||
*/
|
||||
class Explosion : public HitSFX
|
||||
{
|
||||
private:
|
||||
float m_remaining_time;
|
||||
int m_remaining_ticks;
|
||||
int m_emission_frames;
|
||||
ParticleEmitter* m_emitter;
|
||||
int m_explosion_ticks;
|
||||
|
||||
|
||||
public:
|
||||
Explosion(const Vec3& coord, const char* explosion_sound, const char * particle_file );
|
||||
~Explosion();
|
||||
bool updateAndDelete(float delta_t);
|
||||
bool hasEnded () { return m_remaining_time <= -explosion_time; }
|
||||
bool updateAndDelete(int ticks) OVERRIDE;
|
||||
bool hasEnded ()
|
||||
{
|
||||
return m_remaining_ticks <= -m_explosion_ticks;
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
/** Updates a hit effect. Called once per frame.
|
||||
* \param dt Time step size.
|
||||
* \return True if the hit effect is finished and can be removed. */
|
||||
virtual bool updateAndDelete(float dt) = 0;
|
||||
virtual bool updateAndDelete(int ticks) = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that this SFX affects a player kart, which can be used to
|
||||
|
@ -61,7 +61,7 @@ void HitSFX::setLocalPlayerKartHit()
|
||||
* \param dt Time step size.
|
||||
* \return true If the explosion is finished.
|
||||
*/
|
||||
bool HitSFX::updateAndDelete(float dt)
|
||||
bool HitSFX::updateAndDelete(int ticks)
|
||||
{
|
||||
SFXBase::SFXStatus status = m_sfx->getStatus();
|
||||
return status!= SFXBase::SFX_PLAYING;
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
public:
|
||||
HitSFX(const Vec3& coord, const char* explosion_sound);
|
||||
~HitSFX();
|
||||
virtual bool updateAndDelete(float dt) OVERRIDE;
|
||||
virtual bool updateAndDelete(int ticks) OVERRIDE;
|
||||
virtual void setLocalPlayerKartHit() OVERRIDE;
|
||||
|
||||
}; // HitSFX
|
||||
|
@ -152,7 +152,9 @@ Material::Material(const XMLNode *node, bool deprecated)
|
||||
node->get("ignore", &m_ignore );
|
||||
|
||||
node->get("max-speed", &m_max_speed_fraction );
|
||||
node->get("slowdown-time", &m_slowdown_time );
|
||||
float f = stk_config->ticks2Time(m_slowdown_ticks);
|
||||
node->get("slowdown-time", &f );
|
||||
m_slowdown_ticks = stk_config->time2Ticks(f);
|
||||
node->get("colorizable", &m_colorizable );
|
||||
node->get("colorization-factor", &m_colorization_factor);
|
||||
node->get("hue-settings", &m_hue_settings );
|
||||
@ -484,7 +486,7 @@ void Material::init()
|
||||
m_colorization_factor = 0.0f;
|
||||
m_colorization_mask = "";
|
||||
m_max_speed_fraction = 1.0f;
|
||||
m_slowdown_time = 1.0f;
|
||||
m_slowdown_ticks = stk_config->time2Ticks(1.0f);
|
||||
m_sfx_name = "";
|
||||
m_sfx_min_speed = 0.0f;
|
||||
m_sfx_max_speed = 30;
|
||||
|
@ -155,7 +155,7 @@ private:
|
||||
RandomGenerator m_random_hue;
|
||||
|
||||
/** How much the top speed is reduced per second. */
|
||||
float m_slowdown_time;
|
||||
int m_slowdown_ticks;
|
||||
|
||||
/** Maximum speed at which no more slow down occurs. */
|
||||
float m_max_speed_fraction;
|
||||
@ -287,7 +287,7 @@ public:
|
||||
/** Returns how long it will take for a slowdown to take effect.
|
||||
* It is the time it takes till the full slowdown applies to
|
||||
* karts. So a short time will slowdown a kart much faster. */
|
||||
float getSlowDownTime() const { return m_slowdown_time; }
|
||||
int getSlowDownTicks() const { return m_slowdown_ticks; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if this material is under some other mesh and therefore
|
||||
* requires another raycast to find the surface it is under (used for
|
||||
|
@ -63,7 +63,7 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
|
||||
}
|
||||
#endif
|
||||
|
||||
m_slipstream_time = 0.0f;
|
||||
m_slipstream_ticks = 0;
|
||||
|
||||
float length = m_kart->getKartProperties()->getSlipstreamLength();
|
||||
float kw = m_kart->getKartWidth();
|
||||
@ -122,8 +122,8 @@ SlipStream::~SlipStream()
|
||||
/** Called at re-start of a race. */
|
||||
void SlipStream::reset()
|
||||
{
|
||||
m_slipstream_mode = SS_NONE;
|
||||
m_slipstream_time = 0;
|
||||
m_slipstream_mode = SS_NONE;
|
||||
m_slipstream_ticks = 0;
|
||||
|
||||
// Reset a potential max speed increase
|
||||
m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, 0, 0, 0, 0);
|
||||
@ -188,7 +188,7 @@ SP::SPMesh* SlipStream::createMesh(Material* material)
|
||||
("custom_alpha", [this](SP::SPUniformAssigner* ua)->void
|
||||
{
|
||||
// In sp shader it's assigned reverse by 1.0 - custom_alpha
|
||||
ua->setValue(1.0f - m_slipstream_time);
|
||||
ua->setValue(1.0f - stk_config->ticks2Time(m_slipstream_ticks));
|
||||
});
|
||||
|
||||
std::vector<uint16_t> indices;
|
||||
@ -289,8 +289,8 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart)
|
||||
*/
|
||||
bool SlipStream::isSlipstreamReady() const
|
||||
{
|
||||
return m_slipstream_time>
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTime();
|
||||
return m_slipstream_ticks>
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTicks();
|
||||
} // isSlipstreamReady
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -309,7 +309,7 @@ void SlipStream::updateSlipstreamPower()
|
||||
kp->getSlipstreamMaxSpeedIncrease(),
|
||||
kp->getSlipstreamAddPower(),
|
||||
kp->getSlipstreamDuration(),
|
||||
kp->getSlipstreamFadeOutTime());
|
||||
kp->getSlipstreamFadeOutTicks());
|
||||
}
|
||||
} // upateSlipstreamPower
|
||||
|
||||
@ -341,7 +341,7 @@ void SlipStream::setDebugColor(const video::SColor &color)
|
||||
/** Update, called once per timestep.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void SlipStream::update(float dt)
|
||||
void SlipStream::update(int ticks)
|
||||
{
|
||||
const KartProperties *kp = m_kart->getKartProperties();
|
||||
|
||||
@ -350,12 +350,12 @@ void SlipStream::update(float dt)
|
||||
|| m_kart->isGhostKart())
|
||||
return;
|
||||
|
||||
MovingTexture::update(dt);
|
||||
MovingTexture::update(stk_config->ticks2Time(ticks));
|
||||
|
||||
if(m_slipstream_mode==SS_USE)
|
||||
{
|
||||
m_slipstream_time -= dt;
|
||||
if(m_slipstream_time<0) m_slipstream_mode=SS_NONE;
|
||||
m_slipstream_ticks -= ticks;
|
||||
if(m_slipstream_ticks<0) m_slipstream_mode=SS_NONE;
|
||||
}
|
||||
|
||||
updateSlipstreamPower();
|
||||
@ -463,28 +463,33 @@ void SlipStream::update(float dt)
|
||||
{
|
||||
m_slipstream_mode = SS_USE;
|
||||
m_kart->handleZipper();
|
||||
m_slipstream_time = kp->getSlipstreamCollectTime();
|
||||
m_slipstream_ticks = kp->getSlipstreamCollectTicks();
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_slipstream_time -=dt;
|
||||
if(m_slipstream_time<0) m_slipstream_mode = SS_NONE;
|
||||
m_slipstream_ticks -= ticks;
|
||||
if(m_slipstream_ticks<0) m_slipstream_mode = SS_NONE;
|
||||
setIntensity(0, NULL);
|
||||
return;
|
||||
} // if !is_sstreaming
|
||||
|
||||
if(UserConfigParams::m_slipstream_debug &&
|
||||
m_kart->getController()->isLocalPlayerController())
|
||||
m_target_kart->getSlipstream()->setDebugColor(video::SColor(255, 0, 255, 0));
|
||||
m_target_kart->getSlipstream()
|
||||
->setDebugColor(video::SColor(255, 0, 255, 0));
|
||||
// Accumulate slipstream credits now
|
||||
m_slipstream_time = m_slipstream_mode==SS_NONE ? dt
|
||||
: m_slipstream_time+dt;
|
||||
|
||||
if (m_slipstream_mode == SS_NONE)
|
||||
m_slipstream_ticks = ticks;
|
||||
else
|
||||
m_slipstream_ticks += ticks;
|
||||
|
||||
if(isSlipstreamReady())
|
||||
m_kart->setSlipstreamEffect(9.0f);
|
||||
setIntensity(m_slipstream_time, m_target_kart);
|
||||
setIntensity(stk_config->ticks2Time(m_slipstream_ticks), m_target_kart);
|
||||
|
||||
m_slipstream_mode = SS_COLLECT;
|
||||
if (m_slipstream_time > kp->getSlipstreamCollectTime())
|
||||
if (m_slipstream_ticks > kp->getSlipstreamCollectTicks())
|
||||
{
|
||||
setIntensity(1.0f, m_target_kart);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
float m_length;
|
||||
|
||||
/** The time a kart was in slipstream. */
|
||||
float m_slipstream_time;
|
||||
int m_slipstream_ticks;
|
||||
|
||||
/** Slipstream mode: either nothing happening, or the kart is collecting
|
||||
* 'slipstream credits', or the kart is using accumulated credits. */
|
||||
@ -80,7 +80,7 @@ public:
|
||||
SlipStream (AbstractKart* kart);
|
||||
virtual ~SlipStream ();
|
||||
void reset();
|
||||
virtual void update(float dt);
|
||||
virtual void update(int ticks);
|
||||
void setIntensity(float f, const AbstractKart* kart);
|
||||
void updateSlipstreamPower();
|
||||
bool isSlipstreamReady() const;
|
||||
|
@ -921,7 +921,7 @@ SColorf GetPlayerColor(int player_id)
|
||||
SColorf color_rgb = { 0,0,0,1 };
|
||||
|
||||
|
||||
col.Saturation = col.Saturation * (1.0F / (floor(player_id / 4) + 1) );
|
||||
col.Saturation = col.Saturation * (1.0f / (floorf(float(player_id / 4)) + 1) );
|
||||
col.toRGB(color_rgb);
|
||||
return color_rgb;
|
||||
}
|
||||
@ -1161,9 +1161,9 @@ void Skin::drawRibbonChild(const core::recti &rect, Widget* widget,
|
||||
|
||||
SColorf color_rgb = GetPlayerColor(i);
|
||||
|
||||
parentRibbonWidget->m_skin_r = color_rgb.r * 255.0F;
|
||||
parentRibbonWidget->m_skin_g = color_rgb.g * 255.0F;
|
||||
parentRibbonWidget->m_skin_b = color_rgb.b * 255.0F;
|
||||
parentRibbonWidget->m_skin_r = short(color_rgb.r * 255.0f);
|
||||
parentRibbonWidget->m_skin_g = short(color_rgb.g * 255.0f);
|
||||
parentRibbonWidget->m_skin_b = short(color_rgb.b * 255.0f);
|
||||
|
||||
if (nPlayersOnThisItem > 0)
|
||||
{
|
||||
@ -1270,9 +1270,9 @@ void Skin::drawSpinnerBody(const core::recti &rect, Widget* widget,
|
||||
{
|
||||
params=&SkinConfig::m_render_params["spinner::neutral"];
|
||||
}
|
||||
widget->m_skin_r = color_rgb.r * 255.0f;
|
||||
widget->m_skin_g = color_rgb.g * 255.0f;
|
||||
widget->m_skin_b = color_rgb.b * 255.0f;
|
||||
widget->m_skin_r = short(color_rgb.r * 255.0f);
|
||||
widget->m_skin_g = short(color_rgb.g * 255.0f);
|
||||
widget->m_skin_b = short(color_rgb.b * 255.0f);
|
||||
|
||||
for (int i = 1; i < MAX_PLAYER_COUNT + 1; i++)
|
||||
{
|
||||
|
@ -28,9 +28,10 @@
|
||||
#include "guiengine/screen_keyboard.hpp"
|
||||
#include "input/device_manager.hpp"
|
||||
#include "input/gamepad_device.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/keyboard_device.hpp"
|
||||
#include "input/multitouch_device.hpp"
|
||||
#include "input/input.hpp"
|
||||
#include "input/wiimote_manager.hpp"
|
||||
#include "karts/controller/controller.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "modes/demo_world.hpp"
|
||||
@ -86,6 +87,10 @@ InputManager::InputManager() : m_mode(BOOTSTRAP),
|
||||
// -----------------------------------------------------------------------------
|
||||
void InputManager::update(float dt)
|
||||
{
|
||||
#ifdef ENABLE_WIIUSE
|
||||
wiimote_manager->update();
|
||||
#endif
|
||||
|
||||
if(m_timer_in_use)
|
||||
{
|
||||
m_timer -= dt;
|
||||
@ -292,14 +297,14 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
case IRR_KEY_F11:
|
||||
if(value && shift_is_pressed && world && RewindManager::isEnabled())
|
||||
{
|
||||
printf("Enter rewind to time:");
|
||||
printf("Enter rewind to time in ticks:");
|
||||
char s[256];
|
||||
fgets(s, 256, stdin);
|
||||
float t;
|
||||
int t;
|
||||
StringUtils::fromString(s,t);
|
||||
RewindManager::get()->rewindTo(t);
|
||||
Log::info("Rewind", "Rewinding from %f to %f",
|
||||
world->getTime(), t);
|
||||
Log::info("Rewind", "Rewinding from %d to %d",
|
||||
world->getTimeTicks(), t);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -49,7 +49,7 @@ Attachment::Attachment(AbstractKart* kart)
|
||||
: EventRewinder()
|
||||
{
|
||||
m_type = ATTACH_NOTHING;
|
||||
m_time_left = 0.0;
|
||||
m_ticks_left = 0;
|
||||
m_plugin = NULL;
|
||||
m_kart = kart;
|
||||
m_previous_owner = NULL;
|
||||
@ -103,7 +103,7 @@ Attachment::~Attachment()
|
||||
* can be passed back to the previous owner). NULL if a no
|
||||
* previous owner exists.
|
||||
*/
|
||||
void Attachment::set(AttachmentType type, float time,
|
||||
void Attachment::set(AttachmentType type, int ticks,
|
||||
AbstractKart *current_kart)
|
||||
{
|
||||
bool was_bomb = (m_type == ATTACH_BOMB);
|
||||
@ -162,7 +162,7 @@ void Attachment::set(AttachmentType type, float time,
|
||||
m_node->setScale(core::vector3df(m_node_scale,m_node_scale,m_node_scale));
|
||||
|
||||
m_type = type;
|
||||
m_time_left = time;
|
||||
m_ticks_left = ticks;
|
||||
m_previous_owner = current_kart;
|
||||
m_node->setRotation(core::vector3df(0, 0, 0));
|
||||
|
||||
@ -188,7 +188,7 @@ void Attachment::set(AttachmentType type, float time,
|
||||
|
||||
speed_mult = 1.0f + (f * (temp_mult - 1.0f));
|
||||
|
||||
m_time_left = m_time_left * speed_mult;
|
||||
m_ticks_left = int(m_ticks_left * speed_mult);
|
||||
|
||||
if (UserConfigParams::m_particles_effects > 1)
|
||||
{
|
||||
@ -230,7 +230,7 @@ void Attachment::clear()
|
||||
|
||||
m_type=ATTACH_NOTHING;
|
||||
|
||||
m_time_left=0.0;
|
||||
m_ticks_left = 0;
|
||||
m_node->setVisible(false);
|
||||
m_node->setPosition(core::vector3df());
|
||||
m_node->setRotation(core::vector3df());
|
||||
@ -254,7 +254,7 @@ void Attachment::saveState(BareNetworkString *buffer) const
|
||||
buffer->addUInt8(type);
|
||||
if(m_type!=ATTACH_NOTHING)
|
||||
{
|
||||
buffer->addFloat(m_time_left);
|
||||
buffer->addUInt32(m_ticks_left);
|
||||
if(m_type==ATTACH_BOMB && m_previous_owner)
|
||||
buffer->addUInt8(m_previous_owner->getWorldKartId());
|
||||
// m_initial_speed is not saved, on restore state it will
|
||||
@ -284,13 +284,13 @@ void Attachment::rewindTo(BareNetworkString *buffer)
|
||||
return;
|
||||
}
|
||||
|
||||
float time_left = buffer->getFloat();
|
||||
int ticks_left = buffer->getUInt32();
|
||||
|
||||
// Attaching an object can be expensive (loading new models, ...)
|
||||
// so avoid doing this if there is no change in attachment type
|
||||
if(new_type == m_type)
|
||||
{
|
||||
setTimeLeft(time_left);
|
||||
setTicksLeft(ticks_left);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -305,7 +305,7 @@ void Attachment::rewindTo(BareNetworkString *buffer)
|
||||
{
|
||||
m_previous_owner = NULL;
|
||||
}
|
||||
set(new_type, time_left, m_previous_owner);
|
||||
set(new_type, ticks_left, m_previous_owner);
|
||||
} // rewindTo
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Called when going forwards in time during a rewind.
|
||||
@ -333,11 +333,11 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
if(m_type == ATTACH_BUBBLEGUM_SHIELD ||
|
||||
m_type == ATTACH_NOLOK_BUBBLEGUM_SHIELD)
|
||||
{
|
||||
m_time_left = 0.0f;
|
||||
m_ticks_left = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
float leftover_time = 0.0f;
|
||||
int leftover_ticks = 0;
|
||||
|
||||
bool add_a_new_item = true;
|
||||
|
||||
@ -366,19 +366,20 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
// default time. This is necessary to avoid that a kart lands on the
|
||||
// same banana again once the explosion animation is finished, giving
|
||||
// the kart the same penalty twice.
|
||||
float f = std::max(item->getDisableTime(), kp->getExplosionDuration() + 2.0f);
|
||||
item->setDisableTime(f);
|
||||
int ticks = std::max(item->getDisableTicks(),
|
||||
stk_config->time2Ticks(kp->getExplosionDuration() + 2.0f));
|
||||
item->setDisableTicks(ticks);
|
||||
break;
|
||||
}
|
||||
case ATTACH_ANVIL:
|
||||
// if the kart already has an anvil, attach a new anvil,
|
||||
// and increase the overall time
|
||||
new_attachment = 1;
|
||||
leftover_time = m_time_left;
|
||||
leftover_ticks = m_ticks_left;
|
||||
break;
|
||||
case ATTACH_PARACHUTE:
|
||||
new_attachment = 0;
|
||||
leftover_time = m_time_left;
|
||||
leftover_ticks = m_ticks_left;
|
||||
break;
|
||||
default:
|
||||
// There is no attachment currently, but there will be one
|
||||
@ -399,7 +400,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
switch (new_attachment)
|
||||
{
|
||||
case 0:
|
||||
set(ATTACH_PARACHUTE, kp->getParachuteDuration() + leftover_time);
|
||||
set(ATTACH_PARACHUTE, kp->getParachuteDuration() + leftover_ticks);
|
||||
m_initial_speed = m_kart->getSpeed();
|
||||
|
||||
// if going very slowly or backwards,
|
||||
@ -407,7 +408,8 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
if(m_initial_speed <= 1.5) m_initial_speed = 1.5;
|
||||
break ;
|
||||
case 1:
|
||||
set(ATTACH_ANVIL, kp->getAnvilDuration() + leftover_time);
|
||||
set(ATTACH_ANVIL, stk_config->time2Ticks(kp->getAnvilDuration())
|
||||
+ leftover_ticks );
|
||||
// if ( m_kart == m_kart[0] )
|
||||
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
||||
// Reduce speed once (see description above), all other changes are
|
||||
@ -416,10 +418,9 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
m_kart->updateWeight();
|
||||
break ;
|
||||
case 2:
|
||||
set( ATTACH_BOMB, stk_config->m_bomb_time+leftover_time);
|
||||
set( ATTACH_BOMB, stk_config->time2Ticks(stk_config->m_bomb_time)
|
||||
+ leftover_ticks );
|
||||
|
||||
// if ( m_kart == m_kart[0] )
|
||||
// sound -> playSfx ( SOUND_SHOOMF ) ;
|
||||
break ;
|
||||
} // switch
|
||||
}
|
||||
@ -446,8 +447,8 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
|
||||
// If both karts have a bomb, explode them immediately:
|
||||
if(attachment_other->getType()==Attachment::ATTACH_BOMB)
|
||||
{
|
||||
setTimeLeft(0.0f);
|
||||
attachment_other->setTimeLeft(0.0f);
|
||||
setTicksLeft(0);
|
||||
attachment_other->setTicksLeft(0);
|
||||
}
|
||||
else // only this kart has a bomb, move it to the other
|
||||
{
|
||||
@ -455,10 +456,11 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
|
||||
if (getPreviousOwner() != other || World::getWorld()->getNumKarts() <= 2)
|
||||
{
|
||||
// Don't move if this bomb was from other kart originally
|
||||
other->getAttachment()->set(ATTACH_BOMB,
|
||||
getTimeLeft()+
|
||||
stk_config->m_bomb_time_increase,
|
||||
m_kart);
|
||||
other->getAttachment()
|
||||
->set(ATTACH_BOMB,
|
||||
getTicksLeft()+stk_config->time2Ticks(
|
||||
stk_config->m_bomb_time_increase),
|
||||
m_kart);
|
||||
other->playCustomSFX(SFXManager::CUSTOM_ATTACH);
|
||||
clear();
|
||||
}
|
||||
@ -473,8 +475,10 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
|
||||
m_kart->decreaseShieldTime();
|
||||
return;
|
||||
}
|
||||
set(ATTACH_BOMB, other->getAttachment()->getTimeLeft()+
|
||||
stk_config->m_bomb_time_increase, other);
|
||||
set(ATTACH_BOMB,
|
||||
other->getAttachment()->getTicksLeft()+
|
||||
stk_config->time2Ticks(stk_config->m_bomb_time_increase),
|
||||
other);
|
||||
other->getAttachment()->clear();
|
||||
m_kart->playCustomSFX(SFXManager::CUSTOM_ATTACH);
|
||||
}
|
||||
@ -487,7 +491,7 @@ void Attachment::handleCollisionWithKart(AbstractKart *other)
|
||||
} // handleCollisionWithKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Attachment::update(float dt)
|
||||
void Attachment::update(int ticks)
|
||||
{
|
||||
if(m_type==ATTACH_NOTHING) return;
|
||||
|
||||
@ -496,7 +500,7 @@ void Attachment::update(float dt)
|
||||
if (m_type == ATTACH_BOMB && m_kart->getKartAnimation() != NULL)
|
||||
return;
|
||||
|
||||
m_time_left -=dt;
|
||||
m_ticks_left -= ticks;
|
||||
|
||||
|
||||
bool is_shield = m_type == ATTACH_BUBBLEGUM_SHIELD ||
|
||||
@ -504,22 +508,26 @@ void Attachment::update(float dt)
|
||||
float m_wanted_node_scale = is_shield
|
||||
? std::max(1.0f, m_kart->getHighestPoint()*1.1f)
|
||||
: 1.0f;
|
||||
int slow_flashes = 3;
|
||||
if (is_shield && m_time_left < slow_flashes)
|
||||
int slow_flashes = stk_config->time2Ticks(3.0f);
|
||||
if (is_shield && m_ticks_left < slow_flashes)
|
||||
{
|
||||
int flashes_per_second = 4;
|
||||
int divisor = 2;
|
||||
int ticks_per_flash = stk_config->time2Ticks(0.25f);
|
||||
|
||||
float fast_flashes = 0.5F;
|
||||
if (m_time_left < fast_flashes)
|
||||
int fast_flashes = stk_config->time2Ticks(0.5f);
|
||||
if (m_ticks_left < fast_flashes)
|
||||
{
|
||||
flashes_per_second = 12;
|
||||
ticks_per_flash = stk_config->time2Ticks(1.0f/12);
|
||||
}
|
||||
|
||||
int mod = (int)(m_time_left * flashes_per_second * 2) % divisor;
|
||||
m_node->setVisible(2*mod >= divisor);
|
||||
//int divisor = 2;
|
||||
//int mod = (int)(m_ticks_left * flashes_per_second * 2) % divisor;
|
||||
int mod = m_ticks_left % ticks_per_flash;
|
||||
m_node->setVisible(mod > ticks_per_flash);
|
||||
}
|
||||
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if (m_node_scale < m_wanted_node_scale)
|
||||
{
|
||||
m_node_scale += dt*1.5f;
|
||||
@ -531,7 +539,7 @@ void Attachment::update(float dt)
|
||||
|
||||
if(m_plugin)
|
||||
{
|
||||
bool discard = m_plugin->updateAndTestFinished(dt);
|
||||
bool discard = m_plugin->updateAndTestFinished(ticks);
|
||||
if(discard)
|
||||
{
|
||||
clear(); // also removes the plugin
|
||||
@ -558,7 +566,7 @@ void Attachment::update(float dt)
|
||||
f * (kp->getParachuteUboundFraction()
|
||||
- kp->getParachuteLboundFraction())))
|
||||
{
|
||||
m_time_left = -1;
|
||||
m_ticks_left = -1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -576,22 +584,23 @@ void Attachment::update(float dt)
|
||||
assert(false);
|
||||
break;
|
||||
case ATTACH_BOMB:
|
||||
|
||||
{
|
||||
if (m_bomb_sound) m_bomb_sound->setPosition(m_kart->getXYZ());
|
||||
|
||||
// Mesh animation frames are 1 to 61 frames (60 steps)
|
||||
// The idea is change second by second, counterclockwise 60 to 0 secs
|
||||
// If longer times needed, it should be a surprise "oh! bomb activated!"
|
||||
if(m_time_left <= (m_node->getEndFrame() - m_node->getStartFrame()-1))
|
||||
float time_left = stk_config->ticks2Time(m_ticks_left);
|
||||
if (time_left <= (m_node->getEndFrame() - m_node->getStartFrame() - 1))
|
||||
{
|
||||
m_node->setCurrentFrame(m_node->getEndFrame()
|
||||
- m_node->getStartFrame()-1-m_time_left);
|
||||
- m_node->getStartFrame() - 1 - time_left);
|
||||
}
|
||||
if(m_time_left<=0.0)
|
||||
if (m_ticks_left <= 0)
|
||||
{
|
||||
HitEffect *he = new Explosion(m_kart->getXYZ(), "explosion",
|
||||
"explosion_bomb.xml" );
|
||||
if(m_kart->getController()->isLocalPlayerController())
|
||||
"explosion_bomb.xml");
|
||||
if (m_kart->getController()->isLocalPlayerController())
|
||||
he->setLocalPlayerKartHit();
|
||||
projectile_manager->addHitEffect(he);
|
||||
ExplosionAnimation::create(m_kart);
|
||||
@ -603,11 +612,12 @@ void Attachment::update(float dt)
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ATTACH_BUBBLEGUM_SHIELD:
|
||||
case ATTACH_NOLOK_BUBBLEGUM_SHIELD:
|
||||
if (m_time_left < 0)
|
||||
if (m_ticks_left < 0)
|
||||
{
|
||||
m_time_left = 0.0f;
|
||||
m_ticks_left = 0;
|
||||
if (m_bubble_explode_sound) m_bubble_explode_sound->deleteSFX();
|
||||
m_bubble_explode_sound =
|
||||
SFXManager::get()->createSoundSource("bubblegum_explode");
|
||||
@ -638,7 +648,7 @@ void Attachment::update(float dt)
|
||||
} // switch
|
||||
|
||||
// Detach attachment if its time is up.
|
||||
if ( m_time_left <= 0.0f)
|
||||
if ( m_ticks_left <= 0)
|
||||
clear();
|
||||
} // update
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
AbstractKart *m_kart;
|
||||
|
||||
/** Time left till attachment expires. */
|
||||
float m_time_left;
|
||||
int m_ticks_left;
|
||||
|
||||
/** For parachutes only. */
|
||||
float m_initial_speed;
|
||||
@ -112,9 +112,9 @@ public:
|
||||
~Attachment();
|
||||
void clear ();
|
||||
void hitBanana(Item *item, int new_attachment=-1);
|
||||
void update (float dt);
|
||||
void update(int ticks);
|
||||
void handleCollisionWithKart(AbstractKart *other);
|
||||
void set (AttachmentType type, float time,
|
||||
void set (AttachmentType type, int ticks,
|
||||
AbstractKart *previous_kart=NULL);
|
||||
virtual void rewind(BareNetworkString *buffer);
|
||||
void rewindTo(BareNetworkString *buffer);
|
||||
@ -122,16 +122,17 @@ public:
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the type of the attachment, but keeps the old time left value. */
|
||||
void set (AttachmentType type) { set(type, m_time_left); }
|
||||
void set (AttachmentType type) { set(type, m_ticks_left); }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the type of this attachment. */
|
||||
AttachmentType getType() const { return m_type; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how much time is left before this attachment is removed. */
|
||||
float getTimeLeft() const { return m_time_left; }
|
||||
/** Returns how much time (in ticks) is left before this attachment is
|
||||
* removed. */
|
||||
int getTicksLeft() const { return m_ticks_left; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets how long this attachment will remain attached. */
|
||||
void setTimeLeft(float t){ m_time_left = t; }
|
||||
void setTicksLeft(int t){ m_ticks_left = t; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the previous owner of this attachment, used in bombs that
|
||||
* are being passed between karts. */
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
/** Updates a plugin. This is called once each time frame. If the
|
||||
* function returns true, the attachment is discarded. */
|
||||
virtual bool updateAndTestFinished(float dt) = 0;
|
||||
virtual bool updateAndTestFinished(int ticks) = 0;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when the animation of the Attachment's node is done. */
|
||||
|
@ -76,7 +76,7 @@ Bowling::Bowling(AbstractKart *kart)
|
||||
getBody()->setCollisionFlags(flag);
|
||||
|
||||
// should not live forever, auto-destruct after 20 seconds
|
||||
m_max_lifespan = 20;
|
||||
m_max_lifespan = stk_config->time2Ticks(20);
|
||||
|
||||
m_roll_sfx = SFXManager::get()->createSoundSource("bowling_roll");
|
||||
m_roll_sfx->play();
|
||||
@ -118,9 +118,9 @@ void Bowling::init(const XMLNode &node, scene::IMesh *bowling)
|
||||
* \param dt Time step size.
|
||||
* \returns True of this object should be removed.
|
||||
*/
|
||||
bool Bowling::updateAndDelete(float dt)
|
||||
bool Bowling::updateAndDelete(int ticks)
|
||||
{
|
||||
bool can_be_deleted = Flyable::updateAndDelete(dt);
|
||||
bool can_be_deleted = Flyable::updateAndDelete(ticks);
|
||||
if(can_be_deleted)
|
||||
return true;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
Bowling(AbstractKart* kart);
|
||||
virtual ~Bowling();
|
||||
static void init(const XMLNode &node, scene::IMesh *bowling);
|
||||
virtual bool updateAndDelete(float dt);
|
||||
virtual bool updateAndDelete(int ticks);
|
||||
virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
|
||||
virtual HitEffect *getHitEffect() const;
|
||||
|
||||
|
@ -70,7 +70,7 @@ Flyable::Flyable(AbstractKart *kart, PowerupManager::PowerupType type,
|
||||
m_animation = NULL;
|
||||
m_mass = mass;
|
||||
m_adjust_up_velocity = true;
|
||||
m_time_since_thrown = 0;
|
||||
m_ticks_since_thrown = 0;
|
||||
m_position_offset = Vec3(0,0,0);
|
||||
m_owner_has_temporary_immunity = true;
|
||||
m_do_terrain_info = true;
|
||||
@ -377,17 +377,17 @@ void Flyable::setAnimation(AbstractKartAnimation *animation)
|
||||
* \param dt Time step size.
|
||||
* \returns True if this object can be deleted.
|
||||
*/
|
||||
bool Flyable::updateAndDelete(float dt)
|
||||
bool Flyable::updateAndDelete(int ticks)
|
||||
{
|
||||
if (hasAnimation())
|
||||
{
|
||||
m_animation->update(dt);
|
||||
Moveable::update(dt);
|
||||
m_animation->update(stk_config->ticks2Time(ticks));
|
||||
Moveable::update(ticks);
|
||||
return false;
|
||||
} // if animation
|
||||
|
||||
m_time_since_thrown += dt;
|
||||
if(m_max_lifespan > -1 && m_time_since_thrown > m_max_lifespan)
|
||||
m_ticks_since_thrown += ticks;
|
||||
if(m_max_lifespan > -1 && m_ticks_since_thrown > m_max_lifespan)
|
||||
hit(NULL);
|
||||
|
||||
if(m_has_hit_something) return true;
|
||||
@ -465,7 +465,7 @@ bool Flyable::updateAndDelete(float dt)
|
||||
setVelocity(v);
|
||||
} // if m_adjust_up_velocity
|
||||
|
||||
Moveable::update(dt);
|
||||
Moveable::update(ticks);
|
||||
|
||||
return false;
|
||||
} // updateAndDelete
|
||||
@ -478,8 +478,8 @@ bool Flyable::updateAndDelete(float dt)
|
||||
bool Flyable::isOwnerImmunity(const AbstractKart* kart_hit) const
|
||||
{
|
||||
return m_owner_has_temporary_immunity &&
|
||||
kart_hit == m_owner &&
|
||||
m_time_since_thrown < 2.0f;
|
||||
kart_hit == m_owner &&
|
||||
m_ticks_since_thrown < stk_config->time2Ticks(2.0f);
|
||||
} // isOwnerImmunity
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -127,11 +127,11 @@ protected:
|
||||
|
||||
/** Time since thrown. used so a kart can't hit himself when trying
|
||||
* something, and also to put some time limit to some collectibles */
|
||||
float m_time_since_thrown;
|
||||
int m_ticks_since_thrown;
|
||||
|
||||
/** Set to something > -1 if this flyable should auto-destrcut after
|
||||
* a while. */
|
||||
float m_max_lifespan;
|
||||
* that may ticks. */
|
||||
int m_max_lifespan;
|
||||
|
||||
/** If set to true, the kart that throwns this flyable can't collide
|
||||
* with it for a short time. */
|
||||
@ -167,7 +167,7 @@ public:
|
||||
virtual ~Flyable ();
|
||||
static void init (const XMLNode &node, scene::IMesh *model,
|
||||
PowerupManager::PowerupType type);
|
||||
virtual bool updateAndDelete(float);
|
||||
virtual bool updateAndDelete(int ticks);
|
||||
virtual void setAnimation(AbstractKartAnimation *animation);
|
||||
virtual HitEffect* getHitEffect() const;
|
||||
bool isOwnerImmunity(const AbstractKart *kart_hit) const;
|
||||
|
@ -118,8 +118,8 @@ void Item::initItem(ItemType type, const Vec3 &xyz)
|
||||
m_item_id = -1;
|
||||
m_collected = false;
|
||||
m_original_type = ITEM_NONE;
|
||||
m_deactive_time = 0;
|
||||
m_time_till_return = 0.0f; // not strictly necessary, see isCollected()
|
||||
m_deactive_ticks = 0;
|
||||
m_ticks_till_return = 0; // not strictly necessary, see isCollected()
|
||||
m_emitter = NULL;
|
||||
m_rotate = (type!=ITEM_BUBBLEGUM) && (type!=ITEM_TRIGGER);
|
||||
switch(m_type)
|
||||
@ -265,8 +265,8 @@ Item::~Item()
|
||||
void Item::reset()
|
||||
{
|
||||
m_collected = false;
|
||||
m_time_till_return = 0.0f;
|
||||
m_deactive_time = 0.0f;
|
||||
m_ticks_till_return = 0;
|
||||
m_deactive_ticks = 0;
|
||||
switch(m_type)
|
||||
{
|
||||
case ITEM_BUBBLEGUM:
|
||||
@ -296,24 +296,24 @@ void Item::reset()
|
||||
*/
|
||||
void Item::setParent(AbstractKart* parent)
|
||||
{
|
||||
m_event_handler = parent;
|
||||
m_emitter = parent;
|
||||
m_deactive_time = 1.5f;
|
||||
m_event_handler = parent;
|
||||
m_emitter = parent;
|
||||
m_deactive_ticks = stk_config->time2Ticks(1.5f);
|
||||
} // setParent
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updated the item - rotates it, takes care of items coming back into
|
||||
* the game after it has been collected.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void Item::update(float dt)
|
||||
void Item::update(int ticks)
|
||||
{
|
||||
if(m_deactive_time > 0) m_deactive_time -= dt;
|
||||
if(m_deactive_ticks > 0) m_deactive_ticks -= ticks;
|
||||
|
||||
if(m_collected)
|
||||
{
|
||||
m_time_till_return -= dt;
|
||||
if(m_time_till_return<0)
|
||||
m_ticks_till_return -= ticks;
|
||||
if(m_ticks_till_return<0)
|
||||
{
|
||||
m_collected=false;
|
||||
|
||||
@ -322,13 +322,14 @@ void Item::update(float dt)
|
||||
m_node->setScale(core::vector3df(1,1,1));
|
||||
}
|
||||
} // time till return <0 --> is fully visible again
|
||||
else if ( m_time_till_return <=1.0f )
|
||||
else if ( m_ticks_till_return <= stk_config->time2Ticks(1.0f) )
|
||||
{
|
||||
if (m_node != NULL)
|
||||
{
|
||||
// Make it visible by scaling it from 0 to 1:
|
||||
m_node->setVisible(true);
|
||||
m_node->setScale(core::vector3df(1,1,1)*(1-m_time_till_return));
|
||||
float t = stk_config->ticks2Time(m_ticks_till_return);
|
||||
m_node->setScale(core::vector3df(1,1,1)*(1-t));
|
||||
}
|
||||
} // time till return < 1
|
||||
} // if collected
|
||||
@ -337,8 +338,11 @@ void Item::update(float dt)
|
||||
|
||||
if(!m_rotate || m_node == NULL) return;
|
||||
// have it rotate
|
||||
if(!RewindManager::get()->isRewinding())
|
||||
if (!RewindManager::get()->isRewinding())
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
m_rotation_angle += dt * M_PI;
|
||||
}
|
||||
if (m_rotation_angle > M_PI * 2) m_rotation_angle -= M_PI * 2;
|
||||
|
||||
btMatrix3x3 m;
|
||||
@ -364,7 +368,7 @@ void Item::collected(const AbstractKart *kart, float t)
|
||||
m_event_handler = kart;
|
||||
if(m_type==ITEM_EASTER_EGG)
|
||||
{
|
||||
m_time_till_return=99999;
|
||||
m_ticks_till_return=stk_config->time2Ticks(99999);
|
||||
EasterEggHunt *world = dynamic_cast<EasterEggHunt*>(World::getWorld());
|
||||
assert(world);
|
||||
world->collectedEasterEgg(kart);
|
||||
@ -379,16 +383,16 @@ void Item::collected(const AbstractKart *kart, float t)
|
||||
// Deactivates the item for a certain amount of time. It is used to
|
||||
// prevent bubble gum from hitting a kart over and over again (in each
|
||||
// frame) by giving it time to drive away.
|
||||
m_deactive_time = 0.5f;
|
||||
m_deactive_ticks = stk_config->time2Ticks(0.5f);
|
||||
// Set the time till reappear to -1 seconds --> the item will
|
||||
// reappear immediately.
|
||||
m_time_till_return = -1;
|
||||
m_ticks_till_return = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Note if the time is negative, in update the m_collected flag will
|
||||
// be automatically set to false again.
|
||||
m_time_till_return = t;
|
||||
m_ticks_till_return = stk_config->time2Ticks(t);
|
||||
if (m_node != NULL)
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
@ -402,7 +406,7 @@ void Item::collected(const AbstractKart *kart, float t)
|
||||
|
||||
if (dynamic_cast<ThreeStrikesBattle*>(World::getWorld()) != NULL)
|
||||
{
|
||||
m_time_till_return *= 3;
|
||||
m_ticks_till_return *= 3;
|
||||
}
|
||||
} // isCollected
|
||||
|
||||
|
@ -111,7 +111,7 @@ private:
|
||||
bool m_collected;
|
||||
|
||||
/** Time till a collected item reappears. */
|
||||
float m_time_till_return;
|
||||
int m_ticks_till_return;
|
||||
|
||||
/** Scene node of this item. */
|
||||
LODNode *m_node;
|
||||
@ -131,7 +131,7 @@ private:
|
||||
bool m_rotate;
|
||||
|
||||
/** Optionally set this if this item was laid by a particular kart. in
|
||||
* this case the 'm_deactive_time' will also be set - see below. */
|
||||
* this case the 'm_deactive_ticks' will also be set - see below. */
|
||||
const AbstractKart *m_event_handler;
|
||||
|
||||
/** Kart that emitted this item if any */
|
||||
@ -139,7 +139,7 @@ private:
|
||||
|
||||
/** Optionally if item was placed by a kart, a timer can be used to
|
||||
* temporarly deactivate collision so a kart is not hit by its own item */
|
||||
float m_deactive_time;
|
||||
int m_deactive_ticks;
|
||||
|
||||
/** Counts how often an item is used before it disappears. Used for
|
||||
* bubble gum to make them disappear after a while. A value >0
|
||||
@ -176,7 +176,7 @@ public:
|
||||
Item(const Vec3& xyz, float distance,
|
||||
TriggerItemListener* trigger);
|
||||
virtual ~Item ();
|
||||
void update (float delta);
|
||||
void update(int ticks);
|
||||
virtual void collected(const AbstractKart *kart, float t=2.0f);
|
||||
void setParent(AbstractKart* parent);
|
||||
void reset();
|
||||
@ -195,7 +195,7 @@ public:
|
||||
*/
|
||||
bool hitKart(const Vec3 &xyz, const AbstractKart *kart=NULL) const
|
||||
{
|
||||
if (m_event_handler == kart && m_deactive_time > 0)
|
||||
if (m_event_handler == kart && m_deactive_ticks > 0)
|
||||
return false;
|
||||
Vec3 lc = quatRotate(m_original_rotation, xyz - m_xyz);
|
||||
// Don't be too strict if the kart is a bit above the item
|
||||
@ -216,7 +216,7 @@ protected:
|
||||
bool hitLine(const core::line3df &line,
|
||||
const AbstractKart *kart=NULL) const
|
||||
{
|
||||
if(m_event_handler==kart && m_deactive_time >0) return false;
|
||||
if(m_event_handler==kart && m_deactive_ticks >0) return false;
|
||||
|
||||
Vec3 closest = line.getClosestPoint(m_xyz.toIrrVector());
|
||||
return hitKart(closest, kart);
|
||||
@ -251,10 +251,10 @@ public:
|
||||
* details.
|
||||
* \param f Time till the item can be used again.
|
||||
*/
|
||||
void setDisableTime(float f) { m_time_till_return = f; }
|
||||
void setDisableTicks(int t) { m_ticks_till_return = t; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time the item is disabled for. */
|
||||
float getDisableTime() const { return m_time_till_return; }
|
||||
int getDisableTicks() const { return m_ticks_till_return; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the XYZ position of the item. */
|
||||
const Vec3& getXYZ() const { return m_xyz; }
|
||||
|
@ -156,7 +156,7 @@ void ItemManager::removeTextures()
|
||||
* of each race. */
|
||||
ItemManager::ItemManager()
|
||||
{
|
||||
m_switch_time = -1.0f;
|
||||
m_switch_ticks = -1;
|
||||
// The actual loading is done in loadDefaultItems
|
||||
|
||||
// Prepare the switch to array, which stores which item should be
|
||||
@ -266,7 +266,7 @@ Item* ItemManager::newItem(Item::ItemType type, const Vec3& xyz,
|
||||
|
||||
insertItem(item);
|
||||
if(parent != NULL) item->setParent(parent);
|
||||
if(m_switch_time>=0)
|
||||
if(m_switch_ticks>=0)
|
||||
{
|
||||
Item::ItemType new_type = m_switch_to[item->getType()];
|
||||
item->switchTo(new_type, m_item_mesh[(int)new_type],
|
||||
@ -354,14 +354,14 @@ void ItemManager::checkItemHit(AbstractKart* kart)
|
||||
void ItemManager::reset()
|
||||
{
|
||||
// If items are switched, switch them back first.
|
||||
if(m_switch_time>=0)
|
||||
if(m_switch_ticks>=0)
|
||||
{
|
||||
for(AllItemTypes::iterator i =m_all_items.begin();
|
||||
i!=m_all_items.end(); i++)
|
||||
{
|
||||
if(*i) (*i)->switchBack();
|
||||
}
|
||||
m_switch_time = -1.0f;
|
||||
m_switch_ticks = -1;
|
||||
|
||||
}
|
||||
|
||||
@ -388,36 +388,36 @@ void ItemManager::reset()
|
||||
}
|
||||
} // whilem_all_items.end() i
|
||||
|
||||
m_switch_time = -1;
|
||||
m_switch_ticks = -1;
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates all items, and handles switching items back if the switch time
|
||||
* is over.
|
||||
* \param dt Time step.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void ItemManager::update(float dt)
|
||||
void ItemManager::update(int ticks)
|
||||
{
|
||||
// If switch time is over, switch all items back
|
||||
if(m_switch_time>=0)
|
||||
if(m_switch_ticks>=0)
|
||||
{
|
||||
m_switch_time -= dt;
|
||||
if(m_switch_time<0)
|
||||
m_switch_ticks -= ticks;
|
||||
if(m_switch_ticks<0)
|
||||
{
|
||||
for(AllItemTypes::iterator i =m_all_items.begin();
|
||||
i!=m_all_items.end(); i++)
|
||||
{
|
||||
if(*i) (*i)->switchBack();
|
||||
} // for m_all_items
|
||||
} // m_switch_time < 0
|
||||
} // m_switch_time>=0
|
||||
} // m_switch_ticks < 0
|
||||
} // m_switch_ticks>=0
|
||||
|
||||
for(AllItemTypes::iterator i =m_all_items.begin();
|
||||
i!=m_all_items.end(); i++)
|
||||
{
|
||||
if(*i)
|
||||
{
|
||||
(*i)->update(dt);
|
||||
(*i)->update(ticks);
|
||||
if( (*i)->isUsedUp())
|
||||
{
|
||||
deleteItem( *i );
|
||||
@ -472,16 +472,16 @@ void ItemManager::switchItems()
|
||||
|
||||
Item::ItemType new_type = m_switch_to[(*i)->getType()];
|
||||
|
||||
if(m_switch_time<0)
|
||||
if(m_switch_ticks<0)
|
||||
(*i)->switchTo(new_type, m_item_mesh[(int)new_type], m_item_lowres_mesh[(int)new_type]);
|
||||
else
|
||||
(*i)->switchBack();
|
||||
} // for m_all_items
|
||||
|
||||
// if the items are already switched (m_switch_time >=0)
|
||||
// then switch back, and set m_switch_time to -1 to indicate
|
||||
// if the items are already switched (m_switch_ticks >=0)
|
||||
// then switch back, and set m_switch_ticks to -1 to indicate
|
||||
// that the items are now back to normal.
|
||||
m_switch_time = m_switch_time < 0 ? stk_config->m_item_switch_time : -1;
|
||||
m_switch_ticks = m_switch_ticks < 0 ? stk_config->m_item_switch_ticks : -1;
|
||||
|
||||
} // switchItems
|
||||
|
||||
|
@ -90,7 +90,7 @@ private:
|
||||
|
||||
/** Remaining time that items should remain switched. If the
|
||||
* value is <0, it indicates that the items are not switched atm. */
|
||||
float m_switch_time;
|
||||
int m_switch_ticks;
|
||||
|
||||
void insertItem(Item *item);
|
||||
void deleteItem(Item *item);
|
||||
@ -106,7 +106,7 @@ public:
|
||||
AbstractKart* parent=NULL);
|
||||
Item* newItem (const Vec3& xyz, float distance,
|
||||
TriggerItemListener* listener);
|
||||
void update (float delta);
|
||||
void update (int ticks);
|
||||
void checkItemHit (AbstractKart* kart);
|
||||
void reset ();
|
||||
void collectedItem (Item *item, AbstractKart *kart,
|
||||
|
@ -122,24 +122,24 @@ void Plunger::init(const XMLNode &node, scene::IMesh *plunger_model)
|
||||
* \param dt Time step size.
|
||||
* \returns True of this object should be removed.
|
||||
*/
|
||||
bool Plunger::updateAndDelete(float dt)
|
||||
bool Plunger::updateAndDelete(int ticks)
|
||||
{
|
||||
// In keep-alive mode, just update the rubber band
|
||||
if(m_keep_alive >= 0)
|
||||
{
|
||||
m_keep_alive -= dt;
|
||||
m_keep_alive -= ticks;
|
||||
if(m_keep_alive<=0)
|
||||
{
|
||||
setHasHit();
|
||||
return true;
|
||||
}
|
||||
if(m_rubber_band != NULL) m_rubber_band->update(dt);
|
||||
if(m_rubber_band != NULL) m_rubber_band->update(ticks);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Else: update the flyable and rubber band
|
||||
bool ret = Flyable::updateAndDelete(dt);
|
||||
if(m_rubber_band != NULL) m_rubber_band->update(dt);
|
||||
bool ret = Flyable::updateAndDelete(ticks);
|
||||
if(m_rubber_band != NULL) m_rubber_band->update(ticks);
|
||||
|
||||
return ret;
|
||||
|
||||
@ -179,11 +179,12 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_keep_alive = m_owner->getKartProperties()->getPlungerBandDuration();
|
||||
m_keep_alive = stk_config->time2Ticks(m_owner->getKartProperties()
|
||||
->getPlungerBandDuration() );
|
||||
|
||||
// Make this object invisible by placing it faaar down. Not that if this
|
||||
// objects is simply removed from the scene graph, it might be auto-deleted
|
||||
// because the ref count reaches zero.
|
||||
// Make this object invisible by placing it faaar down. Not that if
|
||||
// this objects is simply removed from the scene graph, it might be
|
||||
// auto-deleted because the ref count reaches zero.
|
||||
scene::ISceneNode *node = getNode();
|
||||
if(node)
|
||||
{
|
||||
|
@ -40,8 +40,10 @@ class Plunger : public Flyable
|
||||
private:
|
||||
/** The rubber band attached to a plunger. */
|
||||
RubberBand *m_rubber_band;
|
||||
/** Timer to keep the plunger alive while the rubber band is working. */
|
||||
float m_keep_alive;
|
||||
|
||||
/** Ticks to keep the plunger alive while the rubber band is working. */
|
||||
int m_keep_alive;
|
||||
|
||||
btVector3 m_initial_velocity;
|
||||
|
||||
bool m_reverse_mode;
|
||||
@ -49,7 +51,7 @@ public:
|
||||
Plunger(AbstractKart *kart);
|
||||
~Plunger();
|
||||
static void init(const XMLNode &node, scene::IMesh* missile);
|
||||
virtual bool updateAndDelete(float dt);
|
||||
virtual bool updateAndDelete(int ticks);
|
||||
virtual void hitTrack ();
|
||||
virtual bool hit (AbstractKart *kart, PhysicalObject *obj=NULL);
|
||||
|
||||
@ -57,7 +59,7 @@ public:
|
||||
/** Sets the keep-alive value. Setting it to 0 will remove the plunger
|
||||
* at the next update - which is used if the rubber band snaps.
|
||||
*/
|
||||
void setKeepAlive(float t) {m_keep_alive = t;}
|
||||
void setKeepAlive(int ticks) {m_keep_alive = ticks;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** No hit effect when it ends. */
|
||||
virtual HitEffect *getHitEffect() const {return NULL; }
|
||||
|
@ -267,7 +267,8 @@ void Powerup::use()
|
||||
|
||||
case PowerupManager::POWERUP_SWATTER:
|
||||
m_kart->getAttachment()
|
||||
->set(Attachment::ATTACH_SWATTER, kp->getSwatterDuration());
|
||||
->set(Attachment::ATTACH_SWATTER,
|
||||
stk_config->time2Ticks(kp->getSwatterDuration()));
|
||||
break;
|
||||
|
||||
case PowerupManager::POWERUP_BUBBLEGUM:
|
||||
@ -302,26 +303,35 @@ void Powerup::use()
|
||||
{
|
||||
if (m_kart->getIdent() == "nolok")
|
||||
{
|
||||
m_kart->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||
kp->getBubblegumShieldDuration());
|
||||
m_kart->getAttachment()
|
||||
->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||
stk_config->
|
||||
time2Ticks(kp->getBubblegumShieldDuration()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_kart->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
||||
kp->getBubblegumShieldDuration());
|
||||
m_kart->getAttachment()
|
||||
->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
||||
stk_config->
|
||||
time2Ticks(kp->getBubblegumShieldDuration()));
|
||||
}
|
||||
}
|
||||
else // using a bubble gum while still having a shield
|
||||
{
|
||||
if (m_kart->getIdent() == "nolok")
|
||||
{
|
||||
m_kart->getAttachment()->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||
kp->getBubblegumShieldDuration() + m_kart->getShieldTime());
|
||||
m_kart->getAttachment()
|
||||
->set(Attachment::ATTACH_NOLOK_BUBBLEGUM_SHIELD,
|
||||
stk_config->
|
||||
time2Ticks(kp->getBubblegumShieldDuration()));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_kart->getAttachment()->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
||||
kp->getBubblegumShieldDuration() + m_kart->getShieldTime());
|
||||
m_kart->getAttachment()
|
||||
->set(Attachment::ATTACH_BUBBLEGUM_SHIELD,
|
||||
stk_config->
|
||||
time2Ticks(kp->getBubblegumShieldDuration()
|
||||
+ m_kart->getShieldTime() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,7 +360,8 @@ void Powerup::use()
|
||||
if(kart->getPosition() == 1)
|
||||
{
|
||||
kart->getAttachment()->set(Attachment::ATTACH_ANVIL,
|
||||
kp->getAnvilDuration());
|
||||
stk_config->
|
||||
time2Ticks(kp->getAnvilDuration()) );
|
||||
kart->updateWeight();
|
||||
kart->adjustSpeed(kp->getAnvilSpeedFactor() * 0.5f);
|
||||
|
||||
@ -397,14 +408,17 @@ void Powerup::use()
|
||||
{
|
||||
float rank_factor;
|
||||
|
||||
rank_factor = (float)(kart->getPosition() - 1) / (float)(m_kart->getPosition() - 2);
|
||||
rank_factor = (float)(kart->getPosition() - 1)
|
||||
/ (float)(m_kart->getPosition() - 2);
|
||||
position_factor = 1.0f - rank_factor;
|
||||
}
|
||||
|
||||
rank_mult = 1 + (position_factor * (kp->getParachuteDurationRankMult() - 1));
|
||||
rank_mult = 1 + (position_factor *
|
||||
(kp->getParachuteDurationRankMult() - 1));
|
||||
|
||||
kart->getAttachment()->set(Attachment::ATTACH_PARACHUTE,
|
||||
(kp->getParachuteDurationOther() * rank_mult));
|
||||
kart->getAttachment()
|
||||
->set(Attachment::ATTACH_PARACHUTE,
|
||||
int(kp->getParachuteDurationOther()*rank_mult) );
|
||||
|
||||
if(kart->getController()->isLocalPlayerController())
|
||||
player_kart = kart;
|
||||
@ -464,7 +478,7 @@ void Powerup::hitBonusBox(const Item &item, int add_info)
|
||||
// Check if rubber ball is the current power up held by the kart. If so,
|
||||
// reset the bBallCollectTime to 0 before giving new powerup.
|
||||
if(m_type == PowerupManager::POWERUP_RUBBERBALL)
|
||||
powerup_manager->setBallCollectTime(0);
|
||||
powerup_manager->setBallCollectTicks(0);
|
||||
|
||||
// Check if two bouncing balls are collected less than getRubberBallTimer()
|
||||
//seconds apart. If yes, then call getRandomPowerup again. If no, then break.
|
||||
@ -474,8 +488,8 @@ void Powerup::hitBonusBox(const Item &item, int add_info)
|
||||
{
|
||||
new_powerup = powerup_manager->getRandomPowerup(position, &n);
|
||||
if(new_powerup != PowerupManager::POWERUP_RUBBERBALL ||
|
||||
( World::getWorld()->getTimeSinceStart() - powerup_manager->getBallCollectTime()) >
|
||||
RubberBall::getTimeBetweenRubberBalls() )
|
||||
( World::getWorld()->getTicksSinceStart() - powerup_manager->getBallCollectTicks()) >
|
||||
RubberBall::getTicksBetweenRubberBalls() )
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -486,7 +500,7 @@ void Powerup::hitBonusBox(const Item &item, int add_info)
|
||||
}
|
||||
|
||||
if(new_powerup == PowerupManager::POWERUP_RUBBERBALL)
|
||||
powerup_manager->setBallCollectTime(World::getWorld()->getTime());
|
||||
powerup_manager->setBallCollectTicks(World::getWorld()->getTimeTicks());
|
||||
|
||||
// Always add a new powerup in ITEM_MODE_NEW (or if the kart
|
||||
// doesn't have a powerup atm).
|
||||
|
@ -113,7 +113,7 @@ private:
|
||||
float m_all_max_turn_angle[POWERUP_MAX];
|
||||
|
||||
/** Last time the bouncing ball was collected */
|
||||
float m_rubber_ball_collect_time;
|
||||
int m_rubber_ball_collect_ticks;
|
||||
|
||||
public:
|
||||
/** The mesh for each model (if the powerup has a model), e.g. a switch
|
||||
@ -165,8 +165,8 @@ public:
|
||||
float getMaxTurnAngle (int type) const {return m_all_max_turn_angle[type];}
|
||||
const btVector3&
|
||||
getExtend (int type) const {return m_all_extends[type];}
|
||||
float getBallCollectTime() const {return m_rubber_ball_collect_time;}
|
||||
void setBallCollectTime(float time) {m_rubber_ball_collect_time=time;}
|
||||
int getBallCollectTicks() const {return m_rubber_ball_collect_ticks;}
|
||||
void setBallCollectTicks(int ticks) {m_rubber_ball_collect_ticks=ticks;}
|
||||
|
||||
};
|
||||
|
||||
|
@ -63,9 +63,9 @@ void ProjectileManager::cleanup()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** General projectile update call. */
|
||||
void ProjectileManager::update(float dt)
|
||||
void ProjectileManager::update(int ticks)
|
||||
{
|
||||
updateServer(dt);
|
||||
updateServer(ticks);
|
||||
|
||||
HitEffects::iterator he = m_active_hit_effects.begin();
|
||||
while(he!=m_active_hit_effects.end())
|
||||
@ -77,7 +77,7 @@ void ProjectileManager::update(float dt)
|
||||
he = next;
|
||||
}
|
||||
// Update this hit effect. If it can be removed, remove it.
|
||||
else if((*he)->updateAndDelete(dt))
|
||||
else if((*he)->updateAndDelete(ticks))
|
||||
{
|
||||
delete *he;
|
||||
HitEffects::iterator next = m_active_hit_effects.erase(he);
|
||||
@ -90,12 +90,12 @@ void ProjectileManager::update(float dt)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Updates all rockets on the server (or no networking). */
|
||||
void ProjectileManager::updateServer(float dt)
|
||||
void ProjectileManager::updateServer(int ticks)
|
||||
{
|
||||
Projectiles::iterator p = m_active_projectiles.begin();
|
||||
while(p!=m_active_projectiles.end())
|
||||
{
|
||||
bool can_be_deleted = (*p)->updateAndDelete(dt);
|
||||
bool can_be_deleted = (*p)->updateAndDelete(ticks);
|
||||
if(can_be_deleted)
|
||||
{
|
||||
HitEffect *he = (*p)->getHitEffect();
|
||||
|
@ -52,13 +52,13 @@ private:
|
||||
* being shown or have a sfx playing. */
|
||||
HitEffects m_active_hit_effects;
|
||||
|
||||
void updateServer(float dt);
|
||||
void updateServer(int ticks);
|
||||
public:
|
||||
ProjectileManager() {}
|
||||
~ProjectileManager() {}
|
||||
void loadData ();
|
||||
void cleanup ();
|
||||
void update (float dt);
|
||||
void update (int ticks);
|
||||
Flyable* newProjectile (AbstractKart *kart,
|
||||
PowerupManager::PowerupType type);
|
||||
void Deactivate (Flyable *p) {}
|
||||
|
@ -42,12 +42,12 @@ float RubberBall::m_st_squash_duration;
|
||||
float RubberBall::m_st_squash_slowdown;
|
||||
float RubberBall::m_st_target_distance;
|
||||
float RubberBall::m_st_target_max_angle;
|
||||
float RubberBall::m_st_delete_time;
|
||||
int RubberBall::m_st_delete_ticks;
|
||||
float RubberBall::m_st_max_height_difference;
|
||||
float RubberBall::m_st_fast_ping_distance;
|
||||
float RubberBall::m_st_early_target_factor;
|
||||
int RubberBall::m_next_id = 0;
|
||||
float RubberBall::m_time_between_balls;
|
||||
int RubberBall::m_ticks_between_balls;
|
||||
|
||||
|
||||
// Debug only, so that we can get a feel on how well balls are aiming etc.
|
||||
@ -75,7 +75,7 @@ RubberBall::RubberBall(AbstractKart *kart)
|
||||
|
||||
// Do not adjust the up velocity
|
||||
setAdjustUpVelocity(false);
|
||||
m_max_lifespan = 9999;
|
||||
m_max_lifespan = stk_config->time2Ticks(9999);
|
||||
m_target = NULL;
|
||||
m_aiming_at_target = false;
|
||||
m_fast_ping = false;
|
||||
@ -89,7 +89,7 @@ RubberBall::RubberBall(AbstractKart *kart)
|
||||
m_previous_xyz = m_owner->getXYZ();
|
||||
m_previous_height = 2.0f; //
|
||||
// A negative value indicates that the timer is not active
|
||||
m_delete_timer = -1.0f;
|
||||
m_delete_ticks = -1;
|
||||
m_tunnel_count = 0;
|
||||
|
||||
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||
@ -173,13 +173,13 @@ void RubberBall::computeTarget()
|
||||
{
|
||||
// If the firing kart itself is the first kart (that is
|
||||
// still driving), prepare to remove the rubber ball
|
||||
if(m_target==m_owner && m_delete_timer < 0)
|
||||
if(m_target==m_owner && m_delete_ticks < 0)
|
||||
{
|
||||
#ifdef PRINT_BALL_REMOVE_INFO
|
||||
Log::debug("[RubberBall]",
|
||||
"ball %d removed because owner is target.", m_id);
|
||||
#endif
|
||||
m_delete_timer = m_st_delete_time;
|
||||
m_delete_ticks = m_st_delete_ticks;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -192,7 +192,7 @@ void RubberBall::computeTarget()
|
||||
Log::debug("[RubberBall]" "ball %d removed because no more active target.",
|
||||
m_id);
|
||||
#endif
|
||||
m_delete_timer = m_st_delete_time;
|
||||
m_delete_ticks = m_st_delete_ticks;
|
||||
m_target = m_owner;
|
||||
} // computeTarget
|
||||
|
||||
@ -268,11 +268,11 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
|
||||
m_st_min_interpolation_distance = 30.0f;
|
||||
m_st_target_distance = 50.0f;
|
||||
m_st_target_max_angle = 25.0f;
|
||||
m_st_delete_time = 10.0f;
|
||||
m_st_delete_ticks = stk_config->time2Ticks(10.0f);
|
||||
m_st_max_height_difference = 10.0f;
|
||||
m_st_fast_ping_distance = 50.0f;
|
||||
m_st_early_target_factor = 1.0f;
|
||||
m_time_between_balls = 15;
|
||||
m_ticks_between_balls = stk_config->time2Ticks(15.0f);
|
||||
|
||||
if(!node.get("interval", &m_st_interval))
|
||||
Log::warn("powerup", "No interval specified for rubber ball.");
|
||||
@ -288,8 +288,10 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
|
||||
if(!node.get("target-distance", &m_st_target_distance))
|
||||
Log::warn("powerup",
|
||||
"No target-distance specified for rubber ball.");
|
||||
if(!node.get("delete-time", &m_st_delete_time))
|
||||
float f;
|
||||
if(!node.get("delete-time", &f))
|
||||
Log::warn("powerup", "No delete-time specified for rubber ball.");
|
||||
m_st_delete_ticks = stk_config->time2Ticks(f);
|
||||
if(!node.get("target-max-angle", &m_st_target_max_angle))
|
||||
Log::warn("powerup", "No target-max-angle specified for rubber ball.");
|
||||
m_st_target_max_angle *= DEGREE_TO_RAD;
|
||||
@ -306,9 +308,10 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
|
||||
if(!node.get("early-target-factor", &m_st_early_target_factor))
|
||||
Log::warn("powerup",
|
||||
"No early-target-factor specified for rubber ball.");
|
||||
if(!node.get("time-between-balls", &m_time_between_balls))
|
||||
if(!node.get("time-between-balls", &m_ticks_between_balls))
|
||||
Log::warn("powerup",
|
||||
"No time-between-balls specified for rubber ball.");
|
||||
m_ticks_between_balls = stk_config->time2Ticks(float(m_ticks_between_balls));
|
||||
Flyable::init(node, rubberball, PowerupManager::POWERUP_RUBBERBALL);
|
||||
} // init
|
||||
|
||||
@ -317,17 +320,17 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *rubberball)
|
||||
* \param dt Time step size.
|
||||
* \returns True if the rubber ball should be removed.
|
||||
*/
|
||||
bool RubberBall::updateAndDelete(float dt)
|
||||
bool RubberBall::updateAndDelete(int ticks)
|
||||
{
|
||||
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||
// FIXME: what does the rubber ball do in case of battle mode??
|
||||
if(!world) return true;
|
||||
|
||||
|
||||
if(m_delete_timer>0)
|
||||
if(m_delete_ticks>0)
|
||||
{
|
||||
m_delete_timer -= dt;
|
||||
if(m_delete_timer<=0)
|
||||
m_delete_ticks -= 1;
|
||||
if(m_delete_ticks<=0)
|
||||
{
|
||||
hit(NULL);
|
||||
#ifdef PRINT_BALL_REMOVE_INFO
|
||||
@ -342,7 +345,7 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
// Flyable will call update() of the animation to
|
||||
// update the ball's position.
|
||||
m_previous_xyz = getXYZ();
|
||||
return Flyable::updateAndDelete(dt);
|
||||
return Flyable::updateAndDelete(ticks);
|
||||
}
|
||||
|
||||
// Update the target in case that the first kart was overtaken (or has
|
||||
@ -354,9 +357,9 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
// since it still needs to be adjusted for the height of the terrain.
|
||||
Vec3 next_xyz;
|
||||
if(m_aiming_at_target)
|
||||
moveTowardsTarget(&next_xyz, dt);
|
||||
moveTowardsTarget(&next_xyz, ticks);
|
||||
else
|
||||
interpolate(&next_xyz, dt);
|
||||
interpolate(&next_xyz, ticks);
|
||||
|
||||
// If the ball is close to the ground, we have to start the raycast
|
||||
// slightly higher (to avoid that the ball tunnels through the floor).
|
||||
@ -373,7 +376,7 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
// Flyable::update for rubber balls.
|
||||
TerrainInfo::update(next_xyz + getNormal()*vertical_offset, -getNormal());
|
||||
|
||||
m_height_timer += dt;
|
||||
m_height_timer += stk_config->ticks2Time(ticks);
|
||||
float height = updateHeight()+m_extend.getY()*0.5f;
|
||||
|
||||
if(UserConfigParams::logFlyable())
|
||||
@ -425,7 +428,7 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
// Determine new distance along track
|
||||
TrackSector::update(next_xyz);
|
||||
|
||||
return Flyable::updateAndDelete(dt);
|
||||
return Flyable::updateAndDelete(ticks);
|
||||
} // updateAndDelete
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -433,9 +436,9 @@ bool RubberBall::updateAndDelete(float dt)
|
||||
* once the rubber ball is close to its target. It restricts the angle by
|
||||
* which the rubber ball can change its direction per frame.
|
||||
* \param next_xyz The position the ball should move to.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics steps - should be 1.
|
||||
*/
|
||||
void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
|
||||
void RubberBall::moveTowardsTarget(Vec3 *next_xyz, int ticks)
|
||||
{
|
||||
// If the rubber ball is already close to a target, i.e. aiming
|
||||
// at it directly, stop interpolating, instead fly straight
|
||||
@ -446,7 +449,11 @@ void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
|
||||
if(diff.length2()==0)
|
||||
*next_xyz = getXYZ() - getNormal()*m_previous_height;
|
||||
else
|
||||
*next_xyz = getXYZ() - getNormal()*m_previous_height +(dt*m_speed / diff.length())*diff;
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
*next_xyz = getXYZ() - getNormal()*m_previous_height
|
||||
+ (dt*m_speed / diff.length())*diff;
|
||||
}
|
||||
|
||||
// If ball is close to the target, then explode
|
||||
if (diff.length() < m_target->getKartLength())
|
||||
@ -466,10 +473,11 @@ void RubberBall::moveTowardsTarget(Vec3 *next_xyz, float dt)
|
||||
* \param next_xyz Returns the new position.
|
||||
* \param The time step size.
|
||||
*/
|
||||
void RubberBall::interpolate(Vec3 *next_xyz, float dt)
|
||||
void RubberBall::interpolate(Vec3 *next_xyz, int ticks)
|
||||
{
|
||||
// If we have reached or overshot the next control point, move to the
|
||||
// the next section of the spline
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
m_t += m_t_increase * dt;
|
||||
if(m_t > 1.0f)
|
||||
{
|
||||
@ -672,7 +680,7 @@ void RubberBall::updateDistanceToTarget()
|
||||
// original target, and start deleting it.
|
||||
if(m_distance_to_target > 0.9f * Track::getCurrentTrack()->getTrackLength())
|
||||
{
|
||||
m_delete_timer = m_st_delete_time;
|
||||
m_delete_ticks = m_st_delete_ticks;
|
||||
#ifdef PRINT_BALL_REMOVE_INFO
|
||||
Log::debug("[RubberBall]", "ball %d lost target (overtook?).",
|
||||
m_id);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "items/flyable.hpp"
|
||||
#include "tracks/track_sector.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
|
||||
class AbstractKart;
|
||||
class SFXBase;
|
||||
@ -79,12 +80,12 @@ private:
|
||||
/** If the ball overtakes its target or starts to aim at the kart which
|
||||
* originally shot the rubber ball, after this amount of time the
|
||||
* ball will be deleted. */
|
||||
static float m_st_delete_time;
|
||||
static int m_st_delete_ticks;
|
||||
|
||||
/** Timer before another rubber ball can be picked up. This is to ensure
|
||||
* that there are not too many rubber balls on the track in races with many
|
||||
* karts. */
|
||||
static float m_time_between_balls;
|
||||
static int m_ticks_between_balls;
|
||||
|
||||
/** This factor is used to influence how much the rubber ball should aim
|
||||
* at its target early. It used the 'distance to center of track' of its
|
||||
@ -166,7 +167,7 @@ private:
|
||||
* originally shot the rubber ball, after a certain amount of time the
|
||||
* ball will be deleted. This timer tracks this time. If it is < 0
|
||||
* it indicates that the ball is targeting another kart atm. */
|
||||
float m_delete_timer;
|
||||
int m_delete_ticks;
|
||||
|
||||
/** The current maximum height of the ball. This value will be
|
||||
* reduced if the ball gets closer to the target. */
|
||||
@ -192,8 +193,8 @@ private:
|
||||
float *f=NULL);
|
||||
void getNextControlPoint();
|
||||
float updateHeight();
|
||||
void interpolate(Vec3 *next_xyz, float dt);
|
||||
void moveTowardsTarget(Vec3 *next_xyz, float dt);
|
||||
void interpolate(Vec3 *next_xyz, int ticks);
|
||||
void moveTowardsTarget(Vec3 *next_xyz, int ticks);
|
||||
void initializeControlPoints(const Vec3 &xyz);
|
||||
float getTunnelHeight(const Vec3 &next_xyz,
|
||||
const float vertical_offset) const;
|
||||
@ -202,10 +203,13 @@ public:
|
||||
RubberBall (AbstractKart* kart);
|
||||
virtual ~RubberBall();
|
||||
static void init(const XMLNode &node, scene::IMesh *rubberball);
|
||||
virtual bool updateAndDelete(float dt);
|
||||
virtual bool updateAndDelete(int ticks) OVERRIDE;
|
||||
virtual bool hit(AbstractKart* kart, PhysicalObject* obj=NULL);
|
||||
virtual void setAnimation(AbstractKartAnimation *animation);
|
||||
static float getTimeBetweenRubberBalls() {return m_time_between_balls;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns time (in ticks) between rubberballs, to avoid that in games
|
||||
* with many karts too many rubber balls are in play at the same time. */
|
||||
static int getTicksBetweenRubberBalls() { return m_ticks_between_balls; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** This object does not create an explosion, all affects on
|
||||
* karts are handled by this hit() function. */
|
||||
|
@ -146,7 +146,7 @@ void RubberBand::updatePosition()
|
||||
* so, an explosion is triggered.
|
||||
* \param dt: Time step size.
|
||||
*/
|
||||
void RubberBand::update(float dt)
|
||||
void RubberBand::update(int ticks)
|
||||
{
|
||||
const KartProperties *kp = m_owner->getKartProperties();
|
||||
|
||||
@ -155,7 +155,7 @@ void RubberBand::update(float dt)
|
||||
// Rubber band snaps
|
||||
m_plunger->hit(NULL);
|
||||
// This causes the plunger to be removed at the next update
|
||||
m_plunger->setKeepAlive(0.0f);
|
||||
m_plunger->setKeepAlive(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,7 +171,7 @@ void RubberBand::update(float dt)
|
||||
// Rubber band snaps
|
||||
m_plunger->hit(NULL);
|
||||
// This causes the plunger to be removed at the next update
|
||||
m_plunger->setKeepAlive(0.0f);
|
||||
m_plunger->setKeepAlive(0);
|
||||
}
|
||||
|
||||
// Apply forces (if applicable)
|
||||
@ -187,7 +187,7 @@ void RubberBand::update(float dt)
|
||||
// Rubber band snaps
|
||||
m_plunger->hit(NULL);
|
||||
// This causes the plunger to be removed at the next update
|
||||
m_plunger->setKeepAlive(0.0f);
|
||||
m_plunger->setKeepAlive(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -196,8 +196,8 @@ void RubberBand::update(float dt)
|
||||
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
|
||||
kp->getPlungerBandSpeedIncrease(),
|
||||
/*engine_force*/ 0.0f,
|
||||
/*duration*/0.1f,
|
||||
kp->getPlungerBandFadeOutTime());
|
||||
/*duration*/stk_config->time2Ticks(0.1f),
|
||||
kp->getPlungerBandFadeOutTicks());
|
||||
if(m_attached_state==RB_TO_KART)
|
||||
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
|
||||
}
|
||||
@ -260,7 +260,7 @@ void RubberBand::hit(AbstractKart *kart_hit, const Vec3 *track_xyz)
|
||||
if(kart_hit->isShielded())
|
||||
{
|
||||
kart_hit->decreaseShieldTime();
|
||||
m_plunger->setKeepAlive(0.0f);
|
||||
m_plunger->setKeepAlive(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
public:
|
||||
RubberBand(Plunger *plunger, AbstractKart *kart);
|
||||
~RubberBand();
|
||||
void update(float dt);
|
||||
void update(int ticks);
|
||||
void hit(AbstractKart *kart_hit, const Vec3 *track_xyz=NULL);
|
||||
}; // RubberBand
|
||||
#endif
|
||||
|
@ -114,8 +114,9 @@ Swatter::~Swatter()
|
||||
* \param dt Time step size.
|
||||
* \return True if the attachment should be discarded.
|
||||
*/
|
||||
bool Swatter::updateAndTestFinished(float dt)
|
||||
bool Swatter::updateAndTestFinished(int ticks)
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if (!m_discard_now)
|
||||
{
|
||||
if (m_removing_bomb)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "items/attachment_plugin.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/random_generator.hpp"
|
||||
|
||||
@ -79,7 +80,7 @@ public:
|
||||
Swatter(AbstractKart *kart, bool was_bomb,
|
||||
scene::ISceneNode* bomb_scene_node);
|
||||
virtual ~Swatter();
|
||||
bool updateAndTestFinished(float dt);
|
||||
bool updateAndTestFinished(int ticks) OVERRIDE;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if the swatter is currently aiming, i.e. can be used to
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "karts/abstract_characteristic.hpp"
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "utils/log.hpp"
|
||||
#include "utils/interpolation_array.hpp"
|
||||
|
||||
@ -931,7 +932,7 @@ float AbstractCharacteristic::getParachuteFriction() const
|
||||
} // getParachuteFriction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getParachuteDuration() const
|
||||
int AbstractCharacteristic::getParachuteDuration() const
|
||||
{
|
||||
float result;
|
||||
bool is_set = false;
|
||||
@ -939,11 +940,11 @@ float AbstractCharacteristic::getParachuteDuration() const
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(PARACHUTE_DURATION).c_str());
|
||||
return result;
|
||||
return stk_config->time2Ticks(result);
|
||||
} // getParachuteDuration
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getParachuteDurationOther() const
|
||||
int AbstractCharacteristic::getParachuteDurationOther() const
|
||||
{
|
||||
float result;
|
||||
bool is_set = false;
|
||||
@ -951,7 +952,7 @@ float AbstractCharacteristic::getParachuteDurationOther() const
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(PARACHUTE_DURATION_OTHER).c_str());
|
||||
return result;
|
||||
return stk_config->time2Ticks(result);
|
||||
} // getParachuteDurationOther
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1495,7 +1496,7 @@ float AbstractCharacteristic::getSlipstreamWidth() const
|
||||
} // getSlipstreamWidth
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getSlipstreamCollectTime() const
|
||||
int AbstractCharacteristic::getSlipstreamCollectTicks() const
|
||||
{
|
||||
float result;
|
||||
bool is_set = false;
|
||||
@ -1503,8 +1504,8 @@ float AbstractCharacteristic::getSlipstreamCollectTime() const
|
||||
if (!is_set)
|
||||
Log::fatal("AbstractCharacteristic", "Can't get characteristic %s",
|
||||
getName(SLIPSTREAM_COLLECT_TIME).c_str());
|
||||
return result;
|
||||
} // getSlipstreamCollectTime
|
||||
return stk_config->time2Ticks(result);
|
||||
} // getSlipstreamCollectTicks
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float AbstractCharacteristic::getSlipstreamUseTime() const
|
||||
|
@ -305,8 +305,8 @@ public:
|
||||
float getAnvilSpeedFactor() const;
|
||||
|
||||
float getParachuteFriction() const;
|
||||
float getParachuteDuration() const;
|
||||
float getParachuteDurationOther() const;
|
||||
int getParachuteDuration() const;
|
||||
int getParachuteDurationOther() const;
|
||||
float getParachuteDurationRankMult() const;
|
||||
float getParachuteDurationSpeedMult() const;
|
||||
float getParachuteLboundFraction() const;
|
||||
@ -362,7 +362,7 @@ public:
|
||||
float getSlipstreamDuration() const;
|
||||
float getSlipstreamLength() const;
|
||||
float getSlipstreamWidth() const;
|
||||
float getSlipstreamCollectTime() const;
|
||||
int getSlipstreamCollectTicks() const;
|
||||
float getSlipstreamUseTime() const;
|
||||
float getSlipstreamAddPower() const;
|
||||
float getSlipstreamMinSpeed() const;
|
||||
|
@ -253,7 +253,7 @@ public:
|
||||
virtual float getFinishTime() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart has a plunger attached to its face. */
|
||||
virtual float getBlockedByPlungerTime() const = 0;
|
||||
virtual int getBlockedByPlungerTicks() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
* the difficulty, see KartPorperties getPlungerInFaceTime. */
|
||||
@ -285,7 +285,7 @@ public:
|
||||
* category. Not pure abstract, since there is no need to implement this
|
||||
* e.g. in Ghost.
|
||||
* \param category Which category to report on. */
|
||||
virtual float getSpeedIncreaseTimeLeft(unsigned int category) const = 0;
|
||||
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets an increased maximum speed for a category.
|
||||
* \param category The category for which to set the higher maximum speed.
|
||||
@ -295,15 +295,15 @@ public:
|
||||
* \param fade_out_time How long the maximum speed will fade out linearly.
|
||||
*/
|
||||
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time) = 0;
|
||||
float engine_force, int duration,
|
||||
int fade_out_time) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Defines a slowdown, which is in fraction of top speed.
|
||||
* \param category The category for which the speed is increased.
|
||||
* \param max_speed_fraction Fraction of top speed to allow only.
|
||||
* \param fade_in_time How long till maximum speed is capped. */
|
||||
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
float fade_in_time) = 0;
|
||||
int fade_in_time) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the remaining collected energy. */
|
||||
virtual float getEnergy() const = 0;
|
||||
@ -364,7 +364,7 @@ public:
|
||||
/** Return whether nitro is being used despite the nitro button not being
|
||||
* pressed due to minimal use time requirements
|
||||
*/
|
||||
virtual float isOnMinNitroTime() const = 0;
|
||||
virtual bool isOnMinNitroTime() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the current material the kart is on. */
|
||||
virtual const Material *getMaterial() const = 0;
|
||||
@ -412,7 +412,7 @@ public:
|
||||
/** Returns if the kart is invulnerable. */
|
||||
virtual bool isInvulnerable() const = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void setInvulnerableTime(float t) = 0;
|
||||
virtual void setInvulnerableTicks(int ticks) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if the kart is protected by a shield. */
|
||||
virtual bool isShielded() const = 0;
|
||||
@ -459,8 +459,8 @@ public:
|
||||
virtual void setOnScreenText(const wchar_t *text) = 0;
|
||||
// -------------------------------------------------------------------------
|
||||
/** Counter which is used for displaying wrong way message after a delay */
|
||||
virtual float getWrongwayCounter() = 0;
|
||||
virtual void setWrongwayCounter(float counter) = 0;
|
||||
virtual int getWrongwayCounter() = 0;
|
||||
virtual void setWrongwayCounter(int counter) = 0;
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns whether this kart wins or loses. */
|
||||
virtual bool getRaceResult() const = 0;
|
||||
|
@ -48,12 +48,12 @@ AIBaseController::AIBaseController(AbstractKart *kart)
|
||||
void AIBaseController::reset()
|
||||
{
|
||||
m_stuck = false;
|
||||
m_collision_times.clear();
|
||||
m_collision_ticks.clear();
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void AIBaseController::update(float dt)
|
||||
void AIBaseController::update(int ticks)
|
||||
{
|
||||
m_stuck = false;
|
||||
}
|
||||
@ -193,7 +193,7 @@ void AIBaseController::setSteering(float angle, float dt)
|
||||
if (steer_fraction > 1.0f) steer_fraction = 1.0f;
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
{
|
||||
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
|
||||
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
|
||||
@ -237,12 +237,12 @@ void AIBaseController::crashed(const Material *m)
|
||||
// the track again if it is stuck (i.e. time for the push back plus
|
||||
// time for the AI to accelerate and hit the terrain again).
|
||||
const unsigned int NUM_COLLISION = 3;
|
||||
const float COLLISION_TIME = 1.5f;
|
||||
const int COLLISION_TICKS = stk_config->time2Ticks(3.0f);
|
||||
|
||||
float time = World::getWorld()->getTimeSinceStart();
|
||||
if(m_collision_times.size()==0)
|
||||
int ticks = World::getWorld()->getTicksSinceStart();
|
||||
if(m_collision_ticks.size()==0)
|
||||
{
|
||||
m_collision_times.push_back(time);
|
||||
m_collision_ticks.push_back(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -252,23 +252,24 @@ void AIBaseController::crashed(const Material *m)
|
||||
// collisions to happen). The time of 0.2 seconds was experimentally
|
||||
// found, typically it takes 0.5 seconds for a kart to be pushed back
|
||||
// from the terrain and accelerate to hit the same terrain again.
|
||||
if(time - m_collision_times.back() < 0.2f)
|
||||
if(5 * (ticks - m_collision_ticks.back()) < stk_config->time2Ticks(1.0f))
|
||||
return;
|
||||
|
||||
// Remove all outdated entries, i.e. entries that are older than the
|
||||
// collision time plus 1 second. Older entries must be deleted,
|
||||
// otherwise a collision that happened (say) 10 seconds ago could
|
||||
// contribute to a stuck condition.
|
||||
while(m_collision_times.size()>0 &&
|
||||
time - m_collision_times[0] > 1.0f+COLLISION_TIME)
|
||||
m_collision_times.erase(m_collision_times.begin());
|
||||
while(m_collision_ticks.size()>0 &&
|
||||
ticks - m_collision_ticks[0] > stk_config->time2Ticks(1.0f)
|
||||
+ COLLISION_TICKS )
|
||||
m_collision_ticks.erase(m_collision_ticks.begin());
|
||||
|
||||
m_collision_times.push_back(time);
|
||||
m_collision_ticks.push_back(ticks);
|
||||
|
||||
// Now detect if there are enough collision records in the
|
||||
// specified time interval.
|
||||
if(time - m_collision_times.front() > COLLISION_TIME
|
||||
&& m_collision_times.size()>=NUM_COLLISION)
|
||||
if(ticks - m_collision_ticks.front() > COLLISION_TICKS &&
|
||||
m_collision_ticks.size()>=NUM_COLLISION )
|
||||
{
|
||||
// We can't call m_kart->forceRescue here, since crased() is
|
||||
// called during physics processing, and forceRescue() removes the
|
||||
|
@ -36,7 +36,7 @@ private:
|
||||
/** Stores the last N times when a collision happened. This is used
|
||||
* to detect when the AI is stuck, i.e. N collisions happened in
|
||||
* a certain period of time. */
|
||||
std::vector<float> m_collision_times;
|
||||
std::vector<int> m_collision_ticks;
|
||||
|
||||
/** A flag that is set during the physics processing to indicate that
|
||||
* this kart is stuck and needs to be rescued. */
|
||||
@ -75,7 +75,7 @@ protected:
|
||||
// ------------------------------------------------------------------------
|
||||
void determineTurnRadius(const Vec3 &end, Vec3 *center,
|
||||
float *radius) const;
|
||||
virtual void update (float delta);
|
||||
virtual void update(int ticks);
|
||||
virtual void setSteering (float angle, float dt);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return true if AI can skid now. */
|
||||
|
@ -195,11 +195,11 @@ void AIBaseLapController::computePath()
|
||||
/** Updates the ai base controller each time step. Note that any calls to
|
||||
* isStuck() must be done before update is called, since update will call
|
||||
* AIBaseController::update() which will reset the isStuck flag!
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void AIBaseLapController::update(float dt)
|
||||
void AIBaseLapController::update(int ticks)
|
||||
{
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
if(DriveGraph::get())
|
||||
{
|
||||
// Update the current node:
|
||||
@ -252,7 +252,7 @@ float AIBaseLapController::steerToAngle(const unsigned int sector,
|
||||
//Desired angle minus current angle equals how many angles to turn
|
||||
float steer_angle = angle - m_kart->getHeading();
|
||||
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
steer_angle += add_angle*0.2f;
|
||||
else
|
||||
steer_angle += add_angle;
|
||||
|
@ -53,9 +53,9 @@ protected:
|
||||
* graph nodes. */
|
||||
std::vector<std::vector<int> > m_all_look_aheads;
|
||||
|
||||
virtual void update (float delta) ;
|
||||
virtual void update(int ticks);
|
||||
virtual unsigned int getNextSector(unsigned int index);
|
||||
virtual void newLap (int lap);
|
||||
virtual void newLap(int lap);
|
||||
//virtual void setControllerName(const std::string &name);
|
||||
|
||||
float steerToAngle (const unsigned int sector, const float angle);
|
||||
|
@ -59,8 +59,8 @@ void ArenaAI::reset()
|
||||
m_reverse_point = Vec3(0, 0, 0);
|
||||
m_time_since_last_shot = 0.0f;
|
||||
m_time_since_driving = 0.0f;
|
||||
m_time_since_off_road = 0.0f;
|
||||
m_time_since_reversing = 0.0f;
|
||||
m_ticks_since_off_road = 0;
|
||||
m_ticks_since_reversing = 0;
|
||||
m_time_since_uturn = 0.0f;
|
||||
m_turn_radius = 0.0f;
|
||||
m_steering_angle = 0.0f;
|
||||
@ -74,9 +74,9 @@ void ArenaAI::reset()
|
||||
/** This is the main entry point for the AI.
|
||||
* It is called once per frame for each AI and determines the behaviour of
|
||||
* the AI, e.g. steering, accelerating/braking, firing.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void ArenaAI::update(float dt)
|
||||
void ArenaAI::update(int ticks)
|
||||
{
|
||||
// This is used to enable firing an item backwards.
|
||||
m_controls->setLookBack(false);
|
||||
@ -96,30 +96,31 @@ void ArenaAI::update(float dt)
|
||||
|
||||
if (!isKartOnRoad() && m_kart->isOnGround())
|
||||
{
|
||||
m_time_since_off_road += dt;
|
||||
m_ticks_since_off_road += ticks;
|
||||
}
|
||||
else if (m_time_since_off_road != 0.0f)
|
||||
else if (m_ticks_since_off_road != 0)
|
||||
{
|
||||
m_time_since_off_road = 0.0f;
|
||||
m_ticks_since_off_road = 0;
|
||||
}
|
||||
|
||||
// If the kart needs to be rescued, do it now (and nothing else)
|
||||
if (m_time_since_off_road > 5.0f && m_kart->isOnGround())
|
||||
if (m_ticks_since_off_road > stk_config->time2Ticks(5.0f) &&
|
||||
m_kart->isOnGround() )
|
||||
{
|
||||
m_time_since_off_road = 0.0f;
|
||||
m_ticks_since_off_road = 0;
|
||||
new RescueAnimation(m_kart);
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isWaiting())
|
||||
{
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
checkIfStuck(dt);
|
||||
if (gettingUnstuck(dt))
|
||||
if (gettingUnstuck(ticks))
|
||||
return;
|
||||
|
||||
findTarget();
|
||||
@ -156,7 +157,7 @@ void ArenaAI::update(float dt)
|
||||
setSteering(m_steering_angle, dt);
|
||||
}
|
||||
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
|
||||
} // update
|
||||
|
||||
@ -385,22 +386,23 @@ void ArenaAI::doUTurn(const float dt)
|
||||
* \param dt Time step size.
|
||||
* \return True if getting stuck is needed to be done.
|
||||
*/
|
||||
bool ArenaAI::gettingUnstuck(const float dt)
|
||||
bool ArenaAI::gettingUnstuck(int ticks)
|
||||
{
|
||||
if (!m_is_stuck || m_is_uturn) return false;
|
||||
|
||||
resetAfterStop();
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
setSteering(0.0f, dt);
|
||||
m_controls->setBrake(true);
|
||||
|
||||
m_time_since_reversing += dt;
|
||||
m_ticks_since_reversing += ticks;
|
||||
|
||||
if (m_time_since_reversing >= 1.0f)
|
||||
if (m_ticks_since_reversing >= stk_config->time2Ticks(1.0f))
|
||||
{
|
||||
m_is_stuck = false;
|
||||
m_time_since_reversing = 0.0f;
|
||||
m_ticks_since_reversing = 0;
|
||||
}
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
return true;
|
||||
|
||||
} // gettingUnstuck
|
||||
|
@ -89,7 +89,7 @@ private:
|
||||
* until facing in front of it. */
|
||||
Vec3 m_reverse_point;
|
||||
|
||||
/** Indicates that the kart is currently stuck, and m_time_since_reversing
|
||||
/** Indicates that the kart is currently stuck, and m_ticks_since_reversing
|
||||
* is counting down. */
|
||||
bool m_is_stuck;
|
||||
|
||||
@ -105,7 +105,7 @@ private:
|
||||
float m_time_since_last_shot;
|
||||
|
||||
/** This is a timer that counts down when the kart is reversing to get unstuck. */
|
||||
float m_time_since_reversing;
|
||||
float m_ticks_since_reversing;
|
||||
|
||||
/** This is a timer that counts down when the kart is starting to drive. */
|
||||
float m_time_since_driving;
|
||||
@ -114,7 +114,7 @@ private:
|
||||
float m_time_since_uturn;
|
||||
|
||||
/** This is a timer that counts when the kart start going off road. */
|
||||
float m_time_since_off_road;
|
||||
int m_ticks_since_off_road;
|
||||
|
||||
/** Used to determine braking and nitro usage. */
|
||||
float m_turn_radius;
|
||||
@ -142,7 +142,7 @@ private:
|
||||
// ------------------------------------------------------------------------
|
||||
void doUTurn(const float dt);
|
||||
// ------------------------------------------------------------------------
|
||||
bool gettingUnstuck(const float dt);
|
||||
bool gettingUnstuck(int ticks);
|
||||
// ------------------------------------------------------------------------
|
||||
bool updateAimingPosition(Vec3* target_point);
|
||||
// ------------------------------------------------------------------------
|
||||
@ -183,11 +183,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual ~ArenaAI() {}
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void update (float delta) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void reset () OVERRIDE;
|
||||
virtual void reset() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void newLap (int lap) OVERRIDE {}
|
||||
virtual void newLap(int lap) OVERRIDE {}
|
||||
|
||||
};
|
||||
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
Controller (AbstractKart *kart);
|
||||
virtual ~Controller () {};
|
||||
virtual void reset () = 0;
|
||||
virtual void update (float dt) = 0;
|
||||
virtual void update (int ticks) = 0;
|
||||
virtual void handleZipper (bool play_sound) = 0;
|
||||
virtual void collectedItem (const Item &item, int add_info=-1,
|
||||
float previous_energy=0) = 0;
|
||||
|
@ -172,7 +172,7 @@ void EndController::action(PlayerAction action, int value)
|
||||
} // action
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void EndController::update(float dt)
|
||||
void EndController::update(int ticks)
|
||||
{
|
||||
// This is used to enable firing an item backwards.
|
||||
m_controls->setLookBack(false);
|
||||
@ -180,7 +180,7 @@ void EndController::update(float dt)
|
||||
m_controls->setBrake(false);
|
||||
m_controls->setAccel(1.0f);
|
||||
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
|
||||
// In case of battle mode: don't do anything
|
||||
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
|
||||
@ -198,6 +198,7 @@ void EndController::update(float dt)
|
||||
calcSteps();
|
||||
|
||||
/*Response handling functions*/
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
handleSteering(dt);
|
||||
handleRescue(dt);
|
||||
} // update
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
EndController(AbstractKart *kart,
|
||||
Controller *prev_controller);
|
||||
~EndController();
|
||||
virtual void update (float delta) ;
|
||||
virtual void update (int ticks) ;
|
||||
virtual void reset ();
|
||||
virtual void action (PlayerAction action, int value);
|
||||
virtual void newLap (int lap);
|
||||
|
@ -35,7 +35,7 @@ void GhostController::reset()
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void GhostController::update(float dt)
|
||||
void GhostController::update(int ticks)
|
||||
{
|
||||
m_current_time = World::getWorld()->getTime();
|
||||
// Find (if necessary) the next index to use
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
GhostController(AbstractKart *kart, core::stringw display_name);
|
||||
virtual ~GhostController() {};
|
||||
virtual void reset() OVERRIDE;
|
||||
virtual void update (float dt) OVERRIDE;
|
||||
virtual void update (int ticks) OVERRIDE;
|
||||
virtual bool disableSlipstreamBonus() const OVERRIDE { return true; }
|
||||
virtual void crashed(const Material *m) OVERRIDE {}
|
||||
virtual void crashed(const AbstractKart *k) OVERRIDE {}
|
||||
|
@ -172,7 +172,7 @@ bool LocalPlayerController::action(PlayerAction action, int value,
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Handles steering for a player kart.
|
||||
*/
|
||||
void LocalPlayerController::steer(float dt, int steer_val)
|
||||
void LocalPlayerController::steer(int ticks, int steer_val)
|
||||
{
|
||||
if(UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
@ -182,7 +182,7 @@ void LocalPlayerController::steer(float dt, int steer_val)
|
||||
m_kart, 1.0f,
|
||||
video::SColor(255, 255, 0, 255), false);
|
||||
}
|
||||
PlayerController::steer(dt, steer_val);
|
||||
PlayerController::steer(ticks, steer_val);
|
||||
|
||||
if(UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
@ -194,7 +194,7 @@ void LocalPlayerController::steer(float dt, int steer_val)
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the player kart, called once each timestep.
|
||||
*/
|
||||
void LocalPlayerController::update(float dt)
|
||||
void LocalPlayerController::update(int ticks)
|
||||
{
|
||||
if (UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
@ -203,7 +203,7 @@ void LocalPlayerController::update(float dt)
|
||||
Log::debug("LocalPlayerController", "irr_driver", "-------------------------------------");
|
||||
}
|
||||
|
||||
PlayerController::update(dt);
|
||||
PlayerController::update(ticks);
|
||||
|
||||
// look backward when the player requests or
|
||||
// if automatic reverse camera is active
|
||||
|
@ -54,13 +54,13 @@ private:
|
||||
SFXBuffer *m_grab_sound;
|
||||
SFXBuffer *m_full_sound;
|
||||
|
||||
virtual void steer(float, int) OVERRIDE;
|
||||
virtual void steer(int, int) OVERRIDE;
|
||||
virtual void displayPenaltyWarning() OVERRIDE;
|
||||
public:
|
||||
LocalPlayerController(AbstractKart *kart,
|
||||
const int local_playerID);
|
||||
~LocalPlayerController();
|
||||
void update (float) OVERRIDE;
|
||||
void update (int ticks) OVERRIDE;
|
||||
bool action (PlayerAction action, int value,
|
||||
bool dry_run=false) OVERRIDE;
|
||||
virtual void handleZipper (bool play_sound) OVERRIDE;
|
||||
|
@ -38,7 +38,7 @@
|
||||
PlayerController::PlayerController(AbstractKart *kart)
|
||||
: Controller(kart)
|
||||
{
|
||||
m_penalty_time = 0.0f;
|
||||
m_penalty_ticks = 0;
|
||||
} // PlayerController
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -53,13 +53,13 @@ PlayerController::~PlayerController()
|
||||
*/
|
||||
void PlayerController::reset()
|
||||
{
|
||||
m_steer_val_l = 0;
|
||||
m_steer_val_r = 0;
|
||||
m_steer_val = 0;
|
||||
m_prev_brake = 0;
|
||||
m_prev_accel = 0;
|
||||
m_prev_nitro = false;
|
||||
m_penalty_time = 0;
|
||||
m_steer_val_l = 0;
|
||||
m_steer_val_r = 0;
|
||||
m_steer_val = 0;
|
||||
m_prev_brake = 0;
|
||||
m_prev_accel = 0;
|
||||
m_prev_nitro = false;
|
||||
m_penalty_ticks = 0;
|
||||
} // reset
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -167,7 +167,7 @@ bool PlayerController::action(PlayerAction action, int value, bool dry_run)
|
||||
break;
|
||||
case PA_ACCEL:
|
||||
SET_OR_TEST(m_prev_accel, value);
|
||||
if (value && !(m_penalty_time > 0.0f))
|
||||
if (value && !(m_penalty_ticks > 0))
|
||||
{
|
||||
SET_OR_TEST_GETTER(Accel, value/32768.0f);
|
||||
SET_OR_TEST_GETTER(Brake, false);
|
||||
@ -249,7 +249,7 @@ void PlayerController::actionFromNetwork(PlayerAction p_action, int value,
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Handles steering for a player kart.
|
||||
*/
|
||||
void PlayerController::steer(float dt, int steer_val)
|
||||
void PlayerController::steer(int ticks, int steer_val)
|
||||
{
|
||||
// Get the old value, compute the new steering value,
|
||||
// and set it at the end of this function
|
||||
@ -264,6 +264,7 @@ void PlayerController::steer(float dt, int steer_val)
|
||||
// Amount the steering is changed for digital devices.
|
||||
// If the steering is 'back to straight', a different steering
|
||||
// change speed is used.
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
const float STEER_CHANGE = ( (steer_val<=0 && steer<0) ||
|
||||
(steer_val>=0 && steer>0) )
|
||||
? dt/m_kart->getKartProperties()->getTurnTimeResetSteer()
|
||||
@ -313,13 +314,13 @@ void PlayerController::skidBonusTriggered()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the player kart, called once each timestep.
|
||||
*/
|
||||
void PlayerController::update(float dt)
|
||||
void PlayerController::update(int ticks)
|
||||
{
|
||||
// Don't do steering if it's replay. In position only replay it doesn't
|
||||
// matter, but if it's physics replay the gradual steering causes
|
||||
// incorrect results, since the stored values are already adjusted.
|
||||
if (!history->replayHistory() || !history->dontDoPhysics())
|
||||
steer(dt, m_steer_val);
|
||||
steer(ticks, m_steer_val);
|
||||
|
||||
if (World::getWorld()->getPhase() == World::GOAL_PHASE)
|
||||
{
|
||||
@ -336,11 +337,11 @@ void PlayerController::update(float dt)
|
||||
// Only give penalty time in SET_PHASE.
|
||||
// Penalty time check makes sure it doesn't get rendered on every
|
||||
// update.
|
||||
if (m_penalty_time == 0.0 &&
|
||||
if (m_penalty_ticks == 0 &&
|
||||
World::getWorld()->getPhase() == WorldStatus::SET_PHASE)
|
||||
{
|
||||
displayPenaltyWarning();
|
||||
m_penalty_time = stk_config->m_penalty_time;
|
||||
m_penalty_ticks = stk_config->m_penalty_ticks;
|
||||
} // if penalty_time = 0
|
||||
|
||||
m_controls->setBrake(false);
|
||||
@ -350,9 +351,9 @@ void PlayerController::update(float dt)
|
||||
return;
|
||||
} // if isStartPhase
|
||||
|
||||
if (m_penalty_time>0.0)
|
||||
if (m_penalty_ticks>0)
|
||||
{
|
||||
m_penalty_time-=dt;
|
||||
m_penalty_ticks-=ticks;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@ protected:
|
||||
bool m_prev_brake;
|
||||
bool m_prev_nitro;
|
||||
|
||||
float m_penalty_time;
|
||||
int m_penalty_ticks;
|
||||
|
||||
virtual void steer(float, int);
|
||||
virtual void steer(int ticks, int steer_val);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Called when this kart started too early and got a start penalty. */
|
||||
virtual void displayPenaltyWarning() {}
|
||||
@ -43,7 +43,7 @@ protected:
|
||||
public:
|
||||
PlayerController(AbstractKart *kart);
|
||||
virtual ~PlayerController ();
|
||||
virtual void update (float) OVERRIDE;
|
||||
virtual void update (int ticks) OVERRIDE;
|
||||
virtual bool action (PlayerAction action, int value,
|
||||
bool dry_run = false ) OVERRIDE;
|
||||
virtual void actionFromNetwork(PlayerAction action, int value,
|
||||
|
@ -161,7 +161,7 @@ void SkiddingAI::reset()
|
||||
{
|
||||
m_time_since_last_shot = 0.0f;
|
||||
m_start_kart_crash_direction = 0;
|
||||
m_start_delay = -1.0f;
|
||||
m_start_delay = -1;
|
||||
m_time_since_stuck = 0.0f;
|
||||
m_kart_ahead = NULL;
|
||||
m_distance_ahead = 0.0f;
|
||||
@ -218,8 +218,9 @@ unsigned int SkiddingAI::getNextSector(unsigned int index)
|
||||
* It is called once per frame for each AI and determines the behaviour of
|
||||
* the AI, e.g. steering, accelerating/braking, firing.
|
||||
*/
|
||||
void SkiddingAI::update(float dt)
|
||||
void SkiddingAI::update(int ticks)
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
// This is used to enable firing an item backwards.
|
||||
m_controls->setLookBack(false);
|
||||
m_controls->setNitro(false);
|
||||
@ -293,14 +294,14 @@ void SkiddingAI::update(float dt)
|
||||
if(isStuck() && !m_kart->getKartAnimation())
|
||||
{
|
||||
new RescueAnimation(m_kart);
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_world->isStartPhase() )
|
||||
{
|
||||
handleRaceStart();
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -309,7 +310,7 @@ void SkiddingAI::update(float dt)
|
||||
|
||||
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI,
|
||||
m_ai_properties->getSpeedCap(m_distance_to_player),
|
||||
/*fade_in_time*/0.0f);
|
||||
/*fade_in_time*/0);
|
||||
//Detect if we are going to crash with the track and/or kart
|
||||
checkCrashes(m_kart->getXYZ());
|
||||
determineTrackDirection();
|
||||
@ -347,7 +348,7 @@ void SkiddingAI::update(float dt)
|
||||
if(!commands_set)
|
||||
{
|
||||
/*Response handling functions*/
|
||||
handleAcceleration(dt);
|
||||
handleAcceleration(ticks);
|
||||
handleSteering(dt);
|
||||
handleItems(dt);
|
||||
handleRescue(dt);
|
||||
@ -361,7 +362,7 @@ void SkiddingAI::update(float dt)
|
||||
if(m_controls->getNitro() &&
|
||||
m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
|
||||
m_kart->getSpeed()>1.0f &&
|
||||
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
|
||||
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
|
||||
!m_avoid_item_close)
|
||||
{
|
||||
// Make sure that not all AI karts use the zipper at the same
|
||||
@ -376,7 +377,7 @@ void SkiddingAI::update(float dt)
|
||||
}
|
||||
|
||||
/*And obviously general kart stuff*/
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -849,7 +850,7 @@ bool SkiddingAI::handleSelectedItem(Vec3 kart_aim_direction, Vec3 *aim_point)
|
||||
// If the item is unavailable keep on testing. It is not necessary
|
||||
// to test if an item has turned bad, this was tested before this
|
||||
// function is called.
|
||||
if(m_item_to_collect->getDisableTime()>0)
|
||||
if(m_item_to_collect->getDisableTicks()>0)
|
||||
return false;
|
||||
|
||||
const Vec3 &xyz = m_item_to_collect->getXYZ();
|
||||
@ -1039,7 +1040,7 @@ void SkiddingAI::evaluateItems(const Item *item, Vec3 kart_aim_direction,
|
||||
const KartProperties *kp = m_kart->getKartProperties();
|
||||
|
||||
// Ignore items that are currently disabled
|
||||
if(item->getDisableTime()>0) return;
|
||||
if(item->getDisableTicks()>0) return;
|
||||
|
||||
// If the item type is not handled here, ignore it
|
||||
Item::ItemType type = item->getType();
|
||||
@ -1373,7 +1374,8 @@ void SkiddingAI::handleItems(const float dt)
|
||||
// likely that this kart then gets a good iteam), otherwise use it
|
||||
// after a waiting an appropriate time
|
||||
if(m_kart->getPosition()>1 &&
|
||||
m_time_since_last_shot > stk_config->m_item_switch_time+2.0f)
|
||||
m_time_since_last_shot >
|
||||
stk_config->ticks2Time(stk_config->m_item_switch_ticks)+2.0f)
|
||||
m_controls->setFire(true);
|
||||
break; // POWERUP_SWITCH
|
||||
|
||||
@ -1504,12 +1506,12 @@ void SkiddingAI::computeNearestKarts()
|
||||
/** Determines if the AI should accelerate or not.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void SkiddingAI::handleAcceleration( const float dt)
|
||||
void SkiddingAI::handleAcceleration(int ticks)
|
||||
{
|
||||
//Do not accelerate until we have delayed the start enough
|
||||
if( m_start_delay > 0.0f )
|
||||
if( m_start_delay > 0 )
|
||||
{
|
||||
m_start_delay -= dt;
|
||||
m_start_delay -= ticks;
|
||||
m_controls->setAccel(0.0f);
|
||||
return;
|
||||
}
|
||||
@ -1520,7 +1522,7 @@ void SkiddingAI::handleAcceleration( const float dt)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
{
|
||||
if(m_kart->getSpeed() < m_kart->getCurrentMaxSpeed() / 2)
|
||||
m_controls->setAccel(0.05f);
|
||||
@ -1536,14 +1538,15 @@ void SkiddingAI::handleAcceleration( const float dt)
|
||||
//-----------------------------------------------------------------------------
|
||||
void SkiddingAI::handleRaceStart()
|
||||
{
|
||||
if( m_start_delay < 0.0f )
|
||||
if( m_start_delay < 0 )
|
||||
{
|
||||
// Each kart starts at a different, random time, and the time is
|
||||
// smaller depending on the difficulty.
|
||||
m_start_delay = m_ai_properties->m_min_start_delay
|
||||
m_start_delay = stk_config->time2Ticks(
|
||||
m_ai_properties->m_min_start_delay
|
||||
+ (float) rand() / RAND_MAX
|
||||
* (m_ai_properties->m_max_start_delay -
|
||||
m_ai_properties->m_min_start_delay);
|
||||
m_ai_properties->m_min_start_delay) );
|
||||
|
||||
float false_start_probability =
|
||||
m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS
|
||||
@ -1552,7 +1555,7 @@ void SkiddingAI::handleRaceStart()
|
||||
// Now check for a false start. If so, add 1 second penalty time.
|
||||
if(rand() < RAND_MAX * false_start_probability)
|
||||
{
|
||||
m_start_delay+=stk_config->m_penalty_time;
|
||||
m_start_delay+=stk_config->m_penalty_ticks;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1591,7 +1594,7 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
if(m_kart->getSpeed() > 0.95f*m_kart->getCurrentMaxSpeed())
|
||||
return;
|
||||
// Don't use nitro when the AI has a plunger in the face!
|
||||
if(m_kart->getBlockedByPlungerTime()>0) return;
|
||||
if(m_kart->getBlockedByPlungerTicks()>0) return;
|
||||
|
||||
// Don't use nitro if we are braking
|
||||
if(m_controls->getBrake()) return;
|
||||
@ -1683,7 +1686,7 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
|
||||
if(m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
|
||||
m_kart->getSpeed()>1.0f &&
|
||||
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
|
||||
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
|
||||
{
|
||||
DriveNode::DirectionType dir;
|
||||
unsigned int last;
|
||||
@ -2391,7 +2394,7 @@ void SkiddingAI::setSteering(float angle, float dt)
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
// Restrict steering when a plunger is in the face
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
{
|
||||
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
|
||||
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
|
||||
|
@ -51,8 +51,6 @@
|
||||
#include <line3d.h>
|
||||
|
||||
class LinearWorld;
|
||||
class DriveGraph;
|
||||
class ShowCurve;
|
||||
class Track;
|
||||
|
||||
namespace irr
|
||||
@ -145,8 +143,8 @@ private:
|
||||
/** Distance to the kard behind. */
|
||||
float m_distance_behind;
|
||||
|
||||
/** The actual start delay used. */
|
||||
float m_start_delay;
|
||||
/** The actual start delay used in ticks. */
|
||||
int m_start_delay;
|
||||
|
||||
/** Time an item has been collected and not used. */
|
||||
float m_time_since_last_shot;
|
||||
@ -242,7 +240,7 @@ private:
|
||||
*specific action (more like, associated with inaction).
|
||||
*/
|
||||
void handleRaceStart();
|
||||
void handleAcceleration(const float dt);
|
||||
void handleAcceleration(int ticks);
|
||||
void handleSteering(float dt);
|
||||
void handleItems(const float dt);
|
||||
void handleRescue(const float dt);
|
||||
@ -277,7 +275,7 @@ protected:
|
||||
public:
|
||||
SkiddingAI(AbstractKart *kart);
|
||||
~SkiddingAI();
|
||||
virtual void update (float delta) ;
|
||||
virtual void update (int ticks);
|
||||
virtual void reset ();
|
||||
virtual const irr::core::stringw& getNamePostfix() const;
|
||||
};
|
||||
|
@ -107,7 +107,7 @@ void SoccerAI::reset()
|
||||
* after goal.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void SoccerAI::update(float dt)
|
||||
void SoccerAI::update(int ticks)
|
||||
{
|
||||
#ifdef BALL_AIM_DEBUG
|
||||
Vec3 red = m_world->getBallAimPosition(SOCCER_TEAM_RED);
|
||||
@ -125,11 +125,11 @@ void SoccerAI::update(float dt)
|
||||
resetAfterStop();
|
||||
m_controls->setBrake(false);
|
||||
m_controls->setAccel(0.0f);
|
||||
AIBaseController::update(dt);
|
||||
AIBaseController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
ArenaAI::update(dt);
|
||||
ArenaAI::update(ticks);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -100,12 +100,9 @@ private:
|
||||
|
||||
public:
|
||||
SoccerAI(AbstractKart *kart);
|
||||
// ------------------------------------------------------------------------
|
||||
~SoccerAI();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void update (float delta) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void reset () OVERRIDE;
|
||||
virtual void update (int ticks) OVERRIDE;
|
||||
virtual void reset() OVERRIDE;
|
||||
|
||||
};
|
||||
|
||||
|
@ -56,8 +56,8 @@ SpareTireAI::SpareTireAI(AbstractKart *kart)
|
||||
void SpareTireAI::reset()
|
||||
{
|
||||
BattleAI::reset();
|
||||
m_idx = 0;
|
||||
m_timer = 0.0f;
|
||||
m_idx = 0;
|
||||
m_timer = 0;
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -65,12 +65,12 @@ void SpareTireAI::reset()
|
||||
* \ref m_timer reaches zero which it will be decreased here.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void SpareTireAI::update(float dt)
|
||||
void SpareTireAI::update(int ticks)
|
||||
{
|
||||
BattleAI::update(dt);
|
||||
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI, 0.5f, /*fade_in_time*/0.0f);
|
||||
m_timer -= dt;
|
||||
if (m_timer < 0.0f)
|
||||
BattleAI::update(ticks);
|
||||
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI, 0.5f, /*fade_in_time*/0);
|
||||
m_timer -= ticks;
|
||||
if (m_timer < 0)
|
||||
unspawn();
|
||||
} // update
|
||||
|
||||
@ -108,10 +108,10 @@ void SpareTireAI::findTarget()
|
||||
* moving around.
|
||||
* \param time_to_last Time before calling \ref unspawn.
|
||||
*/
|
||||
void SpareTireAI::spawn(float time_to_last)
|
||||
void SpareTireAI::spawn(int ticks_to_last)
|
||||
{
|
||||
findDefaultPath();
|
||||
m_timer = time_to_last;
|
||||
m_timer = ticks_to_last;
|
||||
|
||||
Physics::getInstance()->addKart(m_kart);
|
||||
m_kart->startEngineSFX();
|
||||
|
@ -35,7 +35,7 @@ private:
|
||||
int m_idx;
|
||||
|
||||
/** Store the time before calling \ref unspawn. */
|
||||
float m_timer;
|
||||
int m_timer;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void findTarget() OVERRIDE;
|
||||
@ -47,11 +47,11 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void crashed(const AbstractKart *k) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void update(float delta) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void reset() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
void spawn(float time_to_last);
|
||||
void spawn(int ticks_to_last);
|
||||
// ------------------------------------------------------------------------
|
||||
void unspawn();
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -59,8 +59,8 @@
|
||||
#include <iostream>
|
||||
|
||||
// This define is only used to make the TestAI as similar to the
|
||||
// SkiddingAI. This way the two AIs can be compared without too many
|
||||
// false positives.
|
||||
// SkiddingAI as possible. This way the two AIs can be compared
|
||||
// without too many false and distracing positives.
|
||||
|
||||
#define SkiddingAI TestAI
|
||||
|
||||
@ -167,7 +167,7 @@ void SkiddingAI::reset()
|
||||
{
|
||||
m_time_since_last_shot = 0.0f;
|
||||
m_start_kart_crash_direction = 0;
|
||||
m_start_delay = -1.0f;
|
||||
m_start_delay = -1;
|
||||
m_time_since_stuck = 0.0f;
|
||||
m_kart_ahead = NULL;
|
||||
m_distance_ahead = 0.0f;
|
||||
@ -224,8 +224,9 @@ unsigned int SkiddingAI::getNextSector(unsigned int index)
|
||||
* It is called once per frame for each AI and determines the behaviour of
|
||||
* the AI, e.g. steering, accelerating/braking, firing.
|
||||
*/
|
||||
void SkiddingAI::update(float dt)
|
||||
void SkiddingAI::update(int ticks)
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
// This is used to enable firing an item backwards.
|
||||
m_controls->setLookBack(false);
|
||||
m_controls->setNitro(false);
|
||||
@ -299,14 +300,14 @@ void SkiddingAI::update(float dt)
|
||||
if(isStuck() && !m_kart->getKartAnimation())
|
||||
{
|
||||
new RescueAnimation(m_kart);
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_world->isStartPhase() )
|
||||
{
|
||||
handleRaceStart();
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -315,7 +316,7 @@ void SkiddingAI::update(float dt)
|
||||
|
||||
m_kart->setSlowdown(MaxSpeed::MS_DECREASE_AI,
|
||||
m_ai_properties->getSpeedCap(m_distance_to_player),
|
||||
/*fade_in_time*/0.0f);
|
||||
/*fade_in_time*/0);
|
||||
//Detect if we are going to crash with the track and/or kart
|
||||
checkCrashes(m_kart->getXYZ());
|
||||
determineTrackDirection();
|
||||
@ -353,7 +354,7 @@ void SkiddingAI::update(float dt)
|
||||
if(!commands_set)
|
||||
{
|
||||
/*Response handling functions*/
|
||||
handleAcceleration(dt);
|
||||
handleAcceleration(ticks);
|
||||
handleSteering(dt);
|
||||
handleItems(dt);
|
||||
handleRescue(dt);
|
||||
@ -367,7 +368,7 @@ void SkiddingAI::update(float dt)
|
||||
if(m_controls->getNitro() &&
|
||||
m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
|
||||
m_kart->getSpeed()>1.0f &&
|
||||
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
|
||||
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0 &&
|
||||
!m_avoid_item_close)
|
||||
{
|
||||
// Make sure that not all AI karts use the zipper at the same
|
||||
@ -382,7 +383,7 @@ void SkiddingAI::update(float dt)
|
||||
}
|
||||
|
||||
/*And obviously general kart stuff*/
|
||||
AIBaseLapController::update(dt);
|
||||
AIBaseLapController::update(ticks);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -855,7 +856,7 @@ bool SkiddingAI::handleSelectedItem(Vec3 kart_aim_direction, Vec3 *aim_point)
|
||||
// If the item is unavailable keep on testing. It is not necessary
|
||||
// to test if an item has turned bad, this was tested before this
|
||||
// function is called.
|
||||
if(m_item_to_collect->getDisableTime()>0)
|
||||
if(m_item_to_collect->getDisableTicks()>0)
|
||||
return false;
|
||||
|
||||
const Vec3 &xyz = m_item_to_collect->getXYZ();
|
||||
@ -1045,7 +1046,7 @@ void SkiddingAI::evaluateItems(const Item *item, Vec3 kart_aim_direction,
|
||||
const KartProperties *kp = m_kart->getKartProperties();
|
||||
|
||||
// Ignore items that are currently disabled
|
||||
if(item->getDisableTime()>0) return;
|
||||
if(item->getDisableTicks()>0) return;
|
||||
|
||||
// If the item type is not handled here, ignore it
|
||||
Item::ItemType type = item->getType();
|
||||
@ -1159,7 +1160,7 @@ void SkiddingAI::handleItems(const float dt)
|
||||
if (m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS)
|
||||
{
|
||||
m_controls->setLookBack(m_kart->getPowerup()->getType() ==
|
||||
PowerupManager::POWERUP_BOWLING );
|
||||
PowerupManager::POWERUP_BOWLING );
|
||||
|
||||
if( m_time_since_last_shot > 3.0f )
|
||||
{
|
||||
@ -1287,7 +1288,7 @@ void SkiddingAI::handleItems(const float dt)
|
||||
// Since cakes can be fired all around, just use a sane distance
|
||||
// with a bit of extra for backwards, as enemy will go towards cake
|
||||
m_controls->setFire( (fire_backwards && distance < 25.0f) ||
|
||||
(!fire_backwards && distance < 20.0f) );
|
||||
(!fire_backwards && distance < 20.0f) );
|
||||
if(m_controls->getFire())
|
||||
m_controls->setLookBack(fire_backwards);
|
||||
break;
|
||||
@ -1339,7 +1340,7 @@ void SkiddingAI::handleItems(const float dt)
|
||||
m_controls->setFire( ( (fire_backwards && distance < 30.0f) ||
|
||||
(!fire_backwards && distance <10.0f) ) &&
|
||||
m_time_since_last_shot > 3.0f &&
|
||||
(straight_behind || straight_ahead) );
|
||||
(straight_behind || straight_ahead) );
|
||||
if(m_controls->getFire())
|
||||
m_controls->setLookBack(fire_backwards);
|
||||
break;
|
||||
@ -1379,7 +1380,8 @@ void SkiddingAI::handleItems(const float dt)
|
||||
// likely that this kart then gets a good iteam), otherwise use it
|
||||
// after a waiting an appropriate time
|
||||
if(m_kart->getPosition()>1 &&
|
||||
m_time_since_last_shot > stk_config->m_item_switch_time+2.0f)
|
||||
m_time_since_last_shot
|
||||
> stk_config->ticks2Time(stk_config->m_item_switch_ticks)+2.0f)
|
||||
m_controls->setFire(true);
|
||||
break; // POWERUP_SWITCH
|
||||
|
||||
@ -1396,7 +1398,7 @@ void SkiddingAI::handleItems(const float dt)
|
||||
if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||
{
|
||||
m_controls->setFire(m_world->getTime()<1.0f &&
|
||||
m_kart->getPosition()>2 );
|
||||
m_kart->getPosition()>2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1510,12 +1512,12 @@ void SkiddingAI::computeNearestKarts()
|
||||
/** Determines if the AI should accelerate or not.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void SkiddingAI::handleAcceleration( const float dt)
|
||||
void SkiddingAI::handleAcceleration(int ticks)
|
||||
{
|
||||
//Do not accelerate until we have delayed the start enough
|
||||
if( m_start_delay > 0.0f )
|
||||
if( m_start_delay > 0 )
|
||||
{
|
||||
m_start_delay -= dt;
|
||||
m_start_delay -= ticks;
|
||||
m_controls->setAccel(0.0f);
|
||||
return;
|
||||
}
|
||||
@ -1530,7 +1532,7 @@ void SkiddingAI::handleAcceleration( const float dt)
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
{
|
||||
if(m_kart->getSpeed() < m_kart->getCurrentMaxSpeed() / 2)
|
||||
m_controls->setAccel(0.05f);
|
||||
@ -1546,14 +1548,15 @@ void SkiddingAI::handleAcceleration( const float dt)
|
||||
//-----------------------------------------------------------------------------
|
||||
void SkiddingAI::handleRaceStart()
|
||||
{
|
||||
if( m_start_delay < 0.0f )
|
||||
if( m_start_delay < 0 )
|
||||
{
|
||||
// Each kart starts at a different, random time, and the time is
|
||||
// smaller depending on the difficulty.
|
||||
m_start_delay = m_ai_properties->m_min_start_delay
|
||||
m_start_delay = stk_config->time2Ticks(
|
||||
m_ai_properties->m_min_start_delay
|
||||
+ (float) rand() / RAND_MAX
|
||||
* (m_ai_properties->m_max_start_delay -
|
||||
m_ai_properties->m_min_start_delay);
|
||||
m_ai_properties->m_min_start_delay) );
|
||||
|
||||
float false_start_probability =
|
||||
m_superpower == RaceManager::SUPERPOWER_NOLOK_BOSS
|
||||
@ -1562,7 +1565,7 @@ void SkiddingAI::handleRaceStart()
|
||||
// Now check for a false start. If so, add 1 second penalty time.
|
||||
if(rand() < RAND_MAX * false_start_probability)
|
||||
{
|
||||
m_start_delay+=stk_config->m_penalty_time;
|
||||
m_start_delay+=stk_config->m_penalty_ticks;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1640,7 +1643,7 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
// sandtrack 10 489.963 64.18 0.00 3 1009 0.00 0 0 1 135 0 0 1407 0.00
|
||||
|
||||
// Don't use nitro when the AI has a plunger in the face!
|
||||
if(m_kart->getBlockedByPlungerTime()>0) return;
|
||||
if(m_kart->getBlockedByPlungerTicks()>0) return;
|
||||
|
||||
// Don't use nitro if we are braking
|
||||
if(m_controls->getBrake()) return;
|
||||
@ -1726,13 +1729,13 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
{
|
||||
// Only prevent overtaking on highest level
|
||||
m_controls->setNitro(m_ai_properties->m_nitro_usage
|
||||
== AIProperties::NITRO_ALL );
|
||||
== AIProperties::NITRO_ALL);
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_kart->getPowerup()->getType()==PowerupManager::POWERUP_ZIPPER &&
|
||||
m_kart->getSpeed()>1.0f &&
|
||||
m_kart->getSpeedIncreaseTimeLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
|
||||
m_kart->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_ZIPPER)<=0)
|
||||
{
|
||||
DriveNode::DirectionType dir;
|
||||
unsigned int last;
|
||||
@ -1742,7 +1745,7 @@ void SkiddingAI::handleNitroAndZipper()
|
||||
{
|
||||
float diff = DriveGraph::get()->getDistanceFromStart(last)
|
||||
- DriveGraph::get()->getDistanceFromStart(m_track_node);
|
||||
if (diff < 0) diff += Track::getCurrentTrack()->getTrackLength();
|
||||
if(diff<0) diff += Track::getCurrentTrack()->getTrackLength();
|
||||
if(diff>m_ai_properties->m_straight_length_for_zipper)
|
||||
m_controls->setFire(true);
|
||||
}
|
||||
@ -2076,6 +2079,7 @@ void SkiddingAI::findNonCrashingPointFixed(Vec3 *aim_position, int *last_node)
|
||||
*last_node = m_next_node_index[m_track_node];
|
||||
float angle = DriveGraph::get()->getAngleToNext(m_track_node,
|
||||
m_successor_index[m_track_node]);
|
||||
|
||||
Vec3 direction;
|
||||
Vec3 step_track_coord;
|
||||
|
||||
@ -2431,7 +2435,7 @@ void SkiddingAI::setSteering(float angle, float dt)
|
||||
#endif
|
||||
}
|
||||
m_controls->setSkidControl(m_skid_probability_state == SKID_PROBAB_SKID
|
||||
? sc : KartControl::SC_NONE );
|
||||
? sc : KartControl::SC_NONE );
|
||||
}
|
||||
|
||||
// Adjust steer fraction in case to be in [-1,1]
|
||||
@ -2439,7 +2443,7 @@ void SkiddingAI::setSteering(float angle, float dt)
|
||||
else if(steer_fraction < -1.0f) steer_fraction = -1.0f;
|
||||
|
||||
// Restrict steering when a plunger is in the face
|
||||
if(m_kart->getBlockedByPlungerTime()>0)
|
||||
if(m_kart->getBlockedByPlungerTicks()>0)
|
||||
{
|
||||
if (steer_fraction > 0.5f) steer_fraction = 0.5f;
|
||||
else if(steer_fraction < -0.5f) steer_fraction = -0.5f;
|
||||
@ -2498,7 +2502,7 @@ void SkiddingAI::setSteering(float angle, float dt)
|
||||
else
|
||||
{
|
||||
m_controls->setSteer( (old_steer-max_steer_change < steer_fraction)
|
||||
? steer_fraction : old_steer-max_steer_change );
|
||||
? steer_fraction : old_steer-max_steer_change );
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,8 +101,8 @@ private:
|
||||
/** Distance to the kard behind. */
|
||||
float m_distance_behind;
|
||||
|
||||
/** The actual start delay used. */
|
||||
float m_start_delay;
|
||||
/** The actual start delay used in ticks. */
|
||||
int m_start_delay;
|
||||
|
||||
/** Time an item has been collected and not used. */
|
||||
float m_time_since_last_shot;
|
||||
@ -198,7 +198,7 @@ private:
|
||||
*specific action (more like, associated with inaction).
|
||||
*/
|
||||
void handleRaceStart();
|
||||
void handleAcceleration(const float dt);
|
||||
void handleAcceleration(int ticks);
|
||||
void handleSteering(float dt);
|
||||
void handleItems(const float dt);
|
||||
void handleRescue(const float dt);
|
||||
@ -233,7 +233,7 @@ protected:
|
||||
public:
|
||||
TestAI(AbstractKart *kart);
|
||||
~TestAI();
|
||||
virtual void update (float delta) ;
|
||||
virtual void update (int ticks);
|
||||
virtual void reset ();
|
||||
virtual const irr::core::stringw& getNamePostfix() const;
|
||||
};
|
||||
|
@ -105,7 +105,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
|
||||
|
||||
// Set invulnerable time, and graphical effects
|
||||
float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime();
|
||||
m_kart->setInvulnerableTime(t);
|
||||
m_kart->setInvulnerableTicks(stk_config->time2Ticks(t));
|
||||
m_kart->showStarEffect(t);
|
||||
|
||||
m_kart->getAttachment()->clear();
|
||||
|
@ -72,12 +72,12 @@ void GhostKart::addReplayEvent(float time,
|
||||
/** Updates the current event of the ghost kart using interpolation
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void GhostKart::update(float dt)
|
||||
void GhostKart::update(int ticks)
|
||||
{
|
||||
GhostController* gc = dynamic_cast<GhostController*>(getController());
|
||||
if (gc == NULL) return;
|
||||
|
||||
gc->update(dt);
|
||||
gc->update(ticks);
|
||||
if (gc->isReplayEnd())
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
@ -113,8 +113,9 @@ void GhostKart::update(float dt)
|
||||
center_shift.setY(m_graphical_y_offset);
|
||||
center_shift = getTrans().getBasis() * center_shift;
|
||||
|
||||
Moveable::updateGraphics(dt, center_shift, btQuaternion(0, 0, 0, 1));
|
||||
Moveable::updateGraphics(ticks, center_shift, btQuaternion(0, 0, 0, 1));
|
||||
Moveable::updatePosition();
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
getKartModel()->update(dt, dt*(m_all_physic_info[idx].m_speed),
|
||||
m_all_physic_info[idx].m_steer, m_all_physic_info[idx].m_speed,
|
||||
/*lean*/0.0f, idx);
|
||||
|
@ -46,7 +46,7 @@ private:
|
||||
public:
|
||||
GhostKart(const std::string& ident,
|
||||
unsigned int world_kart_id, int position);
|
||||
virtual void update (float dt);
|
||||
virtual void update(int ticks);
|
||||
virtual void reset();
|
||||
// ------------------------------------------------------------------------
|
||||
/** No physics body for ghost kart, so nothing to adjust. */
|
||||
|
@ -124,10 +124,10 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_finished_race = false;
|
||||
m_race_result = false;
|
||||
m_finish_time = 0.0f;
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_bubblegum_ticks = 0;
|
||||
m_bubblegum_torque = 0.0f;
|
||||
m_invulnerable_time = 0.0f;
|
||||
m_squash_time = 0.0f;
|
||||
m_invulnerable_ticks = 0;
|
||||
m_squash_ticks = 0;
|
||||
|
||||
m_shadow = NULL;
|
||||
m_wheel_box = NULL;
|
||||
@ -139,7 +139,7 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_flying = false;
|
||||
m_stars_effect = NULL;
|
||||
m_is_jumping = false;
|
||||
m_min_nitro_time = 0.0f;
|
||||
m_min_nitro_ticks = 0;
|
||||
m_fire_clicked = 0;
|
||||
m_wrongway_counter = 0;
|
||||
m_type = RaceManager::KT_AI;
|
||||
@ -316,7 +316,7 @@ void Kart::reset()
|
||||
Physics::getInstance()->addKart(this);
|
||||
}
|
||||
|
||||
m_min_nitro_time = 0.0f;
|
||||
m_min_nitro_ticks = 0;
|
||||
|
||||
// Reset star effect in case that it is currently being shown.
|
||||
m_stars_effect->reset();
|
||||
@ -348,22 +348,21 @@ void Kart::reset()
|
||||
m_finished_race = false;
|
||||
m_eliminated = false;
|
||||
m_finish_time = 0.0f;
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_bubblegum_ticks = 0;
|
||||
m_bubblegum_torque = 0.0f;
|
||||
m_invulnerable_time = 0.0f;
|
||||
m_squash_time = 0.0f;
|
||||
m_invulnerable_ticks = 0;
|
||||
m_squash_ticks = 0;
|
||||
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
m_collected_energy = 0;
|
||||
m_has_started = false;
|
||||
m_bounce_back_time = 0.0f;
|
||||
m_brake_time = 0.0f;
|
||||
m_time_last_crash = 0.0f;
|
||||
m_bounce_back_ticks = 0;
|
||||
m_brake_ticks = 0;
|
||||
m_ticks_last_crash = 0;
|
||||
m_speed = 0.0f;
|
||||
m_smoothed_speed = 0.0f;
|
||||
m_current_lean = 0.0f;
|
||||
m_view_blocked_by_plunger = 0.0f;
|
||||
m_bubblegum_time = 0.0f;
|
||||
m_bubblegum_torque = 0.0f;
|
||||
m_falling_ticks = 0;
|
||||
m_view_blocked_by_plunger = 0;
|
||||
m_has_caught_nolok_bubblegum = false;
|
||||
m_is_jumping = false;
|
||||
|
||||
@ -444,8 +443,8 @@ void Kart::setXYZ(const Vec3& a)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time)
|
||||
float engine_force, int duration,
|
||||
int fade_out_time)
|
||||
{
|
||||
m_max_speed->increaseMaxSpeed(category, add_speed, engine_force, duration,
|
||||
fade_out_time);
|
||||
@ -453,7 +452,7 @@ void Kart::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void Kart::setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
float fade_in_time)
|
||||
int fade_in_time)
|
||||
{
|
||||
m_max_speed->setSlowdown(category, max_speed_fraction, fade_in_time);
|
||||
} // setSlowdown
|
||||
@ -464,9 +463,9 @@ float Kart::getCurrentMaxSpeed() const
|
||||
return m_max_speed->getCurrentMaxSpeed();
|
||||
} // getCurrentMaxSpeed
|
||||
// -----------------------------------------------------------------------------
|
||||
float Kart::getSpeedIncreaseTimeLeft(unsigned int category) const
|
||||
int Kart::getSpeedIncreaseTicksLeft(unsigned int category) const
|
||||
{
|
||||
return m_max_speed->getSpeedIncreaseTimeLeft(category);
|
||||
return m_max_speed->getSpeedIncreaseTicksLeft(category);
|
||||
} // getSpeedIncreaseTimeLeft
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -544,7 +543,8 @@ void Kart::blockViewWithPlunger()
|
||||
{
|
||||
// Avoid that a plunger extends the plunger time
|
||||
if(m_view_blocked_by_plunger<=0 && !isShielded())
|
||||
m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime();
|
||||
m_view_blocked_by_plunger =
|
||||
stk_config->time2Ticks(m_kart_properties->getPlungerInFaceTime());
|
||||
if(isShielded())
|
||||
{
|
||||
decreaseShieldTime();
|
||||
@ -1020,14 +1020,15 @@ void Kart::collectedItem(Item *item, int add_info)
|
||||
item->getEmitter()->getIdent() == "nolok");
|
||||
|
||||
// slow down
|
||||
m_bubblegum_time = m_kart_properties->getBubblegumDuration();
|
||||
m_bubblegum_ticks =
|
||||
stk_config->time2Ticks(m_kart_properties->getBubblegumDuration());
|
||||
m_bubblegum_torque = ((rand()%2)
|
||||
? m_kart_properties->getBubblegumTorque()
|
||||
: -m_kart_properties->getBubblegumTorque());
|
||||
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE,
|
||||
m_kart_properties->getBubblegumSpeedFraction() ,
|
||||
m_kart_properties->getBubblegumFadeInTime(),
|
||||
m_bubblegum_time);
|
||||
m_kart_properties->getBubblegumFadeInTicks(),
|
||||
m_bubblegum_ticks);
|
||||
getNextEmitter()->play(getXYZ(), m_goo_sound);
|
||||
|
||||
// Play appropriate custom character sound
|
||||
@ -1051,7 +1052,7 @@ void Kart::collectedItem(Item *item, int add_info)
|
||||
*/
|
||||
float Kart::getStartupBoost() const
|
||||
{
|
||||
float t = World::getWorld()->getTimeSinceStart();
|
||||
float t = stk_config->ticks2Time(World::getWorld()->getTicksSinceStart());
|
||||
std::vector<float> startup_times = m_kart_properties->getStartupTime();
|
||||
for (unsigned int i = 0; i < startup_times.size(); i++)
|
||||
{
|
||||
@ -1110,16 +1111,16 @@ bool Kart::isNearGround() const
|
||||
} // isNearGround
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Enables a kart shield protection for a certain amount of time.
|
||||
/** Enables a kart shield protection for a certain amount of time.
|
||||
*/
|
||||
void Kart::setShieldTime(float t)
|
||||
{
|
||||
if(isShielded())
|
||||
{
|
||||
getAttachment()->setTimeLeft(t);
|
||||
getAttachment()->setTicksLeft(stk_config->time2Ticks(t));
|
||||
}
|
||||
}
|
||||
} // setShieldTime
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/**
|
||||
* Returns true if the kart is protected by a shield.
|
||||
@ -1144,8 +1145,8 @@ bool Kart::isShielded() const
|
||||
*/
|
||||
float Kart::getShieldTime() const
|
||||
{
|
||||
if(isShielded())
|
||||
return getAttachment()->getTimeLeft();
|
||||
if (isShielded())
|
||||
return stk_config->ticks2Time(getAttachment()->getTicksLeft());
|
||||
else
|
||||
return 0.0f;
|
||||
} // getShieldTime
|
||||
@ -1159,7 +1160,7 @@ void Kart::decreaseShieldTime()
|
||||
{
|
||||
if (isShielded())
|
||||
{
|
||||
getAttachment()->setTimeLeft(0.0f);
|
||||
getAttachment()->setTicksLeft(0);
|
||||
}
|
||||
} // decreaseShieldTime
|
||||
|
||||
@ -1206,19 +1207,19 @@ void Kart::eliminate()
|
||||
* particle effects, camera position, etc.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void Kart::update(float dt)
|
||||
void Kart::update(int ticks)
|
||||
{
|
||||
// Reset any instand speed increase in the bullet kart
|
||||
m_vehicle->setMinSpeed(0);
|
||||
|
||||
// update star effect (call will do nothing if stars are not activated)
|
||||
m_stars_effect->update(dt);
|
||||
m_stars_effect->update(stk_config->ticks2Time(ticks));
|
||||
|
||||
if(m_squash_time>=0)
|
||||
if(m_squash_ticks>=0)
|
||||
{
|
||||
m_squash_time-=dt;
|
||||
m_squash_ticks-=ticks;
|
||||
// If squasing time ends, reset the model
|
||||
if(m_squash_time<=0)
|
||||
if(m_squash_ticks<=0)
|
||||
{
|
||||
m_node->setScale(core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
scene::ISceneNode* node =
|
||||
@ -1236,10 +1237,10 @@ void Kart::update(float dt)
|
||||
}
|
||||
} // if squashed
|
||||
|
||||
if (m_bubblegum_time > 0.0f)
|
||||
if (m_bubblegum_ticks > 0.0f)
|
||||
{
|
||||
m_bubblegum_time -= dt;
|
||||
if (m_bubblegum_time <= 0.0f)
|
||||
m_bubblegum_ticks -= ticks;
|
||||
if (m_bubblegum_ticks <= 0.0f)
|
||||
{
|
||||
m_bubblegum_torque = 0.0f;
|
||||
}
|
||||
@ -1251,6 +1252,7 @@ void Kart::update(float dt)
|
||||
// before updating the graphical position (which is done in
|
||||
// Moveable::update() ), otherwise 'stuttering' can happen (caused by
|
||||
// graphical and physical position not being the same).
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if (has_animation_before)
|
||||
{
|
||||
m_kart_animation->update(dt);
|
||||
@ -1258,7 +1260,7 @@ void Kart::update(float dt)
|
||||
// Update the position and other data taken from the physics (or
|
||||
// an animation which calls setXYZ(), which also updates the kart
|
||||
// physical position).
|
||||
Moveable::update(dt);
|
||||
Moveable::update(ticks);
|
||||
|
||||
Vec3 front(0, 0, getKartLength()*0.5f);
|
||||
m_xyz_front = getTrans()(front);
|
||||
@ -1267,14 +1269,14 @@ void Kart::update(float dt)
|
||||
updateSpeed();
|
||||
|
||||
if(!history->replayHistory() || !history->dontDoPhysics())
|
||||
m_controller->update(dt);
|
||||
m_controller->update(ticks);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
#undef DEBUG_CAMERA_SHAKE
|
||||
#ifdef DEBUG_CAMERA_SHAKE
|
||||
Log::verbose("camera", "%s t %f %f xyz %f %f %f v %f %f %f d3 %f d2 %f",
|
||||
Log::verbose("camera", "%s t %f %d xyz %f %f %f v %f %f %f d3 %f d2 %f",
|
||||
getIdent().c_str(),
|
||||
World::getWorld()->getTime(), dt,
|
||||
World::getWorld()->getTime(), ticks,
|
||||
getXYZ().getX(), getXYZ().getY(), getXYZ().getZ(),
|
||||
getVelocity().getX(), getVelocity().getY(), getVelocity().getZ(),
|
||||
(Camera::getCamera(0)->getXYZ()-getXYZ()).length(),
|
||||
@ -1287,9 +1289,9 @@ void Kart::update(float dt)
|
||||
#ifdef DEBUG_TO_COMPARE_KART_PHYSICS
|
||||
// This information is useful when comparing kart physics, e.g. to
|
||||
// see top speed, acceleration (i.e. time to top speed) etc.
|
||||
Log::verbose("physics", " %s t %f %f xyz(9-11) %f %f %f v(13-15) %f %f %f steerf(17) %f maxangle(19) %f speed(21) %f steering(23-24) %f %f clock %lf",
|
||||
Log::verbose("physics", " %s t %f %d xyz(9-11) %f %f %f v(13-15) %f %f %f steerf(17) %f maxangle(19) %f speed(21) %f steering(23-24) %f %f clock %lf",
|
||||
getIdent().c_str(),
|
||||
World::getWorld()->getTime(), dt,
|
||||
World::getWorld()->getTime(), ticks,
|
||||
getXYZ().getX(), getXYZ().getY(), getXYZ().getZ(),
|
||||
getVelocity().getX(), getVelocity().getY(), getVelocity().getZ(), //13,14,15
|
||||
m_skidding->getSteeringFraction(), //19
|
||||
@ -1302,17 +1304,17 @@ void Kart::update(float dt)
|
||||
#endif
|
||||
|
||||
// if its view is blocked by plunger, decrease remaining time
|
||||
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= dt;
|
||||
if(m_view_blocked_by_plunger > 0) m_view_blocked_by_plunger -= ticks;
|
||||
//unblock the view if kart just became shielded
|
||||
if(isShielded())
|
||||
m_view_blocked_by_plunger = 0.0f;
|
||||
m_view_blocked_by_plunger = 0;
|
||||
// Decrease remaining invulnerability time
|
||||
if(m_invulnerable_time>0)
|
||||
if(m_invulnerable_ticks>0)
|
||||
{
|
||||
m_invulnerable_time-=dt;
|
||||
m_invulnerable_ticks -= ticks;
|
||||
}
|
||||
|
||||
m_slipstream->update(dt);
|
||||
m_slipstream->update(ticks);
|
||||
|
||||
// TODO: hiker said this probably will be moved to btKart or so when updating bullet engine.
|
||||
// Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less
|
||||
@ -1343,13 +1345,13 @@ void Kart::update(float dt)
|
||||
// Used to prevent creating a rescue animation after an explosion animation
|
||||
// got deleted
|
||||
|
||||
m_attachment->update(dt);
|
||||
m_attachment->update(ticks);
|
||||
|
||||
m_kart_gfx->update(dt);
|
||||
if (m_collision_particles) m_collision_particles->update(dt);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Kart::updatePhysics", 0x60, 0x34, 0x7F);
|
||||
updatePhysics(dt);
|
||||
updatePhysics(ticks);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
if(!m_controls.getFire()) m_fire_clicked = 0;
|
||||
@ -1471,7 +1473,7 @@ void Kart::update(float dt)
|
||||
}
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Kart::Update (material)", 0x60, 0x34, 0x7F);
|
||||
handleMaterialGFX(dt);
|
||||
handleMaterialGFX(ticks);
|
||||
const Material* material=m_terrain_info->getMaterial();
|
||||
if (!material) // kart falling off the track
|
||||
{
|
||||
@ -1523,14 +1525,14 @@ void Kart::update(float dt)
|
||||
{
|
||||
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_TERRAIN,
|
||||
material->getMaxSpeedFraction(),
|
||||
material->getSlowDownTime() );
|
||||
material->getSlowDownTicks() );
|
||||
#ifdef DEBUG
|
||||
if(UserConfigParams::m_material_debug)
|
||||
{
|
||||
Log::info("Kart","%s\tfraction %f\ttime %f.",
|
||||
material->getTexFname().c_str(),
|
||||
material->getMaxSpeedFraction(),
|
||||
material->getSlowDownTime() );
|
||||
material->getSlowDownTicks() );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -1548,12 +1550,16 @@ void Kart::update(float dt)
|
||||
static video::SColor green(255, 61, 87, 23);
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
// draw skidmarks if relevant (we force pink skidmarks on when hitting a bubblegum)
|
||||
// draw skidmarks if relevant (we force pink skidmarks on when hitting
|
||||
// a bubblegum)
|
||||
if(m_kart_properties->getSkidEnabled() && m_skidmarks)
|
||||
{
|
||||
m_skidmarks->update(dt,
|
||||
m_bubblegum_time > 0,
|
||||
(m_bubblegum_time > 0 ? (m_has_caught_nolok_bubblegum ? &green : &pink) : NULL) );
|
||||
m_bubblegum_ticks > 0,
|
||||
(m_bubblegum_ticks > 0
|
||||
? (m_has_caught_nolok_bubblegum ? &green
|
||||
: &pink)
|
||||
: NULL ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1561,7 +1567,7 @@ void Kart::update(float dt)
|
||||
|
||||
if (emergency)
|
||||
{
|
||||
m_view_blocked_by_plunger = 0.0f;
|
||||
m_view_blocked_by_plunger = 0;
|
||||
if (m_flying)
|
||||
{
|
||||
stopFlying();
|
||||
@ -1695,7 +1701,8 @@ void Kart::setSquash(float time, float slowdown)
|
||||
}
|
||||
m_node->setScale(core::vector3df(1.0f, 0.5f, 1.0f));
|
||||
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown,
|
||||
0.1f, time);
|
||||
stk_config->time2Ticks(0.1f),
|
||||
stk_config->time2Ticks(time));
|
||||
if (m_vehicle->getNumWheels() > 0)
|
||||
{
|
||||
if (!m_wheel_box)
|
||||
@ -1708,7 +1715,7 @@ void Kart::setSquash(float time, float slowdown)
|
||||
}
|
||||
m_wheel_box->getRelativeTransformationMatrix().setScale(core::vector3df(1.0f, 2.0f, 1.0f));
|
||||
}
|
||||
m_squash_time = time;
|
||||
m_squash_ticks = stk_config->time2Ticks(time);
|
||||
} // setSquash
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1796,7 +1803,7 @@ void Kart::handleMaterialSFX(const Material *material)
|
||||
* kart is falling, or if the surface the kart is driving on has
|
||||
* the 'isBelowSurface' property set.
|
||||
*/
|
||||
void Kart::handleMaterialGFX(float dt)
|
||||
void Kart::handleMaterialGFX(int ticks)
|
||||
{
|
||||
const Material *material = getMaterial();
|
||||
|
||||
@ -1833,19 +1840,19 @@ void Kart::handleMaterialGFX(float dt)
|
||||
bool falling = material && material->hasFallingEffect() && !m_flying;
|
||||
if (falling)
|
||||
{
|
||||
m_falling_time -= dt;
|
||||
if (m_falling_time < 0.0f)
|
||||
m_falling_time = 0.0f;
|
||||
m_falling_ticks -= ticks;
|
||||
if (m_falling_ticks < 0)
|
||||
m_falling_ticks = 0;
|
||||
}
|
||||
else
|
||||
m_falling_time = 0.35f;
|
||||
m_falling_ticks = stk_config->time2Ticks(0.35f);
|
||||
|
||||
for(unsigned int i=0; i<Camera::getNumCameras(); i++)
|
||||
{
|
||||
Camera *camera = Camera::getCamera(i);
|
||||
if(camera->getKart()!=this) continue;
|
||||
|
||||
if (falling && m_falling_time <= 0.0f)
|
||||
if (falling && m_falling_ticks <= 0)
|
||||
{
|
||||
camera->setMode(Camera::CM_FALLING);
|
||||
}
|
||||
@ -1966,7 +1973,9 @@ void Kart::handleZipper(const Material *material, bool play_sound)
|
||||
|
||||
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
|
||||
max_speed_increase, speed_gain,
|
||||
engine_force, duration, fade_out_time);
|
||||
engine_force,
|
||||
stk_config->time2Ticks(duration),
|
||||
stk_config->time2Ticks(fade_out_time));
|
||||
// Play custom character sound (weee!)
|
||||
playCustomSFX(SFXManager::CUSTOM_ZIPPER);
|
||||
m_controller->handleZipper(play_sound);
|
||||
@ -1974,32 +1983,33 @@ void Kart::handleZipper(const Material *material, bool play_sound)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Updates the current nitro status.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void Kart::updateNitro(float dt)
|
||||
void Kart::updateNitro(int ticks)
|
||||
{
|
||||
if (m_controls.getNitro() && m_min_nitro_time <= 0.0f)
|
||||
if (m_controls.getNitro() && m_min_nitro_ticks <= 0)
|
||||
{
|
||||
m_min_nitro_time = m_kart_properties->getNitroMinConsumptionTime();
|
||||
m_min_nitro_ticks = m_kart_properties->getNitroMinConsumptionTicks();
|
||||
}
|
||||
if (m_min_nitro_time > 0.0f)
|
||||
if (m_min_nitro_ticks > 0)
|
||||
{
|
||||
m_min_nitro_time -= dt;
|
||||
m_min_nitro_ticks -= ticks;
|
||||
|
||||
// when pressing the key, don't allow the min time to go under zero.
|
||||
// If it went under zero, it would be reset
|
||||
if (m_controls.getNitro() && m_min_nitro_time <= 0.0f)
|
||||
m_min_nitro_time = 0.1f;
|
||||
if (m_controls.getNitro() && m_min_nitro_ticks <= 0)
|
||||
m_min_nitro_ticks = 1;
|
||||
}
|
||||
|
||||
bool increase_speed = (m_controls.getNitro() && isOnGround());
|
||||
if (!increase_speed && m_min_nitro_time <= 0.0f)
|
||||
if (!increase_speed && m_min_nitro_ticks <= 0)
|
||||
{
|
||||
if(m_nitro_sound->getStatus() == SFXBase::SFX_PLAYING)
|
||||
m_nitro_sound->stop();
|
||||
return;
|
||||
}
|
||||
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
m_collected_energy -= dt * m_kart_properties->getNitroConsumption();
|
||||
if (m_collected_energy < 0)
|
||||
{
|
||||
@ -2014,10 +2024,10 @@ void Kart::updateNitro(float dt)
|
||||
if(m_nitro_sound->getStatus() != SFXBase::SFX_PLAYING)
|
||||
m_nitro_sound->play();
|
||||
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
|
||||
m_kart_properties->getNitroMaxSpeedIncrease(),
|
||||
m_kart_properties->getNitroEngineForce(),
|
||||
m_kart_properties->getNitroDuration(),
|
||||
m_kart_properties->getNitroFadeOutTime());
|
||||
m_kart_properties->getNitroMaxSpeedIncrease(),
|
||||
m_kart_properties->getNitroEngineForce(),
|
||||
stk_config->time2Ticks(m_kart_properties->getNitroDuration()),
|
||||
stk_config->time2Ticks(m_kart_properties->getNitroFadeOutTime()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2096,8 +2106,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
|
||||
float abs_speed = fabsf(getSpeed());
|
||||
impulse *= ( abs_speed<10 ? 10.0f : sqrt(abs_speed) )
|
||||
* m_kart_properties->getCollisionTerrainImpulse();
|
||||
m_bounce_back_time = 0.2f;
|
||||
m_bounce_back_time = 0.0f;;
|
||||
m_bounce_back_ticks = 0;
|
||||
impulse = Vec3(0, 0, 0);
|
||||
//m_vehicle->setTimedCentralImpulse(0.1f, impulse);
|
||||
m_vehicle->setTimedCentralImpulse(0.0, impulse);
|
||||
@ -2125,7 +2134,7 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
|
||||
else
|
||||
impulse = Vec3(0, 0, -1); // Arbitrary
|
||||
impulse *= m_kart_properties->getCollisionTerrainImpulse();
|
||||
m_bounce_back_time = 0.2f;
|
||||
m_bounce_back_ticks = stk_config->time2Ticks(0.2f);
|
||||
m_vehicle->setTimedCentralImpulse(0.1f, impulse);
|
||||
}
|
||||
|
||||
@ -2173,13 +2182,13 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
|
||||
else if (m->getCollisionReaction() == Material::PUSH_BACK)
|
||||
{
|
||||
// This variable is set to 0.2 in case of a kart-terrain collision
|
||||
if (m_bounce_back_time <= 0.2f)
|
||||
if (m_bounce_back_ticks <= stk_config->time2Ticks(0.2f))
|
||||
{
|
||||
btVector3 push = m_body->getLinearVelocity().normalized();
|
||||
push[1] = 0.1f;
|
||||
m_body->applyCentralImpulse( -4000.0f*push );
|
||||
m_bounce_back_time = 2.0f;
|
||||
} // if m_bounce_back_time <= 0.2f
|
||||
m_bounce_back_ticks = stk_config->time2Ticks(2.0f);
|
||||
} // if m_bounce_back_ticks <= 0.2f
|
||||
} // if (m->getCollisionReaction() == Material::PUSH_BACK)
|
||||
} // if(m && m->getCollisionReaction() != Material::NORMAL &&
|
||||
// !getKartAnimation())
|
||||
@ -2193,13 +2202,14 @@ void Kart::crashed(const Material *m, const Vec3 &normal)
|
||||
*/
|
||||
void Kart::playCrashSFX(const Material* m, AbstractKart *k)
|
||||
{
|
||||
if(World::getWorld()->getTimeSinceStart()-m_time_last_crash < 0.5f) return;
|
||||
int ticks_since_start = World::getWorld()->getTicksSinceStart();
|
||||
if(ticks_since_start-m_ticks_last_crash < 0.5f) return;
|
||||
|
||||
m_time_last_crash = World::getWorld()->getTimeSinceStart();
|
||||
m_ticks_last_crash = ticks_since_start;
|
||||
// After a collision disable the engine for a short time so that karts
|
||||
// can 'bounce back' a bit (without this the engine force will prevent
|
||||
// karts from bouncing back, they will instead stuck towards the obstable).
|
||||
if(m_bounce_back_time<=0.0f)
|
||||
if(m_bounce_back_ticks <= 0)
|
||||
{
|
||||
if (getVelocity().length()> 0.555f)
|
||||
{
|
||||
@ -2243,7 +2253,7 @@ void Kart::playCrashSFX(const Material* m, AbstractKart *k)
|
||||
crash_sound_emitter->play(getXYZ(), buffer);
|
||||
}
|
||||
} // if lin_vel > 0.555
|
||||
} // if m_bounce_back_time <= 0
|
||||
} // if m_bounce_back_ticks <= 0
|
||||
} // playCrashSFX
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -2326,9 +2336,9 @@ bool Kart::playCustomSFX(unsigned int type)
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Updates the physics for this kart: computing the driving force, set
|
||||
* steering, handles skidding, terrain impact on kart, ...
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number if physics time steps - should be 1.
|
||||
*/
|
||||
void Kart::updatePhysics(float dt)
|
||||
void Kart::updatePhysics(int ticks)
|
||||
{
|
||||
// Check if accel is pressed for the first time. The actual timing
|
||||
// is done in getStartupBoost - it returns 0 if the start was actually
|
||||
@ -2341,22 +2351,22 @@ void Kart::updatePhysics(float dt)
|
||||
{
|
||||
m_kart_gfx->setCreationRateAbsolute(KartGFX::KGFX_ZIPPER, 100*f);
|
||||
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
|
||||
0.9f*f, f,
|
||||
/*engine_force*/200.0f,
|
||||
/*duration*/5.0f,
|
||||
/*fade_out_time*/5.0f);
|
||||
0.9f*f, f,
|
||||
/*engine_force*/200.0f,
|
||||
/*duration*/stk_config->time2Ticks(5.0f),
|
||||
/*fade_out_time*/stk_config->time2Ticks(5.0f));
|
||||
}
|
||||
}
|
||||
|
||||
m_bounce_back_time-=dt;
|
||||
m_bounce_back_ticks-=ticks;
|
||||
|
||||
updateEnginePowerAndBrakes(dt);
|
||||
updateEnginePowerAndBrakes(ticks);
|
||||
|
||||
// apply flying physics if relevant
|
||||
if (m_flying)
|
||||
updateFlying();
|
||||
|
||||
m_skidding->update(dt, isOnGround(), m_controls.getSteer(),
|
||||
m_skidding->update(ticks, isOnGround(), m_controls.getSteer(),
|
||||
m_controls.getSkidControl());
|
||||
m_vehicle->setVisualRotation(m_skidding->getVisualSkidRotation());
|
||||
if(( m_skidding->getSkidState() == Skidding::SKID_ACCUMULATE_LEFT ||
|
||||
@ -2382,10 +2392,10 @@ void Kart::updatePhysics(float dt)
|
||||
|
||||
float min_speed = m && m->isZipper() ? m->getZipperMinSpeed() : -1.0f;
|
||||
m_max_speed->setMinSpeed(min_speed);
|
||||
m_max_speed->update(dt);
|
||||
m_max_speed->update(ticks);
|
||||
|
||||
|
||||
updateEngineSFX(dt);
|
||||
updateEngineSFX(stk_config->ticks2Time(ticks));
|
||||
#ifdef XX
|
||||
Log::info("Kart","angVel %f %f %f heading %f suspension %f %f %f %f"
|
||||
,m_body->getAngularVelocity().getX()
|
||||
@ -2446,9 +2456,9 @@ void Kart::updateEngineSFX(float dt)
|
||||
/** Sets the engine power. It considers the engine specs, items that influence
|
||||
* the available power, and braking/steering.
|
||||
*/
|
||||
void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
void Kart::updateEnginePowerAndBrakes(int ticks)
|
||||
{
|
||||
updateNitro(dt);
|
||||
updateNitro(ticks);
|
||||
float engine_power = getActualWheelForce();
|
||||
|
||||
// apply parachute physics if relevant
|
||||
@ -2456,7 +2466,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
engine_power*=0.2f;
|
||||
|
||||
// apply bubblegum physics if relevant
|
||||
if (m_bubblegum_time > 0.0f)
|
||||
if (m_bubblegum_ticks > 0)
|
||||
{
|
||||
engine_power = 0.0f;
|
||||
m_body->applyTorque(btVector3(0.0, m_bubblegum_torque, 0.0));
|
||||
@ -2466,7 +2476,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
{
|
||||
// For a short time after a collision disable the engine,
|
||||
// so that the karts can bounce back a bit from the obstacle.
|
||||
if(m_bounce_back_time>0.0f)
|
||||
if(m_bounce_back_ticks>0.0f)
|
||||
engine_power = 0.0f;
|
||||
// let a player going backwards accelerate quickly (e.g. if a player
|
||||
// hits a wall, he needs to be able to start again quickly after
|
||||
@ -2486,7 +2496,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
if(m_vehicle->getWheelInfo(0).m_brake &&
|
||||
!World::getWorld()->isStartPhase())
|
||||
m_vehicle->setAllBrakes(0);
|
||||
m_brake_time = 0;
|
||||
m_brake_ticks = 0;
|
||||
}
|
||||
else
|
||||
{ // not accelerating
|
||||
@ -2496,10 +2506,10 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
if(m_speed > 0.0f)
|
||||
{ // Still going forward while braking
|
||||
applyEngineForce(-engine_power*2.5f);
|
||||
m_brake_time += dt;
|
||||
m_brake_ticks += ticks;
|
||||
// Apply the brakes - include the time dependent brake increase
|
||||
float f = 1 + m_brake_time
|
||||
* m_kart_properties->getEngineBrakeTimeIncrease();
|
||||
float f = 1.0f + stk_config->ticks2Time(m_brake_ticks)
|
||||
* m_kart_properties->getEngineBrakeTimeIncrease();
|
||||
m_vehicle->setAllBrakes(m_kart_properties->getEngineBrakeFactor() * f);
|
||||
}
|
||||
else // m_speed < 0
|
||||
@ -2524,7 +2534,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
}
|
||||
else // !m_brake
|
||||
{
|
||||
m_brake_time = 0;
|
||||
m_brake_ticks = 0;
|
||||
// lift the foot from throttle, brakes with 10% engine_power
|
||||
assert(!std::isnan(m_controls.getAccel()));
|
||||
assert(!std::isnan(engine_power));
|
||||
@ -2846,14 +2856,14 @@ SFXBase* Kart::getNextEmitter()
|
||||
* \param offset_xyz Offset to be added to the position.
|
||||
* \param rotation Additional rotation.
|
||||
*/
|
||||
void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
void Kart::updateGraphics(int ticks, const Vec3& offset_xyz,
|
||||
const btQuaternion& rotation)
|
||||
{
|
||||
// Upate particle effects (creation rate, and emitter size
|
||||
// depending on speed)
|
||||
// --------------------------------------------------------
|
||||
float nitro_frac = 0;
|
||||
if ( (m_controls.getNitro() || m_min_nitro_time > 0.0f) &&
|
||||
if ( (m_controls.getNitro() || m_min_nitro_ticks > 0) &&
|
||||
isOnGround() && m_collected_energy > 0 )
|
||||
{
|
||||
// fabs(speed) is important, otherwise the negative number will
|
||||
@ -2881,6 +2891,8 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
const float steer_frac = m_skidding->getSteeringFraction();
|
||||
|
||||
const float roll_speed = m_kart_properties->getLeanSpeed() * DEGREE_TO_RAD;
|
||||
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if(speed_frac > 0.8f && fabsf(steer_frac)>0.5f)
|
||||
{
|
||||
// Use steering ^ 7, which means less effect at lower
|
||||
@ -2933,7 +2945,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
center_shift = getTrans().getBasis() * center_shift;
|
||||
|
||||
float heading = m_skidding->getVisualSkidRotation();
|
||||
Moveable::updateGraphics(dt, center_shift,
|
||||
Moveable::updateGraphics(ticks, center_shift,
|
||||
btQuaternion(heading, 0, -m_current_lean));
|
||||
|
||||
// m_speed*dt is the distance the kart has moved, which determines
|
||||
|
@ -133,24 +133,24 @@ protected:
|
||||
|
||||
/** How long the brake key has been pressed - the longer the harder
|
||||
* the kart will brake. */
|
||||
float m_brake_time;
|
||||
int m_brake_ticks;
|
||||
|
||||
/** A short time after a collision acceleration is disabled to allow
|
||||
* the karts to bounce back*/
|
||||
float m_bounce_back_time;
|
||||
int m_bounce_back_ticks;
|
||||
|
||||
/** Time a kart is invulnerable. */
|
||||
float m_invulnerable_time;
|
||||
int m_invulnerable_ticks;
|
||||
|
||||
/** How long a kart is being squashed. If this is >0
|
||||
* the kart is squashed. */
|
||||
float m_squash_time;
|
||||
int m_squash_ticks;
|
||||
|
||||
/** Current leaning of the kart. */
|
||||
float m_current_lean;
|
||||
|
||||
/** If > 0 then bubble gum effect is on. This is the sliding when hitting a gum on the floor, not the shield. */
|
||||
float m_bubblegum_time;
|
||||
int m_bubblegum_ticks;
|
||||
|
||||
/** The torque to apply after hitting a bubble gum. */
|
||||
float m_bubblegum_torque;
|
||||
@ -159,7 +159,7 @@ protected:
|
||||
bool m_fire_clicked;
|
||||
|
||||
/** Counter which is used for displaying wrong way message after a delay */
|
||||
float m_wrongway_counter;
|
||||
int m_wrongway_counter;
|
||||
|
||||
|
||||
// Bullet physics parameters
|
||||
@ -193,11 +193,11 @@ protected:
|
||||
float m_finish_time;
|
||||
bool m_finished_race;
|
||||
|
||||
float m_falling_time = 0.35f;
|
||||
int m_falling_ticks;
|
||||
|
||||
/** When a kart has its view blocked by the plunger, this variable will be
|
||||
* > 0 the number it contains is the time left before removing plunger. */
|
||||
float m_view_blocked_by_plunger;
|
||||
int m_view_blocked_by_plunger;
|
||||
/** The current speed (i.e. length of velocity vector) of this kart. */
|
||||
float m_speed;
|
||||
/** For camera handling an exponentially smoothened value is used, which
|
||||
@ -223,21 +223,21 @@ protected:
|
||||
SFXBuffer *m_crash_sounds[CRASH_SOUND_COUNT];
|
||||
SFXBuffer *m_goo_sound;
|
||||
SFXBuffer *m_boing_sound;
|
||||
float m_time_last_crash;
|
||||
int m_ticks_last_crash;
|
||||
RaceManager::KartType m_type;
|
||||
|
||||
/** To prevent using nitro in too short bursts */
|
||||
float m_min_nitro_time;
|
||||
int m_min_nitro_ticks;
|
||||
|
||||
void updatePhysics(float dt);
|
||||
void updatePhysics(int ticks);
|
||||
void handleMaterialSFX(const Material *material);
|
||||
void handleMaterialGFX(float dt);
|
||||
void handleMaterialGFX(int ticks);
|
||||
void updateFlying();
|
||||
void updateSliding();
|
||||
void updateEnginePowerAndBrakes(float dt);
|
||||
void updateEnginePowerAndBrakes(int ticks);
|
||||
void updateEngineSFX(float dt);
|
||||
void updateSpeed();
|
||||
void updateNitro(float dt);
|
||||
void updateNitro(int ticks);
|
||||
float getActualWheelForce();
|
||||
void playCrashSFX(const Material* m, AbstractKart *k);
|
||||
void loadData(RaceManager::KartType type, bool animatedModel);
|
||||
@ -250,7 +250,7 @@ public:
|
||||
virtual ~Kart();
|
||||
virtual void init(RaceManager::KartType type);
|
||||
virtual void kartIsInRestNow();
|
||||
virtual void updateGraphics(float dt, const Vec3& off_xyz,
|
||||
virtual void updateGraphics(int ticks, const Vec3& off_xyz,
|
||||
const btQuaternion& off_rotation);
|
||||
virtual void createPhysics ();
|
||||
virtual void updateWeight ();
|
||||
@ -265,11 +265,11 @@ public:
|
||||
virtual void startEngineSFX ();
|
||||
virtual void adjustSpeed (float f);
|
||||
virtual void increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time);
|
||||
float engine_force, int duration,
|
||||
int fade_out_time);
|
||||
virtual void setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
float fade_in_time);
|
||||
virtual float getSpeedIncreaseTimeLeft(unsigned int category) const;
|
||||
int fade_in_time);
|
||||
virtual int getSpeedIncreaseTicksLeft(unsigned int category) const OVERRIDE;
|
||||
virtual void collectedItem(Item *item, int random_attachment);
|
||||
virtual float getStartupBoost() const;
|
||||
|
||||
@ -286,7 +286,7 @@ public:
|
||||
virtual void crashed (AbstractKart *k, bool update_attachments);
|
||||
virtual void crashed (const Material *m, const Vec3 &normal);
|
||||
virtual float getHoT () const;
|
||||
virtual void update (float dt);
|
||||
virtual void update (int ticks);
|
||||
virtual void finishedRace (float time, bool from_server=false);
|
||||
virtual void setPosition (int p);
|
||||
virtual void beep ();
|
||||
@ -335,7 +335,7 @@ public:
|
||||
virtual bool hasFinishedRace () const { return m_finished_race; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns true if the kart has a plunger attached to its face. */
|
||||
virtual float getBlockedByPlungerTime() const
|
||||
virtual int getBlockedByPlungerTicks() const
|
||||
{ return m_view_blocked_by_plunger; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets that the view is blocked by a plunger. The duration depends on
|
||||
@ -416,10 +416,13 @@ public:
|
||||
virtual void eliminate();
|
||||
// ------------------------------------------------------------------------
|
||||
/** Makes a kart invulnerable for a certain amount of time. */
|
||||
virtual void setInvulnerableTime(float t) { m_invulnerable_time = t; }
|
||||
virtual void setInvulnerableTicks(int ticks) OVERRIDE
|
||||
{
|
||||
m_invulnerable_ticks = ticks;
|
||||
} // setInvulnerableTicks
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if the kart is invulnerable. */
|
||||
virtual bool isInvulnerable() const { return m_invulnerable_time > 0; }
|
||||
virtual bool isInvulnerable() const { return m_invulnerable_ticks > 0; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Enables a kart shield protection for a certain amount of time. */
|
||||
virtual void setShieldTime(float t);
|
||||
@ -440,10 +443,10 @@ public:
|
||||
/** Return whether nitro is being used despite the nitro button not being
|
||||
* pressed due to minimal use time requirements
|
||||
*/
|
||||
virtual float isOnMinNitroTime() const { return m_min_nitro_time > 0.0f; }
|
||||
virtual bool isOnMinNitroTime() const { return m_min_nitro_ticks > 0; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns if the kart is currently being squashed. */
|
||||
virtual bool isSquashed() const { return m_squash_time >0; }
|
||||
virtual bool isSquashed() const { return m_squash_ticks >0; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Shows the star effect for a certain time. */
|
||||
virtual void showStarEffect(float t);
|
||||
@ -461,9 +464,9 @@ public:
|
||||
bool isFlying() const { return m_flying; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Counter which is used for displaying wrong way message after a delay */
|
||||
float getWrongwayCounter() { return m_wrongway_counter; }
|
||||
int getWrongwayCounter() { return m_wrongway_counter; }
|
||||
// ------------------------------------------------------------------------
|
||||
void setWrongwayCounter(float counter) { m_wrongway_counter = counter; }
|
||||
void setWrongwayCounter(int counter) { m_wrongway_counter = counter; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns whether this kart wins or loses. */
|
||||
virtual bool getRaceResult() const { return m_race_result; }
|
||||
|
@ -773,13 +773,13 @@ float KartProperties::getParachuteFriction() const
|
||||
} // getParachuteFriction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getParachuteDuration() const
|
||||
int KartProperties::getParachuteDuration() const
|
||||
{
|
||||
return m_cached_characteristic->getParachuteDuration();
|
||||
} // getParachuteDuration
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getParachuteDurationOther() const
|
||||
int KartProperties::getParachuteDurationOther() const
|
||||
{
|
||||
return m_cached_characteristic->getParachuteDurationOther();
|
||||
} // getParachuteDurationOther
|
||||
@ -839,9 +839,10 @@ float KartProperties::getBubblegumTorque() const
|
||||
} // getBubblegumTorque
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getBubblegumFadeInTime() const
|
||||
int KartProperties::getBubblegumFadeInTicks() const
|
||||
{
|
||||
return m_cached_characteristic->getBubblegumFadeInTime();
|
||||
return stk_config->time2Ticks(m_cached_characteristic
|
||||
->getBubblegumFadeInTime());
|
||||
} // getBubblegumFadeInTime
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -929,9 +930,10 @@ float KartProperties::getPlungerBandSpeedIncrease() const
|
||||
} // getPlungerBandSpeedIncrease
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getPlungerBandFadeOutTime() const
|
||||
int KartProperties::getPlungerBandFadeOutTicks() const
|
||||
{
|
||||
return m_cached_characteristic->getPlungerBandFadeOutTime();
|
||||
return stk_config->time2Ticks(m_cached_characteristic
|
||||
->getPlungerBandFadeOutTime());
|
||||
} // getPlungerBandFadeOutTime
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -994,6 +996,15 @@ float KartProperties::getNitroDuration() const
|
||||
return m_cached_characteristic->getNitroDuration();
|
||||
} // getNitroDuration
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns minimum time during which nitro is consumed when pressing nitro
|
||||
* key, to prevent using nitro in very short bursts
|
||||
*/
|
||||
int KartProperties::getNitroMinConsumptionTicks() const
|
||||
{
|
||||
return stk_config->time2Ticks(m_nitro_min_consumption);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getNitroEngineForce() const
|
||||
{
|
||||
@ -1037,9 +1048,10 @@ float KartProperties::getNitroMax() const
|
||||
} // getNitroMax
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getSlipstreamDuration() const
|
||||
int KartProperties::getSlipstreamDuration() const
|
||||
{
|
||||
return m_cached_characteristic->getSlipstreamDuration();
|
||||
return stk_config->time2Ticks( m_cached_characteristic
|
||||
->getSlipstreamDuration() );
|
||||
} // getSlipstreamDuration
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1055,9 +1067,9 @@ float KartProperties::getSlipstreamWidth() const
|
||||
} // getSlipstreamWidth
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getSlipstreamCollectTime() const
|
||||
int KartProperties::getSlipstreamCollectTicks() const
|
||||
{
|
||||
return m_cached_characteristic->getSlipstreamCollectTime();
|
||||
return m_cached_characteristic->getSlipstreamCollectTicks();
|
||||
} // getSlipstreamCollectTime
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1085,9 +1097,10 @@ float KartProperties::getSlipstreamMaxSpeedIncrease() const
|
||||
} // getSlipstreamMaxSpeedIncrease
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
float KartProperties::getSlipstreamFadeOutTime() const
|
||||
int KartProperties::getSlipstreamFadeOutTicks() const
|
||||
{
|
||||
return m_cached_characteristic->getSlipstreamFadeOutTime();
|
||||
return stk_config->time2Ticks(m_cached_characteristic
|
||||
->getSlipstreamFadeOutTime());
|
||||
} // getSlipstreamFadeOutTime
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -352,11 +352,6 @@ public:
|
||||
/** Returns the full path where the files for this kart are stored. */
|
||||
const std::string& getKartDir () const {return m_root; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns minimum time during which nitro is consumed when pressing nitro
|
||||
* key, to prevent using nitro in very short bursts
|
||||
*/
|
||||
float getNitroMinConsumptionTime() const { return m_nitro_min_consumption; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the bevel factor (!=0 indicates to use a bevelled box). */
|
||||
const Vec3 &getBevelFactor() const { return m_bevel_factor; }
|
||||
@ -427,8 +422,8 @@ public:
|
||||
float getAnvilSpeedFactor() const;
|
||||
|
||||
float getParachuteFriction() const;
|
||||
float getParachuteDuration() const;
|
||||
float getParachuteDurationOther() const;
|
||||
int getParachuteDuration() const;
|
||||
int getParachuteDurationOther() const;
|
||||
float getParachuteDurationRankMult() const;
|
||||
float getParachuteDurationSpeedMult() const;
|
||||
float getParachuteLboundFraction() const;
|
||||
@ -440,7 +435,7 @@ public:
|
||||
float getBubblegumDuration() const;
|
||||
float getBubblegumSpeedFraction() const;
|
||||
float getBubblegumTorque() const;
|
||||
float getBubblegumFadeInTime() const;
|
||||
int getBubblegumFadeInTicks() const;
|
||||
float getBubblegumShieldDuration() const;
|
||||
|
||||
float getZipperDuration() const;
|
||||
@ -458,7 +453,7 @@ public:
|
||||
float getPlungerBandForce() const;
|
||||
float getPlungerBandDuration() const;
|
||||
float getPlungerBandSpeedIncrease() const;
|
||||
float getPlungerBandFadeOutTime() const;
|
||||
int getPlungerBandFadeOutTicks() const;
|
||||
float getPlungerInFaceTime() const;
|
||||
|
||||
std::vector<float> getStartupTime() const;
|
||||
@ -480,16 +475,18 @@ public:
|
||||
float getNitroMaxSpeedIncrease() const;
|
||||
float getNitroFadeOutTime() const;
|
||||
float getNitroMax() const;
|
||||
int getNitroMinConsumptionTicks() const;
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
float getSlipstreamDuration() const;
|
||||
int getSlipstreamDuration() const;
|
||||
float getSlipstreamLength() const;
|
||||
float getSlipstreamWidth() const;
|
||||
float getSlipstreamCollectTime() const;
|
||||
int getSlipstreamCollectTicks() const;
|
||||
float getSlipstreamUseTime() const;
|
||||
float getSlipstreamAddPower() const;
|
||||
float getSlipstreamMinSpeed() const;
|
||||
float getSlipstreamMaxSpeedIncrease() const;
|
||||
float getSlipstreamFadeOutTime() const;
|
||||
int getSlipstreamFadeOutTicks() const;
|
||||
|
||||
float getSkidIncrease() const;
|
||||
float getSkidDecrease() const;
|
||||
|
@ -181,9 +181,9 @@ void KartRewinder::rewindToState(BareNetworkString *buffer)
|
||||
/** Called once a frame. It will add a new kart control event to the rewind
|
||||
* manager if any control values have changed.
|
||||
*/
|
||||
void KartRewinder::update(float dt)
|
||||
void KartRewinder::update(int ticks)
|
||||
{
|
||||
Kart::update(dt);
|
||||
Kart::update(ticks);
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -49,7 +49,7 @@ public:
|
||||
void reset();
|
||||
virtual void rewindToState(BareNetworkString *p) OVERRIDE;
|
||||
virtual void rewindToEvent(BareNetworkString *p) OVERRIDE;
|
||||
virtual void update(float dt);
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
virtual void undoState(BareNetworkString *p) OVERRIDE
|
||||
|
@ -58,10 +58,11 @@ void KartWithStats::reset()
|
||||
* statistics for this kart.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void KartWithStats::update(float dt)
|
||||
void KartWithStats::update(int ticks)
|
||||
{
|
||||
Kart::update(dt);
|
||||
Kart::update(ticks);
|
||||
if(getSpeed()>m_top_speed ) m_top_speed = getSpeed();
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if(getControls().getSkidControl()) m_skidding_time += dt;
|
||||
if(getControls().getBrake() ) m_brake_count ++;
|
||||
LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld());
|
||||
|
@ -76,7 +76,7 @@ public:
|
||||
int position,
|
||||
const btTransform& init_transform,
|
||||
PerPlayerDifficulty difficulty);
|
||||
virtual void update(float dt);
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
virtual void reset();
|
||||
virtual void collectedItem(Item *item, int add_info);
|
||||
virtual void setKartAnimation(AbstractKartAnimation *ka);
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
#include "karts/max_speed.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "physics/btKart.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
|
||||
/** This class handles maximum speed for karts. Several factors can influence
|
||||
* the maximum speed a kart can drive, some will decrease the maximum speed,
|
||||
* some will increase the maximum speed.
|
||||
@ -88,8 +89,8 @@ void MaxSpeed::reset()
|
||||
* \param fade_out_time How long the maximum speed will fade out linearly.
|
||||
*/
|
||||
void MaxSpeed::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time)
|
||||
float engine_force, int duration,
|
||||
int fade_out_time)
|
||||
{
|
||||
// Allow fade_out_time 0 if add_speed is set to 0.
|
||||
assert(add_speed==0.0f || fade_out_time>0.01f);
|
||||
@ -117,8 +118,8 @@ void MaxSpeed::increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
*/
|
||||
void MaxSpeed::instantSpeedIncrease(unsigned int category,
|
||||
float add_max_speed, float speed_boost,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time)
|
||||
float engine_force, int duration,
|
||||
int fade_out_time)
|
||||
{
|
||||
increaseMaxSpeed(category, add_max_speed, engine_force, duration,
|
||||
fade_out_time);
|
||||
@ -144,9 +145,9 @@ void MaxSpeed::instantSpeedIncrease(unsigned int category,
|
||||
* -m_fade_out_time and 0, the maximum speed will linearly decrease.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void MaxSpeed::SpeedIncrease::update(float dt)
|
||||
void MaxSpeed::SpeedIncrease::update(int ticks)
|
||||
{
|
||||
m_duration -= dt;
|
||||
m_duration -= ticks;
|
||||
// End of increased max speed reached.
|
||||
if(m_duration < -m_fade_out_time)
|
||||
{
|
||||
@ -157,15 +158,15 @@ void MaxSpeed::SpeedIncrease::update(float dt)
|
||||
if(m_duration >0) return;
|
||||
|
||||
// Now we are in the fade out period: decrease time linearly
|
||||
m_current_speedup -= dt*m_max_add_speed/m_fade_out_time;
|
||||
m_current_speedup -= ticks*m_max_add_speed/m_fade_out_time;
|
||||
} // SpeedIncrease::update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void MaxSpeed::SpeedIncrease::saveState(BareNetworkString *buffer) const
|
||||
{
|
||||
buffer->addFloat(m_max_add_speed);
|
||||
buffer->addFloat(m_duration);
|
||||
buffer->addFloat(m_fade_out_time);
|
||||
buffer->addUInt32(m_duration);
|
||||
buffer->addUInt32(m_fade_out_time);
|
||||
buffer->addFloat(m_current_speedup);
|
||||
buffer->addFloat(m_engine_force);
|
||||
} // saveState
|
||||
@ -177,8 +178,8 @@ void MaxSpeed::SpeedIncrease::rewindTo(BareNetworkString *buffer,
|
||||
if(is_active)
|
||||
{
|
||||
m_max_add_speed = buffer->getFloat();
|
||||
m_duration = buffer->getFloat();
|
||||
m_fade_out_time = buffer->getFloat();
|
||||
m_duration = buffer->getUInt32();
|
||||
m_fade_out_time = buffer->getUInt32();
|
||||
m_current_speedup = buffer->getFloat();
|
||||
m_engine_force = buffer->getFloat();
|
||||
}
|
||||
@ -198,7 +199,7 @@ void MaxSpeed::SpeedIncrease::rewindTo(BareNetworkString *buffer,
|
||||
* value is changed to something else).
|
||||
*/
|
||||
void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
float fade_in_time, float duration)
|
||||
int fade_in_time, int duration)
|
||||
{
|
||||
assert(category>=MS_DECREASE_MIN && category <MS_DECREASE_MAX);
|
||||
m_speed_decrease[category].m_max_speed_fraction = max_speed_fraction;
|
||||
@ -210,12 +211,12 @@ void MaxSpeed::setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
/** Handles the speed increase for a certain category.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void MaxSpeed::SpeedDecrease::update(float dt)
|
||||
void MaxSpeed::SpeedDecrease::update(int ticks)
|
||||
{
|
||||
if(m_duration>-1.0f)
|
||||
if(m_duration>-1)
|
||||
{
|
||||
// It's a timed slowdown
|
||||
m_duration -= dt;
|
||||
m_duration -= ticks;
|
||||
if(m_duration<0)
|
||||
{
|
||||
m_duration = 0;
|
||||
@ -228,8 +229,9 @@ void MaxSpeed::SpeedDecrease::update(float dt)
|
||||
float diff = m_current_fraction - m_max_speed_fraction;
|
||||
if(diff > 0)
|
||||
{
|
||||
if (diff * m_fade_in_time > dt)
|
||||
m_current_fraction -= dt/m_fade_in_time;
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
if (diff * m_fade_in_time > ticks)
|
||||
m_current_fraction -= float(dt)/m_fade_in_time;
|
||||
else
|
||||
m_current_fraction = m_max_speed_fraction;
|
||||
}
|
||||
@ -245,9 +247,9 @@ void MaxSpeed::SpeedDecrease::update(float dt)
|
||||
void MaxSpeed::SpeedDecrease::saveState(BareNetworkString *buffer) const
|
||||
{
|
||||
buffer->addFloat(m_max_speed_fraction);
|
||||
buffer->addFloat(m_fade_in_time);
|
||||
buffer->addUInt32(m_fade_in_time);
|
||||
buffer->addFloat(m_current_fraction);
|
||||
buffer->addFloat(m_duration);
|
||||
buffer->addUInt32(m_duration);
|
||||
} // saveState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -259,9 +261,9 @@ void MaxSpeed::SpeedDecrease::rewindTo(BareNetworkString *buffer,
|
||||
if(is_active)
|
||||
{
|
||||
m_max_speed_fraction = buffer->getFloat();
|
||||
m_fade_in_time = buffer->getFloat();
|
||||
m_fade_in_time = buffer->getUInt32();
|
||||
m_current_fraction = buffer->getFloat();
|
||||
m_duration = buffer->getFloat();
|
||||
m_duration = buffer->getUInt32();
|
||||
}
|
||||
else // make sure it is not active
|
||||
{
|
||||
@ -273,7 +275,7 @@ void MaxSpeed::SpeedDecrease::rewindTo(BareNetworkString *buffer,
|
||||
/** Returns how much increased speed time is left over in the given category.
|
||||
* \param category Which category to report on.
|
||||
*/
|
||||
float MaxSpeed::getSpeedIncreaseTimeLeft(unsigned int category)
|
||||
int MaxSpeed::getSpeedIncreaseTicksLeft(unsigned int category)
|
||||
{
|
||||
return m_speed_increase[category].getTimeLeft();
|
||||
} // getSpeedIncreaseTimeLeft
|
||||
@ -285,7 +287,7 @@ float MaxSpeed::getSpeedIncreaseTimeLeft(unsigned int category)
|
||||
* change to any of the speed increase/decrease objects will be done.
|
||||
* \param dt Time step size (dt=0 only updates the current maximum speed).
|
||||
*/
|
||||
void MaxSpeed::update(float dt)
|
||||
void MaxSpeed::update(int ticks)
|
||||
{
|
||||
|
||||
// First compute the minimum max-speed fraction, which
|
||||
@ -295,7 +297,7 @@ void MaxSpeed::update(float dt)
|
||||
for(unsigned int i=MS_DECREASE_MIN; i<MS_DECREASE_MAX; i++)
|
||||
{
|
||||
SpeedDecrease &slowdown = m_speed_decrease[i];
|
||||
slowdown.update(dt);
|
||||
slowdown.update(ticks);
|
||||
slowdown_factor = std::min(slowdown_factor,
|
||||
slowdown.getSlowdownFraction());
|
||||
}
|
||||
@ -308,7 +310,7 @@ void MaxSpeed::update(float dt)
|
||||
for(unsigned int i=MS_INCREASE_MIN; i<MS_INCREASE_MAX; i++)
|
||||
{
|
||||
SpeedIncrease &speedup = m_speed_increase[i];
|
||||
speedup.update(dt);
|
||||
speedup.update(ticks);
|
||||
m_current_max_speed += speedup.getSpeedIncrease();
|
||||
m_add_engine_force += speedup.getEngineForce();
|
||||
}
|
||||
|
@ -71,9 +71,9 @@ private:
|
||||
* to the duration will be decreased. When the duration is <0, the
|
||||
* fade out time starts, and duration will go down to
|
||||
* -m_fade_out_time before this speed increase stops. */
|
||||
float m_duration;
|
||||
int m_duration;
|
||||
/** The fadeout time. */
|
||||
float m_fade_out_time;
|
||||
int m_fade_out_time;
|
||||
/** The current max speed increase value. */
|
||||
float m_current_speedup;
|
||||
/** Additional engine force. */
|
||||
@ -96,7 +96,7 @@ private:
|
||||
m_engine_force = 0;
|
||||
} // reset
|
||||
// --------------------------------------------------------------------
|
||||
void update(float dt);
|
||||
void update(int ticks);
|
||||
void saveState(BareNetworkString *buffer) const;
|
||||
void rewindTo(BareNetworkString *buffer, bool is_active);
|
||||
// --------------------------------------------------------------------
|
||||
@ -107,7 +107,7 @@ private:
|
||||
* Note that this function will return a negative value if
|
||||
* the fade_out time has started or this speed increase has
|
||||
* expired. */
|
||||
float getTimeLeft() const {return m_duration; }
|
||||
int getTimeLeft() const {return m_duration; }
|
||||
// --------------------------------------------------------------------
|
||||
/** Returns the additional engine force for this speed increase. */
|
||||
float getEngineForce() const
|
||||
@ -127,14 +127,14 @@ private:
|
||||
/** The maximum slowdown to apply. */
|
||||
float m_max_speed_fraction;
|
||||
/** How long it should take for the full slowdown to take effect. */
|
||||
float m_fade_in_time;
|
||||
int m_fade_in_time;
|
||||
/** The current slowdown fraction, taking the fade-in time
|
||||
* into account. */
|
||||
float m_current_fraction;
|
||||
|
||||
/** How long the effect should last. A -1.0f as value indicates
|
||||
* that this effect stays active till it is changed back. */
|
||||
float m_duration;
|
||||
int m_duration;
|
||||
|
||||
/** The constructor initialises the data with data that won't
|
||||
* affect top speed at all. */
|
||||
@ -147,12 +147,12 @@ private:
|
||||
void reset()
|
||||
{
|
||||
m_max_speed_fraction = 1.0f;
|
||||
m_fade_in_time = 0.0f;
|
||||
m_current_fraction = 1.0f;
|
||||
m_duration = 0.0f;
|
||||
m_fade_in_time = 0;
|
||||
m_duration = 0;
|
||||
} //reset
|
||||
// --------------------------------------------------------------------
|
||||
void update(float dt);
|
||||
void update(int ticks);
|
||||
void saveState(BareNetworkString *buffer) const;
|
||||
void rewindTo(BareNetworkString *buffer, bool is_active);
|
||||
// --------------------------------------------------------------------
|
||||
@ -179,16 +179,16 @@ public:
|
||||
MaxSpeed(AbstractKart *kart);
|
||||
|
||||
void increaseMaxSpeed(unsigned int category, float add_speed,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time);
|
||||
float engine_force, int duration,
|
||||
int fade_out_time);
|
||||
void instantSpeedIncrease(unsigned int category,
|
||||
float add_speed, float speed_boost,
|
||||
float engine_force, float duration,
|
||||
float fade_out_time/*=1.0f*/);
|
||||
float engine_force, int duration,
|
||||
int fade_out_time);
|
||||
void setSlowdown(unsigned int category, float max_speed_fraction,
|
||||
float fade_in_time, float duration=-1.0f);
|
||||
float getSpeedIncreaseTimeLeft(unsigned int category);
|
||||
void update(float dt);
|
||||
int fade_in_time, int duration=-1);
|
||||
int getSpeedIncreaseTicksLeft(unsigned int category);
|
||||
void update(int ticks);
|
||||
void reset();
|
||||
void saveState(BareNetworkString *buffer) const;
|
||||
void rewindTo(BareNetworkString *buffer);
|
||||
|
@ -72,10 +72,12 @@ void Moveable::addError(const Vec3& pos_error,
|
||||
const btQuaternion &rot_error)
|
||||
{
|
||||
m_positional_error += pos_error;
|
||||
#ifdef DEBUG_VISUAL_ERROR
|
||||
Log::info("VisualError", "time %f addError %f %f %f size %f",
|
||||
World::getWorld()->getTime(),
|
||||
m_positional_error.getX(), m_positional_error.getY(), m_positional_error.getZ(),
|
||||
m_positional_error.length());
|
||||
#endif
|
||||
m_rotational_error *= rot_error;
|
||||
} // addError
|
||||
|
||||
@ -86,7 +88,7 @@ void Moveable::addError(const Vec3& pos_error,
|
||||
* \param offset_xyz Offset to be added to the position.
|
||||
* \param rotation Additional rotation.
|
||||
*/
|
||||
void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
void Moveable::updateGraphics(int ticks, const Vec3& offset_xyz,
|
||||
const btQuaternion& rotation)
|
||||
{
|
||||
// If this is a client, don't smooth error during rewinds
|
||||
@ -96,10 +98,12 @@ void Moveable::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
{
|
||||
float error = m_positional_error.length();
|
||||
m_positional_error *= stk_config->m_positional_smoothing.get(error);
|
||||
#ifdef DEBUG_VISUAL_ERROR
|
||||
Log::info("VisualError", "time %f reduceError %f %f %f size %f",
|
||||
World::getWorld()->getTime(),
|
||||
m_positional_error.getX(), m_positional_error.getY(), m_positional_error.getZ(),
|
||||
m_positional_error.length());
|
||||
#endif
|
||||
}
|
||||
#ifndef SERVER_ONLY
|
||||
Vec3 xyz=getXYZ()+offset_xyz - m_positional_error;
|
||||
@ -161,16 +165,16 @@ void Moveable::stopFlying()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the current position and rotation from the corresponding physics
|
||||
* body, and then calls updateGraphics to position the model correctly.
|
||||
* \param float dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void Moveable::update(float dt)
|
||||
void Moveable::update(int ticks)
|
||||
{
|
||||
if(m_body->getInvMass()!=0)
|
||||
m_motion_state->getWorldTransform(m_transform);
|
||||
m_velocityLC = getVelocity()*m_transform.getBasis();
|
||||
updatePosition();
|
||||
|
||||
updateGraphics(dt, Vec3(0,0,0), btQuaternion(0, 0, 0, 1));
|
||||
updateGraphics(ticks, Vec3(0,0,0), btQuaternion(0, 0, 0, 1));
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -116,10 +116,10 @@ public:
|
||||
m_motion_state->setWorldTransform(m_transform);
|
||||
} // setRotation(btQuaternion)
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void updateGraphics(float dt, const Vec3& off_xyz,
|
||||
virtual void updateGraphics(int ticks, const Vec3& off_xyz,
|
||||
const btQuaternion& off_rotation);
|
||||
virtual void reset();
|
||||
virtual void update(float dt) ;
|
||||
virtual void update(int ticks) ;
|
||||
btRigidBody *getBody() const {return m_body; }
|
||||
void createBody(float mass, btTransform& trans,
|
||||
btCollisionShape *shape,
|
||||
|
@ -225,15 +225,17 @@ float Skidding::getSteeringWhenSkidding(float steering) const
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Updates skidding status.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
* \param is_on_ground True if the kart is on ground.
|
||||
* \param steering Raw steering of the kart [-1,1], i.e. not adjusted by
|
||||
* the kart's max steering angle.
|
||||
* \param skidding True if the skid button is pressed.
|
||||
*/
|
||||
void Skidding::update(float dt, bool is_on_ground,
|
||||
void Skidding::update(int ticks, bool is_on_ground,
|
||||
float steering, KartControl::SkidControl skidding)
|
||||
{
|
||||
float dt = stk_config->ticks2Time(ticks);
|
||||
|
||||
const KartProperties *kp = m_kart->getKartProperties();
|
||||
|
||||
// If a kart animation is shown, stop all skidding bonuses.
|
||||
@ -440,9 +442,10 @@ void Skidding::update(float dt, bool is_on_ground,
|
||||
->setCreationRateRelative(KartGFX::KGFX_SKIDR, 1.0f);
|
||||
m_kart->m_max_speed->
|
||||
instantSpeedIncrease(MaxSpeed::MS_INCREASE_SKIDDING,
|
||||
bonus_speed, bonus_speed,
|
||||
bonus_force, bonus_time,
|
||||
/*fade-out-time*/ 1.0f);
|
||||
bonus_speed, bonus_speed,
|
||||
bonus_force,
|
||||
stk_config->time2Ticks(bonus_time),
|
||||
/*fade-out-time*/ stk_config->time2Ticks(1.0f));
|
||||
|
||||
if (m_kart->getController()->canGetAchievements())
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ public:
|
||||
Skidding(Kart *kart);
|
||||
~Skidding();
|
||||
void reset();
|
||||
void update(float dt, bool is_on_ground, float steer,
|
||||
void update(int dt, bool is_on_ground, float steer,
|
||||
KartControl::SkidControl skidding);
|
||||
void saveState(BareNetworkString *buffer);
|
||||
void rewindTo(BareNetworkString *buffer);
|
||||
|
@ -19,8 +19,6 @@
|
||||
|
||||
#include "main_loop.hpp"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "config/user_config.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
@ -28,7 +26,6 @@
|
||||
#include "guiengine/engine.hpp"
|
||||
#include "guiengine/message_queue.hpp"
|
||||
#include "input/input_manager.hpp"
|
||||
#include "input/wiimote_manager.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
@ -50,6 +47,7 @@
|
||||
|
||||
MainLoop* main_loop = 0;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
MainLoop::MainLoop(unsigned parent_pid)
|
||||
: m_abort(false), m_parent_pid(parent_pid)
|
||||
{
|
||||
@ -198,25 +196,25 @@ float MainLoop::getLimitedDt()
|
||||
// to findout which events to replay
|
||||
if (World::getWorld() && history->replayHistory() )
|
||||
{
|
||||
dt = history->updateReplayAndGetDT(World::getWorld()->getTime(), dt);
|
||||
history->updateReplay(World::getWorld()->getTimeTicks(), dt);
|
||||
}
|
||||
return dt;
|
||||
} // getLimitedDt
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates all race related objects.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of ticks (physics steps) to simulate - should be 1.
|
||||
*/
|
||||
void MainLoop::updateRace(float dt)
|
||||
void MainLoop::updateRace(int ticks)
|
||||
{
|
||||
if (!World::getWorld()) return; // No race on atm - i.e. we are in menu
|
||||
|
||||
// The race event manager will update world in case of an online race
|
||||
if ( RaceEventManager::getInstance() &&
|
||||
RaceEventManager::getInstance()->isRunning() )
|
||||
RaceEventManager::getInstance()->update(dt);
|
||||
RaceEventManager::getInstance()->update(ticks);
|
||||
else
|
||||
World::getWorld()->updateWorld(dt);
|
||||
World::getWorld()->updateWorld(ticks);
|
||||
} // updateRace
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -336,8 +334,8 @@ void MainLoop::run()
|
||||
PROFILER_PUSH_CPU_MARKER("Main loop", 0xFF, 0x00, 0xF7);
|
||||
|
||||
left_over_time += getLimitedDt();
|
||||
int num_steps = int(left_over_time * stk_config->m_physics_fps);
|
||||
float dt = 1.0f / stk_config->m_physics_fps;
|
||||
int num_steps = stk_config->time2Ticks(left_over_time);
|
||||
float dt = stk_config->ticks2Time(1);
|
||||
left_over_time -= num_steps * dt ;
|
||||
|
||||
if (STKHost::existHost() &&
|
||||
@ -372,7 +370,7 @@ void MainLoop::run()
|
||||
if (World::getWorld() && RewindManager::get()->isEnabled())
|
||||
{
|
||||
RewindManager::get()
|
||||
->addNextTimeStep(World::getWorld()->getTime(), dt);
|
||||
->addNextTimeStep(World::getWorld()->getTimeTicks(), dt);
|
||||
}
|
||||
|
||||
if (!m_abort)
|
||||
@ -380,15 +378,17 @@ void MainLoop::run()
|
||||
float frame_duration = num_steps * dt;
|
||||
if (!ProfileWorld::isNoGraphics())
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("Update race", 0, 255, 255);
|
||||
if (World::getWorld())
|
||||
World::getWorld()->updateGraphics(frame_duration);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
// Render the previous frame, and also handle all user input.
|
||||
PROFILER_PUSH_CPU_MARKER("IrrDriver update", 0x00, 0x00, 0x7F);
|
||||
irr_driver->update(frame_duration);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Input/GUI", 0x7F, 0x00, 0x00);
|
||||
#ifdef ENABLE_WIIUSE
|
||||
wiimote_manager->update();
|
||||
#endif
|
||||
input_manager->update(frame_duration);
|
||||
GUIEngine::update(frame_duration);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
@ -412,14 +412,14 @@ void MainLoop::run()
|
||||
if (World::getWorld() && RewindManager::get()->isEnabled() && i>0)
|
||||
{
|
||||
RewindManager::get()
|
||||
->addNextTimeStep(World::getWorld()->getTime(), dt);
|
||||
->addNextTimeStep(World::getWorld()->getTimeTicks(), dt);
|
||||
}
|
||||
|
||||
// Enable last substep in last iteration
|
||||
m_is_last_substep = (i == num_steps - 1);
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("Update race", 0, 255, 255);
|
||||
if (World::getWorld()) updateRace(dt);
|
||||
if (World::getWorld()) updateRace(1);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
// We need to check again because update_race may have requested
|
||||
@ -431,11 +431,11 @@ void MainLoop::run()
|
||||
0x7F, 0x00, 0x7F);
|
||||
if (auto pm = ProtocolManager::lock())
|
||||
{
|
||||
pm->update(dt);
|
||||
pm->update(1);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
if (World::getWorld()) World::getWorld()->updateTime(dt);
|
||||
if (World::getWorld()) World::getWorld()->updateTime(1);
|
||||
} // for i < num_steps
|
||||
|
||||
m_is_last_substep = false;
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
Uint32 m_prev_time;
|
||||
unsigned m_parent_pid;
|
||||
float getLimitedDt();
|
||||
void updateRace(float dt);
|
||||
void updateRace(int ticks);
|
||||
public:
|
||||
MainLoop(unsigned parent_pid);
|
||||
~MainLoop();
|
||||
|
@ -181,9 +181,9 @@ const std::string& CutsceneWorld::getIdent() const
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Update the world and the track.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void CutsceneWorld::update(float dt)
|
||||
void CutsceneWorld::update(int ticks)
|
||||
{
|
||||
/*
|
||||
{
|
||||
@ -234,7 +234,7 @@ void CutsceneWorld::update(float dt)
|
||||
double prev_time = m_time;
|
||||
double now = StkTime::getRealTime();
|
||||
m_time = now - m_time_at_second_reset;
|
||||
dt = (float)(m_time - prev_time);
|
||||
ticks = stk_config->time2Ticks(float(m_time - prev_time));
|
||||
}
|
||||
|
||||
float fade = 0.0f;
|
||||
@ -288,8 +288,8 @@ void CutsceneWorld::update(float dt)
|
||||
}
|
||||
|
||||
|
||||
World::update((float)dt);
|
||||
World::updateTrack((float)dt);
|
||||
World::update(ticks);
|
||||
World::updateTrack(ticks);
|
||||
|
||||
PtrVector<TrackObject>& objects = Track::getCurrentTrack()
|
||||
->getTrackObjectManager()->getObjects();
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
|
||||
virtual const std::string& getIdent() const OVERRIDE;
|
||||
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
|
||||
virtual void createRaceGUI() OVERRIDE;
|
||||
|
||||
|
@ -53,20 +53,25 @@ private:
|
||||
public:
|
||||
DemoWorld();
|
||||
virtual ~DemoWorld();
|
||||
/** Returns identifier for this world. */
|
||||
virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; }
|
||||
virtual void update(float dt) OVERRIDE {ProfileWorld::update(dt);};
|
||||
virtual bool isRaceOver() OVERRIDE;
|
||||
virtual void enterRaceOverState() OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
static bool updateIdleTimeAndStartDemo(float dt);
|
||||
/** Returns identifier for this world. */
|
||||
virtual std::string getInternalCode() const OVERRIDE { return "DEMO"; }
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void update(int ticks) OVERRIDE { ProfileWorld::update(ticks); }
|
||||
// ------------------------------------------------------------------------
|
||||
static bool updateIdleTimeAndStartDemo(float dt);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the number of laps to use in demo mode. m_num_laps is from
|
||||
* ProfileWorld. */
|
||||
static void setNumLaps(unsigned int num_laps) { m_num_laps = num_laps; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the number of karts to use in demo mode. */
|
||||
static void setNumKarts(unsigned int num_karts) { m_default_num_karts = num_karts;}
|
||||
static void setNumKarts(unsigned int num_karts)
|
||||
{
|
||||
m_default_num_karts = num_karts;
|
||||
} // setNumKarts
|
||||
// ------------------------------------------------------------------------
|
||||
static void setTracks(const std::vector<std::string> &tracks);
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -156,12 +156,12 @@ void EasterEggHunt::collectedEasterEgg(const AbstractKart *kart)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Update the world and the track.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Physics time step size - should be 1.
|
||||
*/
|
||||
void EasterEggHunt::update(float dt)
|
||||
void EasterEggHunt::update(int ticks)
|
||||
{
|
||||
LinearWorld::update(dt);
|
||||
LinearWorld::updateTrack(dt);
|
||||
LinearWorld::update(ticks);
|
||||
LinearWorld::updateTrack(ticks);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -209,7 +209,7 @@ void EasterEggHunt::getKartsDisplayInfo(
|
||||
* direction messages in the easter egg mode since there is no direction there.
|
||||
* \param i Kart id.
|
||||
*/
|
||||
void EasterEggHunt::checkForWrongDirection(unsigned int i, float dt)
|
||||
void EasterEggHunt::checkForWrongDirection(unsigned int i, int ticks)
|
||||
{
|
||||
} // checkForWrongDirection
|
||||
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
virtual const std::string& getIdent() const OVERRIDE;
|
||||
virtual void terminateRace() OVERRIDE;
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
|
||||
@ -65,7 +65,7 @@ public:
|
||||
void collectedEasterEgg(const AbstractKart *kart);
|
||||
void readData(const std::string &filename);
|
||||
|
||||
virtual void checkForWrongDirection(unsigned int i, float dt) OVERRIDE;
|
||||
virtual void checkForWrongDirection(unsigned int i, int ticks) OVERRIDE;
|
||||
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
||||
|
||||
}; // EasterEggHunt
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -49,7 +50,7 @@ LinearWorld::LinearWorld() : WorldWithRank()
|
||||
m_last_lap_sfx = SFXManager::get()->createSoundSource("last_lap_fanfare");
|
||||
m_last_lap_sfx_played = false;
|
||||
m_last_lap_sfx_playing = false;
|
||||
m_fastest_lap = 9999999.9f;
|
||||
m_fastest_lap_ticks = INT_MAX;
|
||||
} // LinearWorld
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -87,8 +88,9 @@ LinearWorld::~LinearWorld()
|
||||
void LinearWorld::reset()
|
||||
{
|
||||
WorldWithRank::reset();
|
||||
m_last_lap_sfx_played = false;
|
||||
m_last_lap_sfx_played = false;
|
||||
m_last_lap_sfx_playing = false;
|
||||
m_fastest_lap_ticks = INT_MAX;
|
||||
|
||||
const unsigned int kart_amount = (unsigned int) m_karts.size();
|
||||
for(unsigned int i=0; i<kart_amount; i++)
|
||||
@ -148,13 +150,13 @@ void LinearWorld::reset()
|
||||
//-----------------------------------------------------------------------------
|
||||
/** General update function called once per frame. This updates the kart
|
||||
* sectors, which are then used to determine the kart positions.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void LinearWorld::update(float dt)
|
||||
void LinearWorld::update(int ticks)
|
||||
{
|
||||
// run generic parent stuff that applies to all modes. It
|
||||
// especially updates the kart positions.
|
||||
WorldWithRank::update(dt);
|
||||
WorldWithRank::update(ticks);
|
||||
|
||||
if (m_last_lap_sfx_playing &&
|
||||
m_last_lap_sfx->getStatus() != SFXBase::SFX_PLAYING)
|
||||
@ -195,7 +197,7 @@ void LinearWorld::update(float dt)
|
||||
// updated their position and laps etc, otherwise inconsistencies
|
||||
// (like two karts at same position) can occur.
|
||||
// ---------------------------------------------------------------
|
||||
WorldWithRank::updateTrack(dt);
|
||||
WorldWithRank::updateTrack(ticks);
|
||||
updateRacePosition();
|
||||
|
||||
for (unsigned int i=0; i<kart_amount; i++)
|
||||
@ -211,7 +213,7 @@ void LinearWorld::update(float dt)
|
||||
m_kart_info[i].m_estimated_finish =
|
||||
estimateFinishTimeForKart(m_karts[i]);
|
||||
}
|
||||
checkForWrongDirection(i, dt);
|
||||
checkForWrongDirection(i, ticks);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -274,7 +276,7 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
if(kart_info.m_race_lap+1 <= lap_count)
|
||||
{
|
||||
assert(kart->getWorldKartId()==kart_index);
|
||||
kart_info.m_time_at_last_lap=getTime();
|
||||
kart_info.m_ticks_at_last_lap=getTimeTicks();
|
||||
kart_info.m_race_lap++;
|
||||
m_kart_info[kart_index].m_overall_distance =
|
||||
m_kart_info[kart_index].m_race_lap
|
||||
@ -345,23 +347,23 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
{
|
||||
kart->finishedRace(getTime());
|
||||
}
|
||||
float time_per_lap;
|
||||
int ticks_per_lap;
|
||||
if (kart_info.m_race_lap == 1) // just completed first lap
|
||||
{
|
||||
time_per_lap=getTime();
|
||||
ticks_per_lap = getTimeTicks();
|
||||
}
|
||||
else //completing subsequent laps
|
||||
{
|
||||
time_per_lap=getTime() - kart_info.m_lap_start_time;
|
||||
ticks_per_lap = getTimeTicks() - kart_info.m_lap_start_ticks;
|
||||
}
|
||||
|
||||
// if new fastest lap
|
||||
if(time_per_lap < m_fastest_lap && raceHasLaps() &&
|
||||
kart_info.m_race_lap>0)
|
||||
if(ticks_per_lap < m_fastest_lap_ticks && raceHasLaps() &&
|
||||
kart_info.m_race_lap>0 )
|
||||
{
|
||||
m_fastest_lap = time_per_lap;
|
||||
m_fastest_lap_ticks = ticks_per_lap;
|
||||
|
||||
std::string s = StringUtils::timeToString(time_per_lap);
|
||||
std::string s = StringUtils::ticksTimeToString(ticks_per_lap);
|
||||
|
||||
// Store the temporary string because clang would mess this up
|
||||
// (remove the stringw before the wchar_t* is used).
|
||||
@ -379,7 +381,7 @@ void LinearWorld::newLap(unsigned int kart_index)
|
||||
|
||||
} // end if new fastest lap
|
||||
|
||||
kart_info.m_lap_start_time = getTime();
|
||||
kart_info.m_lap_start_ticks = getTimeTicks();
|
||||
kart->getController()->newLap(kart_info.m_race_lap);
|
||||
} // newLap
|
||||
|
||||
@ -422,18 +424,18 @@ float LinearWorld::getEstimatedFinishTime(const int kart_id) const
|
||||
} // getEstimatedFinishTime
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
float LinearWorld::getTimeAtLapForKart(const int kart_id) const
|
||||
int LinearWorld::getTicksAtLapForKart(const int kart_id) const
|
||||
{
|
||||
assert(kart_id < (int)m_kart_info.size());
|
||||
return m_kart_info[kart_id].m_time_at_last_lap;
|
||||
} // getTimeAtLapForKart
|
||||
return m_kart_info[kart_id].m_ticks_at_last_lap;
|
||||
} // getTicksAtLapForKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void LinearWorld::getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info)
|
||||
{
|
||||
int laps_of_leader = -1;
|
||||
float time_of_leader = -1;
|
||||
int laps_of_leader = -1;
|
||||
int ticks_of_leader = INT_MAX;
|
||||
// Find the best time for the lap. We can't simply use
|
||||
// the time of the kart at position 1, since the kart
|
||||
// might have been overtaken by now
|
||||
@ -448,7 +450,7 @@ void LinearWorld::getKartsDisplayInfo(
|
||||
rank_info.lap = -1;
|
||||
|
||||
if(kart->isEliminated()) continue;
|
||||
const float lap_time = getTimeAtLapForKart(kart->getWorldKartId());
|
||||
const int lap_ticks = getTicksAtLapForKart(kart->getWorldKartId());
|
||||
const int current_lap = getLapForKart( kart->getWorldKartId() );
|
||||
rank_info.lap = current_lap;
|
||||
|
||||
@ -457,11 +459,11 @@ void LinearWorld::getKartsDisplayInfo(
|
||||
// more laps than current leader --> new leader and
|
||||
// new time computation
|
||||
laps_of_leader = current_lap;
|
||||
time_of_leader = lap_time;
|
||||
ticks_of_leader = lap_ticks;
|
||||
} else if(current_lap == laps_of_leader)
|
||||
{
|
||||
// Same number of laps as leader: use fastest time
|
||||
time_of_leader=std::min(time_of_leader,lap_time);
|
||||
ticks_of_leader=std::min(ticks_of_leader,lap_ticks);
|
||||
}
|
||||
}
|
||||
|
||||
@ -476,24 +478,24 @@ void LinearWorld::getKartsDisplayInfo(
|
||||
|
||||
// Don't compare times when crossing the start line first
|
||||
if(laps_of_leader>0 &&
|
||||
(getTime() - getTimeAtLapForKart(kart->getWorldKartId())<5.0f ||
|
||||
(getTimeTicks() - getTicksAtLapForKart(kart->getWorldKartId())<5||
|
||||
rank_info.lap != laps_of_leader) &&
|
||||
raceHasLaps())
|
||||
{ // Display for 5 seconds
|
||||
std::string str;
|
||||
if(position == 1)
|
||||
{
|
||||
str = " " + StringUtils::timeToString(
|
||||
getTimeAtLapForKart(kart->getWorldKartId()) );
|
||||
str = " " + StringUtils::ticksTimeToString(
|
||||
getTicksAtLapForKart(kart->getWorldKartId()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
float timeBehind;
|
||||
timeBehind = (kart_info.m_race_lap==laps_of_leader
|
||||
? getTimeAtLapForKart(kart->getWorldKartId())
|
||||
: getTime())
|
||||
- time_of_leader;
|
||||
str = "+" + StringUtils::timeToString(timeBehind);
|
||||
int ticks_behind;
|
||||
ticks_behind = (kart_info.m_race_lap==laps_of_leader
|
||||
? getTicksAtLapForKart(kart->getWorldKartId())
|
||||
: getTimeTicks())
|
||||
- ticks_of_leader;
|
||||
str = "+" + StringUtils::ticksTimeToString(ticks_behind);
|
||||
}
|
||||
rank_info.m_text = irr::core::stringw(str.c_str());
|
||||
}
|
||||
@ -840,12 +842,12 @@ void LinearWorld::updateRacePosition()
|
||||
* player karts to display a message to the player.
|
||||
* \param i Kart id.
|
||||
*/
|
||||
void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
|
||||
void LinearWorld::checkForWrongDirection(unsigned int i, int ticks)
|
||||
{
|
||||
if (!m_karts[i]->getController()->isLocalPlayerController())
|
||||
return;
|
||||
|
||||
float wrongway_counter = m_karts[i]->getWrongwayCounter();
|
||||
int wrongway_counter = m_karts[i]->getWrongwayCounter();
|
||||
|
||||
const AbstractKart *kart=m_karts[i];
|
||||
// If the kart can go in more than one directions from the current track
|
||||
@ -873,14 +875,14 @@ void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
|
||||
kart->getVelocityLC().getY() > 0.0f &&
|
||||
!kart->hasFinishedRace())
|
||||
{
|
||||
wrongway_counter += dt;
|
||||
wrongway_counter += ticks;
|
||||
|
||||
if (wrongway_counter > 2.0f)
|
||||
wrongway_counter = 2.0f;
|
||||
if (wrongway_counter > stk_config->time2Ticks(2.0f))
|
||||
wrongway_counter = stk_config->time2Ticks(2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
wrongway_counter -= dt;
|
||||
wrongway_counter -= ticks;
|
||||
|
||||
if (wrongway_counter < 0)
|
||||
wrongway_counter = 0;
|
||||
@ -889,7 +891,7 @@ void LinearWorld::checkForWrongDirection(unsigned int i, float dt)
|
||||
if (kart->getKartAnimation())
|
||||
wrongway_counter = 0;
|
||||
|
||||
if (wrongway_counter > 1.0f)
|
||||
if (wrongway_counter > stk_config->time2Ticks(1.0f))
|
||||
{
|
||||
m_race_gui->addMessage(_("WRONG WAY!"), kart,
|
||||
/* time */ -1.0f,
|
||||
|
@ -18,11 +18,12 @@
|
||||
#ifndef HEADER_LINEAR_WORLD_HPP
|
||||
#define HEADER_LINEAR_WORLD_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "modes/world_with_rank.hpp"
|
||||
#include "utils/aligned_array.hpp"
|
||||
|
||||
#include <climits>
|
||||
#include <vector>
|
||||
|
||||
class SFXBase;
|
||||
|
||||
/*
|
||||
@ -42,8 +43,8 @@ private:
|
||||
|
||||
bool m_last_lap_sfx_playing;
|
||||
|
||||
/** The fastest lap time. */
|
||||
float m_fastest_lap;
|
||||
/** The fastest lap time, in ticks of physics dt. */
|
||||
int m_fastest_lap_ticks;
|
||||
|
||||
/** The track length returned by Track::getLength() only covers the
|
||||
* distance from start line to finish line, i.e. it does not include
|
||||
@ -65,10 +66,10 @@ private:
|
||||
int m_race_lap;
|
||||
|
||||
/** Time at finishing last lap. */
|
||||
float m_time_at_last_lap;
|
||||
int m_ticks_at_last_lap;
|
||||
|
||||
/** Time at start of a new lap. */
|
||||
float m_lap_start_time;
|
||||
int m_lap_start_ticks;
|
||||
|
||||
/** During last lap only: estimated finishing time! */
|
||||
float m_estimated_finish;
|
||||
@ -83,11 +84,11 @@ private:
|
||||
/** Re-initialises all data. */
|
||||
void reset()
|
||||
{
|
||||
m_race_lap = -1;
|
||||
m_lap_start_time = 0;
|
||||
m_time_at_last_lap = 99999.9f;
|
||||
m_estimated_finish = -1.0f;
|
||||
m_overall_distance = 0.0f;
|
||||
m_race_lap = -1;
|
||||
m_lap_start_ticks = 0;
|
||||
m_ticks_at_last_lap = INT_MAX;
|
||||
m_estimated_finish = -1.0f;
|
||||
m_overall_distance = 0.0f;
|
||||
} // reset
|
||||
};
|
||||
// ------------------------------------------------------------------------
|
||||
@ -100,7 +101,7 @@ protected:
|
||||
*/
|
||||
AlignedArray<KartInfo> m_kart_info;
|
||||
|
||||
virtual void checkForWrongDirection(unsigned int i, float dt);
|
||||
virtual void checkForWrongDirection(unsigned int i, int ticks);
|
||||
void updateRacePosition();
|
||||
virtual float estimateFinishTimeForKart(AbstractKart* kart) OVERRIDE;
|
||||
|
||||
@ -112,12 +113,12 @@ public:
|
||||
virtual void init() OVERRIDE;
|
||||
virtual ~LinearWorld();
|
||||
|
||||
virtual void update(float delta) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
float getDistanceDownTrackForKart(const int kart_id) const;
|
||||
float getDistanceToCenterForKart(const int kart_id) const;
|
||||
float getEstimatedFinishTime(const int kart_id) const;
|
||||
int getLapForKart(const int kart_id) const;
|
||||
float getTimeAtLapForKart(const int kart_id) const;
|
||||
int getTicksAtLapForKart(const int kart_id) const;
|
||||
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
@ -155,11 +156,11 @@ public:
|
||||
{
|
||||
return m_kart_info[kart_index].m_overall_distance;
|
||||
} // getOverallDistance
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns time for the fastest laps */
|
||||
float getFastestLap() const
|
||||
{
|
||||
return m_fastest_lap;
|
||||
return stk_config->ticks2Time(m_fastest_lap_ticks);
|
||||
}
|
||||
}; // LinearWorld
|
||||
|
||||
|
@ -101,9 +101,9 @@ void OverWorld::enterOverWorld()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** General update function called once per frame.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void OverWorld::update(float dt)
|
||||
void OverWorld::update(int ticks)
|
||||
{
|
||||
// Skip annoying waiting without a purpose
|
||||
// Make sure to do all things that would normally happen in the
|
||||
@ -119,8 +119,8 @@ void OverWorld::update(float dt)
|
||||
music_manager->startMusic();
|
||||
m_karts[0]->startEngineSFX();
|
||||
}
|
||||
World::update(dt);
|
||||
World::updateTrack(dt);
|
||||
World::update(ticks);
|
||||
World::updateTrack(ticks);
|
||||
const unsigned int kart_amount = (unsigned int)m_karts.size();
|
||||
|
||||
// isn't it cool, on the overworld nitro is free!
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
static void enterOverWorld();
|
||||
|
||||
virtual void update(float delta) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE;
|
||||
virtual void getKartsDisplayInfo(
|
||||
std::vector<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
|
@ -149,10 +149,11 @@ bool ProfileWorld::isRaceOver()
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Counts the number of frames.
|
||||
* \param ticks number of physics time steps - should be 1.
|
||||
*/
|
||||
void ProfileWorld::update(float dt)
|
||||
void ProfileWorld::update(int ticks)
|
||||
{
|
||||
StandardRace::update(dt);
|
||||
StandardRace::update(ticks);
|
||||
|
||||
m_frame_count++;
|
||||
video::IVideoDriver *driver = irr_driver->getVideoDriver();
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
virtual ~ProfileWorld();
|
||||
/** Returns identifier for this world. */
|
||||
virtual std::string getInternalCode() const {return "PROFILE"; }
|
||||
virtual void update(float dt);
|
||||
virtual void update(int ticks);
|
||||
virtual bool isRaceOver();
|
||||
virtual void enterRaceOverState();
|
||||
|
||||
|
@ -84,12 +84,12 @@ void SoccerWorld::init()
|
||||
m_kart_position_map.clear();
|
||||
WorldWithRank::init();
|
||||
m_display_rank = false;
|
||||
m_goal_timer = 0.0f;
|
||||
m_ball_hitter = -1;
|
||||
m_ball = NULL;
|
||||
m_ball_body = NULL;
|
||||
m_goal_target = race_manager->getMaxGoal();
|
||||
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
|
||||
m_goal_timer = 0;
|
||||
m_ball_hitter = -1;
|
||||
m_ball = NULL;
|
||||
m_ball_body = NULL;
|
||||
m_goal_target = race_manager->getMaxGoal();
|
||||
m_goal_sound = SFXManager::get()->createSoundSource("goal_scored");
|
||||
|
||||
Track *track = Track::getCurrentTrack();
|
||||
if (track->hasNavMesh())
|
||||
@ -143,7 +143,7 @@ void SoccerWorld::reset()
|
||||
m_red_kdm.clear();
|
||||
m_blue_kdm.clear();
|
||||
m_ball_heading = 0.0f;
|
||||
m_ball_invalid_timer = 0.0f;
|
||||
m_ball_invalid_timer = 0;
|
||||
|
||||
if (m_goal_sound != NULL &&
|
||||
m_goal_sound->getStatus() == SFXBase::SFX_PLAYING)
|
||||
@ -177,34 +177,34 @@ const std::string& SoccerWorld::getIdent() const
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Update the world and the track.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Physics time steps - should be 1.
|
||||
*/
|
||||
void SoccerWorld::update(float dt)
|
||||
void SoccerWorld::update(int ticks)
|
||||
{
|
||||
updateBallPosition(dt);
|
||||
updateBallPosition(ticks);
|
||||
if (Track::getCurrentTrack()->hasNavMesh())
|
||||
{
|
||||
updateSectorForKarts();
|
||||
updateAIData();
|
||||
}
|
||||
|
||||
WorldWithRank::update(dt);
|
||||
WorldWithRank::updateTrack(dt);
|
||||
WorldWithRank::update(ticks);
|
||||
WorldWithRank::updateTrack(ticks);
|
||||
|
||||
if (getPhase() == World::GOAL_PHASE)
|
||||
{
|
||||
if (m_goal_timer == 0.0f)
|
||||
if (m_goal_timer == 0)
|
||||
{
|
||||
// Stop all karts
|
||||
for (unsigned int i = 0; i < m_karts.size(); i++)
|
||||
m_karts[i]->setVelocity(btVector3(0, 0, 0));
|
||||
}
|
||||
m_goal_timer += dt;
|
||||
m_goal_timer += ticks;
|
||||
|
||||
if (m_goal_timer > 3.0f)
|
||||
if (m_goal_timer > stk_config->time2Ticks(3.0f))
|
||||
{
|
||||
setPhase(WorldStatus::RACE_PHASE);
|
||||
m_goal_timer = 0.0f;
|
||||
m_goal_timer = 0;
|
||||
if (!isRaceOver())
|
||||
{
|
||||
// Reset all karts
|
||||
@ -448,7 +448,7 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Localize the ball on the navigation mesh.
|
||||
*/
|
||||
void SoccerWorld::updateBallPosition(float dt)
|
||||
void SoccerWorld::updateBallPosition(int ticks)
|
||||
{
|
||||
if (isRaceOver()) return;
|
||||
|
||||
@ -465,11 +465,11 @@ void SoccerWorld::updateBallPosition(float dt)
|
||||
->update(getBallPosition(), true/*ignore_vertical*/);
|
||||
if (!m_ball_track_sector->isOnRoad() && getPhase() == RACE_PHASE)
|
||||
{
|
||||
m_ball_invalid_timer += dt;
|
||||
m_ball_invalid_timer += ticks;
|
||||
// Reset the ball and karts if out of navmesh after 2 seconds
|
||||
if (m_ball_invalid_timer >= 2.0f)
|
||||
if (m_ball_invalid_timer >= stk_config->time2Ticks(2.0f))
|
||||
{
|
||||
m_ball_invalid_timer = 0.0f;
|
||||
m_ball_invalid_timer = 0;
|
||||
m_ball->reset();
|
||||
for (unsigned int i = 0; i < m_karts.size(); i++)
|
||||
moveKartAfterRescue(m_karts[i]);
|
||||
@ -478,7 +478,7 @@ void SoccerWorld::updateBallPosition(float dt)
|
||||
}
|
||||
}
|
||||
else
|
||||
m_ball_invalid_timer = 0.0f;
|
||||
m_ball_invalid_timer = 0;
|
||||
}
|
||||
|
||||
} // updateBallPosition
|
||||
|
@ -266,8 +266,11 @@ private:
|
||||
SFXBase *m_goal_sound;
|
||||
|
||||
/** Timer for displaying goal text*/
|
||||
float m_goal_timer;
|
||||
float m_ball_invalid_timer;
|
||||
int m_goal_timer;
|
||||
|
||||
/** Counts ticks when the ball is off track, so a reset can be
|
||||
* triggered if the ball is off for more than 2 seconds. */
|
||||
int m_ball_invalid_timer;
|
||||
int m_ball_hitter;
|
||||
|
||||
/** Goals data of each team scored */
|
||||
@ -290,7 +293,7 @@ private:
|
||||
/** Set the team for the karts */
|
||||
void initKartList();
|
||||
/** Function to update the location the ball on the polygon map */
|
||||
void updateBallPosition(float dt);
|
||||
void updateBallPosition(int ticks);
|
||||
/** Function to update data for AI usage. */
|
||||
void updateAIData();
|
||||
/** Get number of teammates in a team, used by starting position assign. */
|
||||
@ -326,7 +329,7 @@ public:
|
||||
|
||||
virtual const std::string& getIdent() const OVERRIDE;
|
||||
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
void onCheckGoalTriggered(bool first_goal);
|
||||
// ------------------------------------------------------------------------
|
||||
|
@ -95,11 +95,12 @@ void ThreeStrikesBattle::reset()
|
||||
{
|
||||
WorldWithRank::reset();
|
||||
|
||||
m_next_sta_spawn_time =
|
||||
float next_spawn_time =
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 30.0f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
|
||||
25.0f : 20.0f;
|
||||
m_next_sta_spawn_ticks = stk_config->time2Ticks(next_spawn_time);
|
||||
|
||||
const unsigned int kart_amount = (unsigned int)m_karts.size();
|
||||
for(unsigned int n=0; n<kart_amount; n++)
|
||||
@ -349,12 +350,12 @@ const std::string& ThreeStrikesBattle::getIdent() const
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Update the world and the track.
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time step - should be 1.
|
||||
*/
|
||||
void ThreeStrikesBattle::update(float dt)
|
||||
void ThreeStrikesBattle::update(int ticks)
|
||||
{
|
||||
WorldWithRank::update(dt);
|
||||
WorldWithRank::updateTrack(dt);
|
||||
WorldWithRank::update(ticks);
|
||||
WorldWithRank::updateTrack(ticks);
|
||||
|
||||
spawnSpareTireKarts();
|
||||
if (Track::getCurrentTrack()->hasNavMesh())
|
||||
@ -625,26 +626,25 @@ void ThreeStrikesBattle::addKartLife(unsigned int id)
|
||||
void ThreeStrikesBattle::spawnSpareTireKarts()
|
||||
{
|
||||
if (m_spare_tire_karts.empty() ||
|
||||
getTimeSinceStart() < m_next_sta_spawn_time)
|
||||
getTicksSinceStart() < m_next_sta_spawn_ticks)
|
||||
return;
|
||||
|
||||
const float period =
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 40.0f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 30.0f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
|
||||
25.0f : 20.0f;
|
||||
const float inc_factor =
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_BEST ? 0.7f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_HARD ? 0.65f :
|
||||
race_manager->getDifficulty() == RaceManager::DIFFICULTY_MEDIUM ?
|
||||
0.6f : 0.55f;
|
||||
|
||||
// Spawn spare tire kart when necessary
|
||||
// The lifespan for sta: inc_factor / period * 1000 / 2
|
||||
// So in easier mode the sta lasts longer than spawn period
|
||||
const float lifespan = inc_factor / period * 1000;
|
||||
m_next_sta_spawn_time = lifespan + (getTimeSinceStart() * inc_factor) +
|
||||
getTimeSinceStart();
|
||||
float inc_factor, lifespan;
|
||||
switch (race_manager->getDifficulty())
|
||||
{
|
||||
case RaceManager::DIFFICULTY_BEST: inc_factor = 0.7f; lifespan = 17.5f; break;
|
||||
case RaceManager::DIFFICULTY_HARD: inc_factor = 0.65f; lifespan = 21.66f; break;
|
||||
case RaceManager::DIFFICULTY_EASY: inc_factor = 0.6f; lifespan = 24.0f; break;
|
||||
default: inc_factor = 0.55f; lifespan = 27.5f; break;
|
||||
}
|
||||
|
||||
int lifespan_ticks = stk_config->time2Ticks(lifespan);
|
||||
// Spawn spare tire kart when necessary
|
||||
m_next_sta_spawn_ticks = int( lifespan_ticks
|
||||
+ getTicksSinceStart() * inc_factor
|
||||
+ getTicksSinceStart() );
|
||||
int kart_has_few_lives = 0;
|
||||
for (unsigned int i = 0; i < m_kart_info.size(); i++)
|
||||
{
|
||||
@ -665,7 +665,7 @@ void ThreeStrikesBattle::spawnSpareTireKarts()
|
||||
SpareTireAI* sta = dynamic_cast<SpareTireAI*>
|
||||
(m_spare_tire_karts[i]->getController());
|
||||
assert(sta);
|
||||
sta->spawn(lifespan);
|
||||
sta->spawn(lifespan_ticks);
|
||||
}
|
||||
} // spawnSpareTireKarts
|
||||
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
int m_total_hit;
|
||||
|
||||
std::vector<AbstractKart*> m_spare_tire_karts;
|
||||
float m_next_sta_spawn_time;
|
||||
int m_next_sta_spawn_ticks;
|
||||
|
||||
public:
|
||||
/** Used to show a nice graph when battle is over */
|
||||
@ -113,7 +113,7 @@ public:
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void kartHit(const unsigned int kart_id) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void kartAdded(AbstractKart* kart, scene::ISceneNode* node)
|
||||
OVERRIDE;
|
||||
|
@ -311,7 +311,7 @@ void World::reset()
|
||||
irr_driver->reset();
|
||||
|
||||
//Reset the Rubber Ball Collect Time to some negative value.
|
||||
powerup_manager->setBallCollectTime(-100);
|
||||
powerup_manager->setBallCollectTicks(-100);
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -744,7 +744,8 @@ void World::resetAllKarts()
|
||||
(*i)->getMaterial() && (*i)->getMaterial()->hasGravity() ?
|
||||
(*i)->getNormal() * -g : Vec3(0, -g, 0));
|
||||
}
|
||||
for(int i=0; i<60; i++) Physics::getInstance()->update(1.f/60.f);
|
||||
for(int i=0; i<stk_config->getPhysicsFPS(); i++)
|
||||
Physics::getInstance()->update(1);
|
||||
|
||||
for ( KartList::iterator i=m_karts.begin(); i!=m_karts.end(); i++)
|
||||
{
|
||||
@ -838,9 +839,9 @@ void World::scheduleUnpause()
|
||||
* call World::update() first, to get updated kart positions. If race
|
||||
* over would be handled in World::update, LinearWorld had no opportunity
|
||||
* to update its data structures before the race is finished).
|
||||
* \param dt Time step size.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void World::updateWorld(float dt)
|
||||
void World::updateWorld(int ticks)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xB01D6543);
|
||||
@ -867,12 +868,12 @@ void World::updateWorld(float dt)
|
||||
! (NetworkConfig::get()->isClient() &&
|
||||
RewindManager::get()->isRewinding() ) )
|
||||
{
|
||||
history->updateSaving(dt); // updating the saved state
|
||||
history->updateSaving(ticks); // updating the saved state
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
update(dt);
|
||||
update(ticks);
|
||||
}
|
||||
catch (AbortWorldUpdateException& e)
|
||||
{
|
||||
@ -962,10 +963,25 @@ void World::scheduleTutorial()
|
||||
} // scheduleTutorial
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the physics, all karts, the track, and projectile manager.
|
||||
* \param dt Time step size.
|
||||
/** This updates all only graphical elements. It is only called once per
|
||||
* rendered frame, not once per time step.
|
||||
* float dt Time since last rame.
|
||||
*/
|
||||
void World::update(float dt)
|
||||
void World::updateGraphics(float dt)
|
||||
{
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (weather)", 0x80, 0x7F, 0x00);
|
||||
if (UserConfigParams::m_particles_effects > 1 && Weather::getInstance())
|
||||
{
|
||||
Weather::getInstance()->update(dt);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
} // updateGraphics
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the physics, all karts, the track, and projectile manager.
|
||||
* \param ticks Number of physics time steps - should be 1.
|
||||
*/
|
||||
void World::update(int ticks)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
assert(m_magic_number == 0xB01D6543);
|
||||
@ -974,20 +990,20 @@ void World::update(float dt)
|
||||
PROFILER_PUSH_CPU_MARKER("World::update()", 0x00, 0x7F, 0x00);
|
||||
|
||||
#if MEASURE_FPS
|
||||
static float time = 0.0f;
|
||||
time += dt;
|
||||
if (time > 5.0f)
|
||||
static int time = 0.0f;
|
||||
time += ticks;
|
||||
if (time > stk_config->time2Ticks(5.0f))
|
||||
{
|
||||
time -= 5.0f;
|
||||
time -= stk_config->time2Ticks(5.0f);
|
||||
printf("%i\n",irr_driver->getVideoDriver()->getFPS());
|
||||
}
|
||||
#endif
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (sub-updates)", 0x20, 0x7F, 0x00);
|
||||
WorldStatus::update(dt);
|
||||
WorldStatus::update(ticks);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (RewindManager)", 0x20, 0x7F, 0x40);
|
||||
RewindManager::get()->update(dt);
|
||||
RewindManager::get()->update(ticks);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (Kart::upate)", 0x40, 0x7F, 0x00);
|
||||
@ -1002,7 +1018,7 @@ void World::update(float dt)
|
||||
dynamic_cast<SpareTireAI*>(m_karts[i]->getController());
|
||||
// Update all karts that are not eliminated
|
||||
if(!m_karts[i]->isEliminated() || (sta && sta->isMoving()))
|
||||
m_karts[i]->update(dt);
|
||||
m_karts[i]->update(ticks);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
@ -1013,29 +1029,22 @@ void World::update(float dt)
|
||||
|
||||
for (unsigned int i = 0; i < Camera::getNumCameras(); i++)
|
||||
{
|
||||
Camera::getCamera(i)->update(dt);
|
||||
Camera::getCamera(i)->update(stk_config->ticks2Time(ticks));
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
} // if !rewind
|
||||
|
||||
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(dt);
|
||||
if(race_manager->isRecordingRace()) ReplayRecorder::get()->update(ticks);
|
||||
Scripting::ScriptEngine *script_engine = Scripting::ScriptEngine::getInstance();
|
||||
if (script_engine) script_engine->update(dt);
|
||||
if (script_engine) script_engine->update(ticks);
|
||||
|
||||
if (!history->dontDoPhysics())
|
||||
{
|
||||
Physics::getInstance()->update(dt);
|
||||
Physics::getInstance()->update(ticks);
|
||||
}
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (weather)", 0x80, 0x7F, 0x00);
|
||||
if (UserConfigParams::m_particles_effects > 1 && Weather::getInstance())
|
||||
{
|
||||
Weather::getInstance()->update(dt);
|
||||
}
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (projectiles)", 0xa0, 0x7F, 0x00);
|
||||
projectile_manager->update(dt);
|
||||
projectile_manager->update(ticks);
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
@ -1045,16 +1054,6 @@ void World::update(float dt)
|
||||
#endif
|
||||
} // update
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Compute the new time, and set this new time to be used in the rewind
|
||||
* manager.
|
||||
* \param dt Time step size.
|
||||
*/
|
||||
void World::updateTime(const float dt)
|
||||
{
|
||||
WorldStatus::updateTime(dt);
|
||||
} // updateTime
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Only updates the track. The order in which the various parts of STK are
|
||||
* updated is quite important (i.e. the track can't be updated as part of
|
||||
@ -1072,12 +1071,12 @@ void World::updateTime(const float dt)
|
||||
* update has to be called after updating the race position in linear world.
|
||||
* That's why there is a separate call for trackUpdate here.
|
||||
*/
|
||||
void World::updateTrack(float dt)
|
||||
void World::updateTrack(int ticks)
|
||||
{
|
||||
Track::getCurrentTrack()->update(dt);
|
||||
Track::getCurrentTrack()->update(ticks);
|
||||
} // update Track
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Highscores* World::getHighscores() const
|
||||
{
|
||||
if(!m_use_highscores) return NULL;
|
||||
|
@ -163,9 +163,9 @@ protected:
|
||||
virtual void onGo() OVERRIDE;
|
||||
/** Returns true if the race is over. Must be defined by all modes. */
|
||||
virtual bool isRaceOver() = 0;
|
||||
virtual void update(float dt) OVERRIDE;
|
||||
virtual void update(int ticks) OVERRIDE;
|
||||
virtual void createRaceGUI();
|
||||
void updateTrack(float dt);
|
||||
void updateTrack(int ticks);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Used for AI karts that are still racing when all player kart finished.
|
||||
* Generally it should estimate the arrival time for those karts, but as
|
||||
@ -236,11 +236,11 @@ public:
|
||||
// Virtual functions
|
||||
// =================
|
||||
virtual void init();
|
||||
virtual void updateGraphics(float dt);
|
||||
virtual void terminateRace() OVERRIDE;
|
||||
virtual void reset() OVERRIDE;
|
||||
virtual void pause(Phase phase) OVERRIDE;
|
||||
virtual void unpause() OVERRIDE;
|
||||
virtual void updateTime(const float dt) OVERRIDE;
|
||||
virtual void getDefaultCollectibles(int *collectible_type,
|
||||
int *amount );
|
||||
virtual void endRaceEarly() { return; }
|
||||
@ -273,7 +273,7 @@ public:
|
||||
void scheduleUnpause();
|
||||
void scheduleExitRace() { m_schedule_exit_race = true; }
|
||||
void scheduleTutorial();
|
||||
void updateWorld(float dt);
|
||||
void updateWorld(int ticks);
|
||||
void handleExplosion(const Vec3 &xyz, AbstractKart *kart_hit,
|
||||
PhysicalObject *object);
|
||||
AbstractKart* getPlayerKart(unsigned int player) const;
|
||||
|
@ -63,8 +63,9 @@ void WorldStatus::reset()
|
||||
{
|
||||
m_time = 0.0f;
|
||||
m_adjust_time_by = 0.0f;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_count_up_timer = 0.0f;
|
||||
m_time_ticks = 0;
|
||||
m_auxiliary_ticks = 0;
|
||||
m_count_up_ticks = 0;
|
||||
|
||||
m_engines_started = false;
|
||||
|
||||
@ -138,7 +139,8 @@ void WorldStatus::startEngines()
|
||||
void WorldStatus::setClockMode(const ClockType mode, const float initial_time)
|
||||
{
|
||||
m_clock_mode = mode;
|
||||
m_time = initial_time;
|
||||
m_time_ticks = stk_config->time2Ticks(initial_time);
|
||||
m_time = stk_config->ticks2Time(m_time_ticks);
|
||||
} // setClockMode
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -154,7 +156,7 @@ void WorldStatus::enterRaceOverState()
|
||||
return;
|
||||
|
||||
m_phase = DELAY_FINISH_PHASE;
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_auxiliary_ticks = 0;
|
||||
} // enterRaceOverState
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -170,7 +172,7 @@ void WorldStatus::terminateRace()
|
||||
* updated.
|
||||
* \param dt Time step.
|
||||
*/
|
||||
void WorldStatus::update(float dt)
|
||||
void WorldStatus::update(int ticks)
|
||||
{
|
||||
} // update
|
||||
|
||||
@ -178,9 +180,9 @@ void WorldStatus::update(float dt)
|
||||
/** Updates the world time and clock (which might be running backwards), and
|
||||
* all status information, called once per frame at the end of the main
|
||||
* loop.
|
||||
* \param dt Duration of time step.
|
||||
* \param ticks Number of ticks (physics time steps) - should be 1.
|
||||
*/
|
||||
void WorldStatus::updateTime(const float dt)
|
||||
void WorldStatus::updateTime(int ticks)
|
||||
{
|
||||
switch (m_phase)
|
||||
{
|
||||
@ -190,7 +192,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
// tilt way too much. A separate setup phase for the first frame
|
||||
// simplifies this handling
|
||||
case SETUP_PHASE:
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_auxiliary_ticks= 0;
|
||||
m_phase = TRACK_INTRO_PHASE;
|
||||
|
||||
if (m_play_track_intro_sound)
|
||||
@ -205,7 +207,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
|
||||
return; // Do not increase time
|
||||
case TRACK_INTRO_PHASE:
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
|
||||
if (UserConfigParams::m_artist_debug_mode &&
|
||||
!NetworkConfig::get()->isNetworking() &&
|
||||
@ -213,7 +215,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
race_manager->getNumSpareTireKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt * 6;
|
||||
m_auxiliary_ticks += 6;
|
||||
}
|
||||
|
||||
// Work around a bug that occurred on linux once:
|
||||
@ -223,21 +225,22 @@ void WorldStatus::updateTime(const float dt)
|
||||
// long, we use the aux timer to force the next phase
|
||||
// after 3.5 seconds.
|
||||
if (m_track_intro_sound->getStatus() == SFXBase::SFX_PLAYING &&
|
||||
m_auxiliary_timer < 3.5f)
|
||||
m_auxiliary_ticks < stk_config->time2Ticks(3.5f) )
|
||||
return; // Do not increase time
|
||||
|
||||
// Wait before ready phase if sounds are disabled
|
||||
if (!UserConfigParams::m_sfx && m_auxiliary_timer < 3.0f)
|
||||
if (!UserConfigParams::m_sfx &&
|
||||
m_auxiliary_ticks < stk_config->time2Ticks(3.0f))
|
||||
return;
|
||||
|
||||
if (!m_play_track_intro_sound)
|
||||
{
|
||||
startEngines();
|
||||
if (m_auxiliary_timer < 3.0f)
|
||||
if (m_auxiliary_ticks < stk_config->time2Ticks(3.0f))
|
||||
return; // Do not increase time
|
||||
}
|
||||
|
||||
m_auxiliary_timer = 0.0f;
|
||||
m_auxiliary_ticks = 0;
|
||||
|
||||
if (m_play_ready_set_go_sounds)
|
||||
m_prestart_sound->play();
|
||||
@ -269,8 +272,8 @@ void WorldStatus::updateTime(const float dt)
|
||||
}
|
||||
case READY_PHASE:
|
||||
startEngines();
|
||||
|
||||
if (m_auxiliary_timer > 1.0)
|
||||
// One second
|
||||
if (m_auxiliary_ticks > stk_config->getPhysicsFPS())
|
||||
{
|
||||
if (m_play_ready_set_go_sounds)
|
||||
{
|
||||
@ -280,7 +283,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
m_phase = SET_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
|
||||
// In artist debug mode, when without opponents, skip the
|
||||
// ready/set/go counter faster
|
||||
@ -290,12 +293,12 @@ void WorldStatus::updateTime(const float dt)
|
||||
race_manager->getNumSpareTireKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
m_auxiliary_ticks += 6;
|
||||
}
|
||||
|
||||
return; // Do not increase time
|
||||
case SET_PHASE:
|
||||
if (m_auxiliary_timer > 2.0)
|
||||
if (m_auxiliary_ticks > 2*stk_config->getPhysicsFPS())
|
||||
{
|
||||
// set phase is over, go to the next one
|
||||
m_phase = GO_PHASE;
|
||||
@ -308,7 +311,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
onGo();
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
|
||||
// In artist debug mode, when without opponents,
|
||||
// skip the ready/set/go counter faster
|
||||
@ -318,24 +321,25 @@ void WorldStatus::updateTime(const float dt)
|
||||
race_manager->getNumSpareTireKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
m_auxiliary_ticks += 6;
|
||||
}
|
||||
|
||||
return; // Do not increase time
|
||||
case GO_PHASE :
|
||||
|
||||
if (m_auxiliary_timer>2.5f && music_manager->getCurrentMusic() &&
|
||||
// 2.5 seconds
|
||||
if (m_auxiliary_ticks>stk_config->time2Ticks(2.5f) &&
|
||||
music_manager->getCurrentMusic() &&
|
||||
!music_manager->getCurrentMusic()->isPlaying())
|
||||
{
|
||||
music_manager->startMusic();
|
||||
}
|
||||
|
||||
if (m_auxiliary_timer > 3.0f) // how long to display the 'go' message
|
||||
// how long to display the 'go' message
|
||||
if (m_auxiliary_ticks > 3 * stk_config->getPhysicsFPS())
|
||||
{
|
||||
m_phase = MUSIC_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
|
||||
// In artist debug mode, when without opponents,
|
||||
// skip the ready/set/go counter faster
|
||||
@ -344,7 +348,7 @@ void WorldStatus::updateTime(const float dt)
|
||||
race_manager->getNumSpareTireKarts() == 1 &&
|
||||
race_manager->getTrackName() != "tutorial")
|
||||
{
|
||||
m_auxiliary_timer += dt*6;
|
||||
m_auxiliary_ticks += 6;
|
||||
}
|
||||
|
||||
break; // Now the world time starts
|
||||
@ -356,12 +360,13 @@ void WorldStatus::updateTime(const float dt)
|
||||
UserConfigParams::m_race_now = false;
|
||||
}
|
||||
// how long to display the 'music' message
|
||||
if (m_auxiliary_timer>stk_config->m_music_credit_time)
|
||||
if (m_auxiliary_ticks >
|
||||
stk_config->time2Ticks(stk_config->m_music_credit_time) )
|
||||
{
|
||||
m_phase = RACE_PHASE;
|
||||
}
|
||||
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
break;
|
||||
case RACE_PHASE:
|
||||
// Nothing to do for race phase, switch to delay finish phase
|
||||
@ -369,10 +374,11 @@ void WorldStatus::updateTime(const float dt)
|
||||
break;
|
||||
case DELAY_FINISH_PHASE:
|
||||
{
|
||||
m_auxiliary_timer += dt;
|
||||
m_auxiliary_ticks++;
|
||||
|
||||
// Change to next phase if delay is over
|
||||
if (m_auxiliary_timer > stk_config->m_delay_finish_time)
|
||||
if (m_auxiliary_ticks >
|
||||
stk_config->time2Ticks(stk_config->m_delay_finish_time))
|
||||
{
|
||||
m_phase = RESULT_DISPLAY_PHASE;
|
||||
terminateRace();
|
||||
@ -400,26 +406,29 @@ void WorldStatus::updateTime(const float dt)
|
||||
case CLOCK_CHRONO:
|
||||
if (!device->getTimer()->isStopped())
|
||||
{
|
||||
m_time += dt;
|
||||
m_count_up_timer += dt;
|
||||
m_time_ticks++;
|
||||
m_time = stk_config->ticks2Time(m_time_ticks);
|
||||
m_count_up_ticks++;
|
||||
}
|
||||
break;
|
||||
case CLOCK_COUNTDOWN:
|
||||
// stop countdown when race is over
|
||||
if (m_phase == RESULT_DISPLAY_PHASE || m_phase == FINISH_PHASE)
|
||||
{
|
||||
m_time_ticks = 0;
|
||||
m_time = 0.0f;
|
||||
m_count_up_timer = 0.0f;
|
||||
m_count_up_ticks = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!device->getTimer()->isStopped())
|
||||
{
|
||||
m_time -= dt;
|
||||
m_count_up_timer += dt;
|
||||
m_time_ticks--;
|
||||
m_time = stk_config->ticks2Time(m_time_ticks);
|
||||
m_count_up_ticks++;
|
||||
}
|
||||
|
||||
if(m_time <= 0.0)
|
||||
if(m_time_ticks <= 0.0)
|
||||
{
|
||||
// event
|
||||
countdownReachedZero();
|
||||
@ -484,10 +493,23 @@ void WorldStatus::startReadySetGo()
|
||||
*/
|
||||
void WorldStatus::setTime(const float time)
|
||||
{
|
||||
m_count_up_timer += (time - m_time);
|
||||
m_time = time;
|
||||
int new_time_ticks = stk_config->time2Ticks(time);
|
||||
m_count_up_ticks += (new_time_ticks - m_time_ticks);
|
||||
m_time_ticks = new_time_ticks;
|
||||
m_time = stk_config->ticks2Time(new_time_ticks);
|
||||
} // setTime
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets a new time for the world time, measured in ticks.
|
||||
* \param ticks New time in ticks to set.
|
||||
*/
|
||||
void WorldStatus::setTicks(int ticks)
|
||||
{
|
||||
m_count_up_ticks += ticks - m_time_ticks;
|
||||
m_time_ticks = ticks;
|
||||
m_time = stk_config->ticks2Time(ticks);
|
||||
} // setTicks
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Pauses the game and switches to the specified phase.
|
||||
* \param phase Phase to switch to.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user