Remove PlayerDifficulty class
This commit is contained in:
parent
eb19bf571e
commit
1ceab872b1
@ -27,7 +27,6 @@
|
||||
#include "io/xml_node.hpp"
|
||||
#include "items/item.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/player_difficulty.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
STKConfig* stk_config=0;
|
||||
@ -396,15 +395,6 @@ void STKConfig::getAllData(const XMLNode * root)
|
||||
m_kart_properties[type->getName()]->copyFrom(m_default_kart_properties);
|
||||
m_kart_properties[type->getName()]->getAllData(type);
|
||||
}
|
||||
|
||||
child_node = node->getNode("difficulties");
|
||||
for (unsigned int i = 0; i < child_node->getNumNodes(); ++i)
|
||||
{
|
||||
const XMLNode* type = child_node->getNode(i);
|
||||
m_player_difficulties[i] = new PlayerDifficulty();
|
||||
m_player_difficulties[i]->getAllData(type);
|
||||
m_player_difficulties[i]->setDifficulty((PerPlayerDifficulty) i);
|
||||
}
|
||||
} // getAllData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include <map>
|
||||
|
||||
class KartProperties;
|
||||
class PlayerDifficulty;
|
||||
class MusicInformation;
|
||||
class XMLNode;
|
||||
|
||||
@ -51,8 +50,6 @@ protected:
|
||||
/** Default kart properties. */
|
||||
KartProperties *m_default_kart_properties;
|
||||
std::map<std::string, KartProperties*> m_kart_properties;
|
||||
/** Per-player difficulties. */
|
||||
PlayerDifficulty* m_player_difficulties[PLAYER_DIFFICULTY_COUNT];
|
||||
|
||||
public:
|
||||
/** What to do if a kart already has a powerup when it hits a bonus box:
|
||||
@ -187,10 +184,6 @@ public:
|
||||
{
|
||||
return *m_kart_properties.at(type);
|
||||
} // getKartProperties
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
const PlayerDifficulty * getPlayerDifficulty(PerPlayerDifficulty difficulty)
|
||||
{ return m_player_difficulties[difficulty]; }
|
||||
}
|
||||
; // STKConfig
|
||||
|
||||
|
@ -67,11 +67,9 @@ SlipStream::SlipStream(AbstractKart* kart) : MovingTexture(0, 0), m_kart(kart)
|
||||
setTextureMatrix(&(m_node->getMaterial(0).getTextureMatrix(0)));
|
||||
m_slipstream_time = 0.0f;
|
||||
|
||||
float length = m_kart->getKartProperties()->getSlipstreamLength() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamLength();
|
||||
float length = m_kart->getKartProperties()->getSlipstreamLength();
|
||||
float kw = m_kart->getKartWidth();
|
||||
float ew = m_kart->getKartProperties()->getSlipstreamWidth() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamWidth();
|
||||
float ew = m_kart->getKartProperties()->getSlipstreamWidth();
|
||||
float kl = m_kart->getKartLength();
|
||||
|
||||
Vec3 p[4];
|
||||
@ -314,8 +312,7 @@ void SlipStream::setIntensity(float f, const AbstractKart *kart)
|
||||
bool SlipStream::isSlipstreamReady() const
|
||||
{
|
||||
return m_slipstream_time>
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTime() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamCollectTime();
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTime();
|
||||
} // isSlipstreamReady
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -331,14 +328,10 @@ void SlipStream::updateSlipstreamPower()
|
||||
setIntensity(2.0f, NULL);
|
||||
const KartProperties *kp=m_kart->getKartProperties();
|
||||
m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM,
|
||||
kp->getSlipstreamMaxSpeedIncrease() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamMaxSpeedIncrease(),
|
||||
kp->getSlipstreamAddPower() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamAddPower(),
|
||||
kp->getSlipstreamDuration() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamDuration(),
|
||||
kp->getSlipstreamFadeOutTime() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamFadeOutTime());
|
||||
kp->getSlipstreamMaxSpeedIncrease(),
|
||||
kp->getSlipstreamAddPower(),
|
||||
kp->getSlipstreamDuration(),
|
||||
kp->getSlipstreamFadeOutTime());
|
||||
}
|
||||
} // upateSlipstreamPower
|
||||
|
||||
@ -394,8 +387,7 @@ void SlipStream::update(float dt)
|
||||
// not moving. This is useful for debugging the graphics of SS-ing.
|
||||
//#define DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
|
||||
#ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
|
||||
if(m_kart->getSpeed()<m_kart->getKartProperties()->getSlipstreamMinSpeed() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamMinSpeed())
|
||||
if(m_kart->getSpeed()<m_kart->getKartProperties()->getSlipstreamMinSpeed())
|
||||
{
|
||||
setIntensity(0, NULL);
|
||||
m_slipstream_mode = SS_NONE;
|
||||
@ -437,8 +429,7 @@ void SlipStream::update(float dt)
|
||||
// give karts different slipstream properties.
|
||||
#ifndef DISPLAY_SLIPSTREAM_WITH_0_SPEED_FOR_DEBUGGING
|
||||
if(m_target_kart->getSpeed() <
|
||||
m_kart->getKartProperties()->getSlipstreamMinSpeed() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamMinSpeed())
|
||||
m_kart->getKartProperties()->getSlipstreamMinSpeed())
|
||||
{
|
||||
if(UserConfigParams::m_slipstream_debug &&
|
||||
m_kart->getController()->isPlayerController())
|
||||
@ -452,8 +443,7 @@ void SlipStream::update(float dt)
|
||||
// slipstream length+0.5*kart_length()+0.5*target_kart_length
|
||||
// away from the other kart
|
||||
Vec3 delta = m_kart->getXYZ() - m_target_kart->getXYZ();
|
||||
float l = m_kart->getKartProperties()->getSlipstreamLength() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamLength()
|
||||
float l = m_kart->getKartProperties()->getSlipstreamLength()
|
||||
+ 0.5f*( m_target_kart->getKartLength()
|
||||
+m_kart->getKartLength() );
|
||||
if(delta.length2_2d() > l*l)
|
||||
@ -494,8 +484,7 @@ void SlipStream::update(float dt)
|
||||
m_slipstream_mode = SS_USE;
|
||||
m_kart->handleZipper();
|
||||
m_slipstream_time =
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTime() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamCollectTime();
|
||||
m_kart->getKartProperties()->getSlipstreamCollectTime();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -516,8 +505,7 @@ void SlipStream::update(float dt)
|
||||
setIntensity(m_slipstream_time, m_target_kart);
|
||||
|
||||
m_slipstream_mode = SS_COLLECT;
|
||||
if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime() *
|
||||
m_kart->getPlayerDifficulty()->getSlipstreamCollectTime())
|
||||
if(m_slipstream_time>m_kart->getKartProperties()->getSlipstreamCollectTime())
|
||||
{
|
||||
setIntensity(1.0f, m_target_kart);
|
||||
}
|
||||
|
@ -266,8 +266,7 @@ void Attachment::hitBanana(Item *item, int new_attachment)
|
||||
// same banana again once the explosion animation is finished, giving
|
||||
// the kart the same penalty twice.
|
||||
float f = std::max(item->getDisableTime(),
|
||||
m_kart->getKartProperties()->getExplosionTime() *
|
||||
m_kart->getPlayerDifficulty()->getExplosionTime() + 2.0f);
|
||||
m_kart->getKartProperties()->getExplosionTime() + 2.0f);
|
||||
item->setDisableTime(f);
|
||||
break;
|
||||
}
|
||||
|
@ -178,8 +178,7 @@ bool Plunger::hit(AbstractKart *kart, PhysicalObject *obj)
|
||||
}
|
||||
else
|
||||
{
|
||||
m_keep_alive = m_owner->getKartProperties()->getRubberBandDuration() *
|
||||
m_owner->getPlayerDifficulty()->getRubberBandDuration();
|
||||
m_keep_alive = m_owner->getKartProperties()->getRubberBandDuration();
|
||||
|
||||
// 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
|
||||
|
@ -222,8 +222,7 @@ void Powerup::use()
|
||||
case PowerupManager::POWERUP_SWATTER:
|
||||
m_owner->getAttachment()
|
||||
->set(Attachment::ATTACH_SWATTER,
|
||||
m_owner->getKartProperties()->getSwatterDuration() *
|
||||
m_owner->getPlayerDifficulty()->getSwatterDuration());
|
||||
m_owner->getKartProperties()->getSwatterDuration());
|
||||
break;
|
||||
|
||||
case PowerupManager::POWERUP_BUBBLEGUM:
|
||||
|
@ -149,8 +149,7 @@ void RubberBand::update(float dt)
|
||||
// Check for rubber band snapping
|
||||
// ------------------------------
|
||||
float l = (m_end_position-k).length2();
|
||||
float max_len = m_owner->getKartProperties()->getRubberBandMaxLength() *
|
||||
m_owner->getPlayerDifficulty()->getRubberBandMaxLength();
|
||||
float max_len = m_owner->getKartProperties()->getRubberBandMaxLength();
|
||||
if(l>max_len*max_len)
|
||||
{
|
||||
// Rubber band snaps
|
||||
@ -163,8 +162,7 @@ void RubberBand::update(float dt)
|
||||
// ----------------------------
|
||||
if(m_attached_state!=RB_TO_PLUNGER)
|
||||
{
|
||||
float force = m_owner->getKartProperties()->getRubberBandForce() *
|
||||
m_owner->getPlayerDifficulty()->getRubberBandForce();
|
||||
float force = m_owner->getKartProperties()->getRubberBandForce();
|
||||
Vec3 diff = m_end_position-k;
|
||||
|
||||
// detach rubber band if kart gets very close to hit point
|
||||
@ -180,12 +178,10 @@ void RubberBand::update(float dt)
|
||||
diff.normalize(); // diff can't be zero here
|
||||
m_owner->getBody()->applyCentralForce(diff*force);
|
||||
m_owner->increaseMaxSpeed(MaxSpeed::MS_INCREASE_RUBBER,
|
||||
m_owner->getKartProperties()->getRubberBandSpeedIncrease() *
|
||||
m_owner->getPlayerDifficulty()->getRubberBandSpeedIncrease(),
|
||||
m_owner->getKartProperties()->getRubberBandSpeedIncrease(),
|
||||
/*engine_force*/ 0.0f,
|
||||
/*duration*/0.1f,
|
||||
m_owner->getKartProperties()->getRubberBandFadeOutTime() *
|
||||
m_owner->getPlayerDifficulty()->getRubberBandFadeOutTime());
|
||||
m_owner->getKartProperties()->getRubberBandFadeOutTime());
|
||||
if(m_attached_state==RB_TO_KART)
|
||||
m_hit_kart->getBody()->applyCentralForce(diff*(-force));
|
||||
}
|
||||
|
@ -293,8 +293,7 @@ void Swatter::squashThingsAround()
|
||||
|
||||
if(dist2 >= min_dist2) continue; // too far away, ignore this kart
|
||||
|
||||
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
|
||||
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
|
||||
kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown());
|
||||
|
||||
//Handle achievement if the swatter is used by the current player
|
||||
const StateManager::ActivePlayer *const ap = m_kart->getController()
|
||||
|
@ -36,7 +36,7 @@
|
||||
AbstractKart::AbstractKart(const std::string& ident,
|
||||
int world_kart_id, int position,
|
||||
const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
: Moveable()
|
||||
{
|
||||
m_world_kart_id = world_kart_id;
|
||||
@ -69,7 +69,8 @@ AbstractKart::AbstractKart(const std::string& ident,
|
||||
m_characteristic->addCharacteristic(kart_properties_manager->
|
||||
getKartTypeCharacteristic(m_kart_properties->getKartType()));
|
||||
m_characteristic->addCharacteristic(kart_properties_manager->
|
||||
getPlayerCharacteristic(m_difficulty->getIdent()));
|
||||
getPlayerCharacteristic(KartProperties::getPerPlayerDifficultyAsString(
|
||||
m_difficulty)));
|
||||
m_characteristic->addCharacteristic(m_kart_properties->getCharacteristic());
|
||||
} // AbstractKart
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "items/powerup_manager.hpp"
|
||||
#include "karts/moveable.hpp"
|
||||
#include "karts/controller/kart_control.hpp"
|
||||
#include "karts/player_difficulty.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
|
||||
namespace irr
|
||||
@ -77,7 +76,7 @@ protected:
|
||||
const KartProperties *m_kart_properties;
|
||||
|
||||
/** The per-player difficulty. */
|
||||
const PlayerDifficulty *m_difficulty;
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
/** The combined properties of the kart, the player, etc. */
|
||||
std::unique_ptr<CombinedCharacteristic> m_characteristic;
|
||||
|
||||
@ -101,7 +100,7 @@ public:
|
||||
AbstractKart(const std::string& ident,
|
||||
int world_kart_id,
|
||||
int position, const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
virtual ~AbstractKart();
|
||||
virtual core::stringw getName() const;
|
||||
virtual void reset();
|
||||
@ -138,11 +137,11 @@ public:
|
||||
// Access to the per-player difficulty.
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the per-player difficulty of this kart. */
|
||||
const PlayerDifficulty* getPlayerDifficulty() const
|
||||
const PerPlayerDifficulty getPerPlayerDifficulty() const
|
||||
{ return m_difficulty; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Sets the per-player difficulty. */
|
||||
void setPlayerDifficulty(const PlayerDifficulty *pd) { m_difficulty=pd; }
|
||||
void setPerPlayerDifficulty(const PerPlayerDifficulty d) { m_difficulty=d; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns a unique identifier for this kart (name of the directory the
|
||||
|
@ -78,8 +78,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
|
||||
m_xyz = m_kart->getXYZ();
|
||||
m_orig_y = m_xyz.getY();
|
||||
m_kart->playCustomSFX(SFXManager::CUSTOM_EXPLODE);
|
||||
m_timer = m_kart->getKartProperties()->getExplosionTime() *
|
||||
m_kart->getPlayerDifficulty()->getExplosionTime();
|
||||
m_timer = m_kart->getKartProperties()->getExplosionTime();
|
||||
|
||||
// Non-direct hits will be only affected half as much.
|
||||
if(!direct_hit) m_timer*=0.5f;
|
||||
@ -106,8 +105,7 @@ ExplosionAnimation::ExplosionAnimation(AbstractKart *kart,
|
||||
m_add_rotation.setRoll( (rand()%(2*max_rotation+1)-max_rotation)*f );
|
||||
|
||||
// Set invulnerable time, and graphical effects
|
||||
float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime() *
|
||||
m_kart->getPlayerDifficulty()->getExplosionInvulnerabilityTime();
|
||||
float t = m_kart->getKartProperties()->getExplosionInvulnerabilityTime();
|
||||
m_kart->setInvulnerableTime(t);
|
||||
if ( UserConfigParams::m_graphical_effects )
|
||||
{
|
||||
|
@ -24,8 +24,7 @@
|
||||
|
||||
GhostKart::GhostKart(const std::string& ident)
|
||||
: Kart(ident, /*world kart id*/99999,
|
||||
/*position*/-1, btTransform(), stk_config->getPlayerDifficulty(
|
||||
PLAYER_DIFFICULTY_NORMAL))
|
||||
/*position*/-1, btTransform(), PLAYER_DIFFICULTY_NORMAL)
|
||||
{
|
||||
m_current_transform = 0;
|
||||
m_next_event = 0;
|
||||
|
@ -95,7 +95,7 @@
|
||||
*/
|
||||
Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
int position, const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
: AbstractKart(ident, world_kart_id, position, init_transform,
|
||||
difficulty)
|
||||
|
||||
@ -537,8 +537,7 @@ 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_difficulty->getPlungerInFaceTime();
|
||||
m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime();
|
||||
if(isShielded())
|
||||
{
|
||||
decreaseShieldTime();
|
||||
@ -923,16 +922,13 @@ void Kart::collectedItem(Item *item, int add_info)
|
||||
item->getEmitter()->getIdent() == "nolok");
|
||||
|
||||
// slow down
|
||||
m_bubblegum_time = m_kart_properties->getBubblegumTime() * m_difficulty->getBubblegumTime();
|
||||
m_bubblegum_time = m_kart_properties->getBubblegumTime();
|
||||
m_bubblegum_torque = ((rand()%2)
|
||||
? m_kart_properties->getBubblegumTorque()
|
||||
: -m_kart_properties->getBubblegumTorque()) *
|
||||
m_difficulty->getBubblegumTorque();
|
||||
: -m_kart_properties->getBubblegumTorque());
|
||||
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_BUBBLE,
|
||||
m_kart_properties->getBubblegumSpeedFraction() *
|
||||
m_difficulty->getBubblegumSpeedFraction(),
|
||||
m_kart_properties->getBubblegumFadeInTime() *
|
||||
m_difficulty->getBubblegumFadeInTime(),
|
||||
m_kart_properties->getBubblegumSpeedFraction() ,
|
||||
m_kart_properties->getBubblegumFadeInTime(),
|
||||
m_bubblegum_time);
|
||||
m_goo_sound->setPosition(getXYZ());
|
||||
m_goo_sound->play();
|
||||
@ -959,21 +955,17 @@ float Kart::getActualWheelForce()
|
||||
const std::vector<float>& gear_ratio=m_kart_properties->getGearSwitchRatio();
|
||||
for(unsigned int i=0; i<gear_ratio.size(); i++)
|
||||
{
|
||||
if(m_speed <= m_kart_properties->getMaxSpeed() *
|
||||
m_difficulty->getMaxSpeed() * gear_ratio[i])
|
||||
if(m_speed <= m_kart_properties->getMaxSpeed() * gear_ratio[i])
|
||||
{
|
||||
assert(!isnan(m_kart_properties->getMaxPower() *
|
||||
m_difficulty->getMaxPower()));
|
||||
assert(!isnan(m_kart_properties->getMaxPower()));
|
||||
assert(!isnan(m_kart_properties->getGearPowerIncrease()[i]));
|
||||
return m_kart_properties->getMaxPower() *
|
||||
m_difficulty->getMaxPower()
|
||||
*m_kart_properties->getGearPowerIncrease()[i]
|
||||
+add_force;
|
||||
return m_kart_properties->getMaxPower()
|
||||
* m_kart_properties->getGearPowerIncrease()[i]
|
||||
+ add_force;
|
||||
}
|
||||
}
|
||||
assert(!isnan(m_kart_properties->getMaxPower() * m_difficulty->getMaxPower()));
|
||||
return m_kart_properties->getMaxPower() * m_difficulty->getMaxPower()
|
||||
+add_force * 2;
|
||||
assert(!isnan(m_kart_properties->getMaxPower()));
|
||||
return m_kart_properties->getMaxPower() + add_force * 2;
|
||||
|
||||
} // getActualWheelForce
|
||||
|
||||
@ -1677,33 +1669,23 @@ void Kart::handleZipper(const Material *material, bool play_sound)
|
||||
material->getZipperParameter(&max_speed_increase, &duration,
|
||||
&speed_gain, &fade_out_time, &engine_force);
|
||||
if(max_speed_increase<0)
|
||||
max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease() *
|
||||
m_difficulty->getZipperMaxSpeedIncrease();
|
||||
max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease();
|
||||
if(duration<0)
|
||||
duration = m_kart_properties->getZipperTime() *
|
||||
m_difficulty->getZipperTime();
|
||||
duration = m_kart_properties->getZipperTime();
|
||||
if(speed_gain<0)
|
||||
speed_gain = m_kart_properties->getZipperSpeedGain() *
|
||||
m_difficulty->getZipperSpeedGain();
|
||||
speed_gain = m_kart_properties->getZipperSpeedGain();
|
||||
if(fade_out_time<0)
|
||||
fade_out_time = m_kart_properties->getZipperFadeOutTime() *
|
||||
m_difficulty->getZipperFadeOutTime();
|
||||
fade_out_time = m_kart_properties->getZipperFadeOutTime();
|
||||
if(engine_force<0)
|
||||
engine_force = m_kart_properties->getZipperForce() *
|
||||
m_difficulty->getZipperForce();
|
||||
engine_force = m_kart_properties->getZipperForce();
|
||||
}
|
||||
else
|
||||
{
|
||||
max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease() *
|
||||
m_difficulty->getZipperMaxSpeedIncrease();
|
||||
duration = m_kart_properties->getZipperTime() *
|
||||
m_difficulty->getZipperTime();
|
||||
speed_gain = m_kart_properties->getZipperSpeedGain() *
|
||||
m_difficulty->getZipperSpeedGain();
|
||||
fade_out_time = m_kart_properties->getZipperFadeOutTime() *
|
||||
m_difficulty->getZipperFadeOutTime();
|
||||
engine_force = m_kart_properties->getZipperForce() *
|
||||
m_difficulty->getZipperForce();
|
||||
max_speed_increase = m_kart_properties->getZipperMaxSpeedIncrease();
|
||||
duration = m_kart_properties->getZipperTime();
|
||||
speed_gain = m_kart_properties->getZipperSpeedGain();
|
||||
fade_out_time = m_kart_properties->getZipperFadeOutTime();
|
||||
engine_force = m_kart_properties->getZipperForce();
|
||||
}
|
||||
// Ignore a zipper that's activated while braking
|
||||
if(m_controls.m_brake || m_speed<0) return;
|
||||
@ -1741,8 +1723,7 @@ void Kart::updateNitro(float dt)
|
||||
{
|
||||
return;
|
||||
}
|
||||
m_collected_energy -= dt * m_kart_properties->getNitroConsumption() *
|
||||
m_difficulty->getNitroConsumption();
|
||||
m_collected_energy -= dt * m_kart_properties->getNitroConsumption();
|
||||
if (m_collected_energy < 0)
|
||||
{
|
||||
m_collected_energy = 0;
|
||||
@ -1752,13 +1733,10 @@ void Kart::updateNitro(float dt)
|
||||
if (increase_speed)
|
||||
{
|
||||
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_NITRO,
|
||||
m_kart_properties->getNitroMaxSpeedIncrease() *
|
||||
m_difficulty->getNitroMaxSpeedIncrease(),
|
||||
m_kart_properties->getNitroMaxSpeedIncrease(),
|
||||
getCharacteristic()->getNitroEngineForce(),
|
||||
m_kart_properties->getNitroDuration() *
|
||||
m_difficulty->getNitroDuration(),
|
||||
m_kart_properties->getNitroFadeOutTime() *
|
||||
m_difficulty->getNitroFadeOutTime());
|
||||
m_kart_properties->getNitroDuration(),
|
||||
m_kart_properties->getNitroFadeOutTime());
|
||||
}
|
||||
} // updateNitro
|
||||
|
||||
@ -2063,8 +2041,7 @@ void Kart::updatePhysics(float dt)
|
||||
if(!m_has_started && m_controls.m_accel)
|
||||
{
|
||||
m_has_started = true;
|
||||
float f = m_kart_properties->getStartupBoost() *
|
||||
m_difficulty->getStartupBoost();
|
||||
float f = m_kart_properties->getStartupBoost();
|
||||
m_max_speed->instantSpeedIncrease(MaxSpeed::MS_INCREASE_ZIPPER,
|
||||
0.9f*f, f,
|
||||
/*engine_force*/200.0f,
|
||||
@ -2262,10 +2239,8 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
m_brake_time += dt;
|
||||
// Apply the brakes - include the time dependent brake increase
|
||||
float f = 1 + m_brake_time
|
||||
* m_kart_properties->getBrakeTimeIncrease() *
|
||||
m_difficulty->getBrakeTimeIncrease();
|
||||
m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor() *
|
||||
m_difficulty->getBrakeFactor() * f);
|
||||
* m_kart_properties->getBrakeTimeIncrease();
|
||||
m_vehicle->setAllBrakes(m_kart_properties->getBrakeFactor() * f);
|
||||
}
|
||||
else // m_speed < 0
|
||||
{
|
||||
@ -2273,8 +2248,7 @@ void Kart::updateEnginePowerAndBrakes(float dt)
|
||||
// going backward, apply reverse gear ratio (unless he goes
|
||||
// too fast backwards)
|
||||
if ( -m_speed < m_max_speed->getCurrentMaxSpeed()
|
||||
*m_kart_properties->getMaxSpeedReverseRatio() *
|
||||
m_difficulty->getMaxSpeedReverseRatio())
|
||||
*m_kart_properties->getMaxSpeedReverseRatio())
|
||||
{
|
||||
// The backwards acceleration is artificially increased to
|
||||
// allow players to get "unstuck" quicker if they hit e.g.
|
||||
@ -2535,8 +2509,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
{
|
||||
// fabs(speed) is important, otherwise the negative number will
|
||||
// become a huge unsigned number in the particle scene node!
|
||||
nitro_frac = fabsf(getSpeed())/(m_kart_properties->getMaxSpeed() *
|
||||
m_difficulty->getMaxSpeed() );
|
||||
nitro_frac = fabsf(getSpeed())/(m_kart_properties->getMaxSpeed());
|
||||
// The speed of the kart can be higher (due to powerups) than
|
||||
// the normal maximum speed of the kart.
|
||||
if(nitro_frac>1.0f) nitro_frac = 1.0f;
|
||||
@ -2551,8 +2524,7 @@ void Kart::updateGraphics(float dt, const Vec3& offset_xyz,
|
||||
// leaning might get less if a kart gets a special that increases
|
||||
// its maximum speed, but not the current speed (by much). On the
|
||||
// other hand, that ratio can often be greater than 1.
|
||||
float speed_frac = m_speed / m_kart_properties->getMaxSpeed() *
|
||||
m_difficulty->getMaxSpeed();
|
||||
float speed_frac = m_speed / m_kart_properties->getMaxSpeed();
|
||||
if(speed_frac>1.0f)
|
||||
speed_frac = 1.0f;
|
||||
else if (speed_frac < 0.0f) // no leaning when backwards driving
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "items/powerup.hpp"
|
||||
#include "karts/abstract_kart.hpp"
|
||||
#include "karts/kart_properties.hpp"
|
||||
#include "karts/player_difficulty.hpp"
|
||||
#include "tracks/terrain_info.hpp"
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
@ -237,7 +236,7 @@ private:
|
||||
public:
|
||||
Kart(const std::string& ident, unsigned int world_kart_id,
|
||||
int position, const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
virtual ~Kart();
|
||||
virtual void init(RaceManager::KartType type);
|
||||
virtual void kartIsInRestNow();
|
||||
|
@ -321,8 +321,7 @@ void KartGFX::updateTerrain(const ParticleKind *pk)
|
||||
if (skidding > 1.0f && on_ground)
|
||||
rate = fabsf(m_kart->getControls().m_steer) > 0.8 ? skidding - 1 : 0;
|
||||
else if (speed >= 0.5f && on_ground)
|
||||
rate = speed/m_kart->getKartProperties()->getMaxSpeed() *
|
||||
m_kart->getPlayerDifficulty()->getMaxSpeed();
|
||||
rate = speed/m_kart->getKartProperties()->getMaxSpeed();
|
||||
else
|
||||
{
|
||||
pe->setCreationRateAbsolute(0);
|
||||
|
@ -45,6 +45,17 @@
|
||||
|
||||
float KartProperties::UNDEFINED = -99.9f;
|
||||
|
||||
std::string KartProperties::getPerPlayerDifficultyAsString(PerPlayerDifficulty d)
|
||||
{
|
||||
switch(d)
|
||||
{
|
||||
case PLAYER_DIFFICULTY_NORMAL: return "normal"; break;
|
||||
case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break;
|
||||
default: assert(false);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/** The constructor initialises all values with invalid values. It can later
|
||||
* then be checked (for STKConfig) that all values are indeed defined.
|
||||
* Otherwise the defaults are taken from STKConfig (and since they are all
|
||||
|
@ -412,6 +412,9 @@ private:
|
||||
|
||||
|
||||
public:
|
||||
/** Returns the string representation of a per-player difficulty. */
|
||||
static std::string getPerPlayerDifficultyAsString(PerPlayerDifficulty d);
|
||||
|
||||
KartProperties (const std::string &filename="");
|
||||
~KartProperties ();
|
||||
void copyFrom (const KartProperties *source);
|
||||
|
@ -26,7 +26,7 @@
|
||||
KartWithStats::KartWithStats(const std::string& ident,
|
||||
unsigned int world_kart_id,
|
||||
int position, const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
: Kart(ident, world_kart_id, position,
|
||||
init_transform, difficulty)
|
||||
{
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
unsigned int world_kart_id,
|
||||
int position,
|
||||
const btTransform& init_transform,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
virtual void update(float dt);
|
||||
virtual void reset();
|
||||
virtual void collectedItem(Item *item, int add_info);
|
||||
|
@ -62,8 +62,7 @@ MaxSpeed::MaxSpeed(AbstractKart *kart)
|
||||
*/
|
||||
void MaxSpeed::reset()
|
||||
{
|
||||
m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed() *
|
||||
m_kart->getPlayerDifficulty()->getMaxSpeed();
|
||||
m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed();
|
||||
m_min_speed = -1.0f;
|
||||
|
||||
for(unsigned int i=MS_DECREASE_MIN; i<MS_DECREASE_MAX; i++)
|
||||
@ -243,8 +242,7 @@ void MaxSpeed::update(float dt)
|
||||
}
|
||||
|
||||
m_add_engine_force = 0;
|
||||
m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed() *
|
||||
m_kart->getPlayerDifficulty()->getMaxSpeed();
|
||||
m_current_max_speed = m_kart->getKartProperties()->getMaxSpeed();
|
||||
|
||||
// Then add the speed increase from each category
|
||||
// ----------------------------------------------
|
||||
|
@ -1,200 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006-2015 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "karts/player_difficulty.hpp"
|
||||
|
||||
#include "config/stk_config.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "karts/skidding_properties.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "modes/world.hpp"
|
||||
#include "utils/log.hpp"
|
||||
|
||||
/**
|
||||
* The constructor initialises all values with default values.
|
||||
*/
|
||||
PlayerDifficulty::PlayerDifficulty(const std::string &filename) :
|
||||
m_difficulty(PLAYER_DIFFICULTY_NORMAL)
|
||||
{
|
||||
// Set all other values to undefined, so that it can later be tested
|
||||
// if everything is defined properly.
|
||||
m_mass = m_brake_factor = m_brake_time_increase = m_rescue_time =
|
||||
m_explosion_time = m_explosion_invulnerability_time = m_zipper_time =
|
||||
m_zipper_fade_out_time = m_zipper_force = m_zipper_speed_gain =
|
||||
m_zipper_max_speed_increase = m_rubber_band_max_length =
|
||||
m_rubber_band_force = m_rubber_band_duration =
|
||||
m_rubber_band_speed_increase = m_rubber_band_fade_out_time =
|
||||
m_nitro_consumption = m_nitro_max_speed_increase =
|
||||
m_nitro_engine_force = m_nitro_duration = m_nitro_fade_out_time =
|
||||
m_bubblegum_time = m_bubblegum_torque = m_bubblegum_speed_fraction =
|
||||
m_bubblegum_fade_in_time = m_swatter_duration = m_squash_duration =
|
||||
m_squash_slowdown = m_max_speed_reverse_ratio = m_slipstream_length =
|
||||
m_slipstream_width = m_slipstream_collect_time =
|
||||
m_slipstream_use_time = m_slipstream_add_power =
|
||||
m_slipstream_min_speed = m_slipstream_max_speed_increase =
|
||||
m_slipstream_duration = m_slipstream_fade_out_time = 1;
|
||||
|
||||
m_startup_times.resize(RaceManager::DIFFICULTY_COUNT, 1);
|
||||
m_startup_boost.resize(RaceManager::DIFFICULTY_COUNT, 1);
|
||||
|
||||
// The default constructor for stk_config uses filename=""
|
||||
if (filename != "")
|
||||
load(filename, "normal");
|
||||
} // PlayerDifficulty
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Destructor, dereferences the kart model. */
|
||||
PlayerDifficulty::~PlayerDifficulty()
|
||||
{
|
||||
} // ~PlayerDifficulty
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** */
|
||||
std::string PlayerDifficulty::getIdent() const
|
||||
{
|
||||
switch(m_difficulty)
|
||||
{
|
||||
case PLAYER_DIFFICULTY_NORMAL: return "normal"; break;
|
||||
case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break;
|
||||
default: assert(false);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Loads the difficulty properties from a file.
|
||||
* \param filename Filename to load.
|
||||
* \param node Name of the xml node to load the data from
|
||||
*/
|
||||
void PlayerDifficulty::load(const std::string &filename, const std::string &node)
|
||||
{
|
||||
const XMLNode* root = new XMLNode(filename);
|
||||
getAllData(root->getNode(node));
|
||||
if(root)
|
||||
delete root;
|
||||
} // load
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Actually reads in the data from the xml file.
|
||||
* \param root Root of the xml tree.
|
||||
*/
|
||||
void PlayerDifficulty::getAllData(const XMLNode * root)
|
||||
{
|
||||
if(const XMLNode *mass_node = root->getNode("mass"))
|
||||
mass_node->get("value", &m_mass);
|
||||
|
||||
if(const XMLNode *engine_node = root->getNode("engine"))
|
||||
{
|
||||
engine_node->get("brake-factor", &m_brake_factor);
|
||||
engine_node->get("brake-time-increase", &m_brake_time_increase);
|
||||
engine_node->get("max-speed-reverse-ratio", &m_max_speed_reverse_ratio);
|
||||
engine_node->get("power", &m_engine_power);
|
||||
engine_node->get("max-speed", &m_max_speed);
|
||||
}
|
||||
|
||||
if(const XMLNode *nitro_node = root->getNode("nitro"))
|
||||
{
|
||||
nitro_node->get("consumption", &m_nitro_consumption );
|
||||
nitro_node->get("max-speed-increase", &m_nitro_max_speed_increase);
|
||||
nitro_node->get("engine-force", &m_nitro_engine_force );
|
||||
nitro_node->get("duration", &m_nitro_duration );
|
||||
nitro_node->get("fade-out-time", &m_nitro_fade_out_time );
|
||||
}
|
||||
|
||||
if(const XMLNode *bubble_node = root->getNode("bubblegum"))
|
||||
{
|
||||
bubble_node->get("time", &m_bubblegum_time );
|
||||
bubble_node->get("speed-fraction", &m_bubblegum_speed_fraction);
|
||||
bubble_node->get("torque", &m_bubblegum_torque );
|
||||
bubble_node->get("fade-in-time", &m_bubblegum_fade_in_time );
|
||||
}
|
||||
|
||||
if(const XMLNode *rescue_node = root->getNode("rescue"))
|
||||
rescue_node->get("time", &m_rescue_time);
|
||||
|
||||
if(const XMLNode *explosion_node = root->getNode("explosion"))
|
||||
{
|
||||
explosion_node->get("time", &m_explosion_time);
|
||||
explosion_node->get("invulnerability-time",
|
||||
&m_explosion_invulnerability_time);
|
||||
}
|
||||
|
||||
if(const XMLNode *slipstream_node = root->getNode("slipstream"))
|
||||
{
|
||||
slipstream_node->get("length", &m_slipstream_length );
|
||||
slipstream_node->get("width", &m_slipstream_width );
|
||||
slipstream_node->get("collect-time", &m_slipstream_collect_time );
|
||||
slipstream_node->get("use-time", &m_slipstream_use_time );
|
||||
slipstream_node->get("add-power", &m_slipstream_add_power );
|
||||
slipstream_node->get("min-speed", &m_slipstream_min_speed );
|
||||
slipstream_node->get("max-speed-increase",
|
||||
&m_slipstream_max_speed_increase);
|
||||
slipstream_node->get("duration", &m_slipstream_duration );
|
||||
slipstream_node->get("fade-out-time", &m_slipstream_fade_out_time );
|
||||
}
|
||||
|
||||
if(const XMLNode *plunger_node= root->getNode("plunger"))
|
||||
{
|
||||
plunger_node->get("band-max-length", &m_rubber_band_max_length );
|
||||
plunger_node->get("band-force", &m_rubber_band_force );
|
||||
plunger_node->get("band-duration", &m_rubber_band_duration );
|
||||
plunger_node->get("band-speed-increase",&m_rubber_band_speed_increase);
|
||||
plunger_node->get("band-fade-out-time", &m_rubber_band_fade_out_time );
|
||||
plunger_node->get("in-face-time", &m_plunger_in_face_duration);
|
||||
}
|
||||
|
||||
if(const XMLNode *zipper_node= root->getNode("zipper"))
|
||||
{
|
||||
zipper_node->get("time", &m_zipper_time );
|
||||
zipper_node->get("fade-out-time", &m_zipper_fade_out_time );
|
||||
zipper_node->get("force", &m_zipper_force );
|
||||
zipper_node->get("speed-gain", &m_zipper_speed_gain );
|
||||
zipper_node->get("max-speed-increase", &m_zipper_max_speed_increase);
|
||||
}
|
||||
|
||||
if(const XMLNode *swatter_node= root->getNode("swatter"))
|
||||
{
|
||||
swatter_node->get("duration", &m_swatter_duration );
|
||||
swatter_node->get("squash-duration", &m_squash_duration );
|
||||
swatter_node->get("squash-slowdown", &m_squash_slowdown );
|
||||
}
|
||||
|
||||
if(const XMLNode *startup_node= root->getNode("startup"))
|
||||
{
|
||||
startup_node->get("time", &m_startup_times);
|
||||
startup_node->get("boost", &m_startup_boost);
|
||||
}
|
||||
} // getAllData
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called the first time a kart accelerates after 'ready-set-go'. It searches
|
||||
* through m_startup_times to find the appropriate slot, and returns the
|
||||
* speed-boost from the corresponding entry in m_startup_boost.
|
||||
* If the kart started too slow (i.e. slower than the longest time in
|
||||
* m_startup_times, it returns 0.
|
||||
*/
|
||||
float PlayerDifficulty::getStartupBoost() const
|
||||
{
|
||||
float t = World::getWorld()->getTime();
|
||||
for(unsigned int i=0; i<m_startup_times.size(); i++)
|
||||
{
|
||||
if(t<=m_startup_times[i]) return m_startup_boost[i];
|
||||
}
|
||||
return 0;
|
||||
} // getStartupBoost
|
||||
|
@ -1,347 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2006-2015 SuperTuxKart-Team
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_PLAYER_DIFFICULTY_HPP
|
||||
#define HEADER_PLAYER_DIFFICULTY_HPP
|
||||
|
||||
#include "network/remote_kart_info.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
* \brief This class stores values that modify the properties of a kart.
|
||||
* This includes physical properties like speed and the effect of items.
|
||||
* The values stored in this class get multiplied with the current
|
||||
* properties of the kart. If all values here are set to 1, nothing changes.
|
||||
*
|
||||
* \ingroup karts
|
||||
*/
|
||||
class PlayerDifficulty
|
||||
{
|
||||
private:
|
||||
/** Actual difficulty */
|
||||
PerPlayerDifficulty m_difficulty;
|
||||
|
||||
// -----------------
|
||||
/** Weight of kart. */
|
||||
float m_mass;
|
||||
|
||||
/** Maximum force from engine for each difficulty. */
|
||||
float m_engine_power;
|
||||
|
||||
/** Braking factor * engine_power braking force. */
|
||||
float m_brake_factor;
|
||||
|
||||
/** Brake_time * m_brake_time_increase will increase the break time
|
||||
* over time. */
|
||||
float m_brake_time_increase;
|
||||
|
||||
/** Time a kart is moved upwards after when it is rescued. */
|
||||
float m_rescue_time;
|
||||
|
||||
/** Time an animated explosion is shown. Longer = more delay for kart. */
|
||||
float m_explosion_time;
|
||||
|
||||
/** How long a kart is invulnerable after it is hit by an explosion. */
|
||||
float m_explosion_invulnerability_time;
|
||||
|
||||
/** Duration a zipper is active. */
|
||||
float m_zipper_time;
|
||||
|
||||
/** Fade out time for a zipper. */
|
||||
float m_zipper_fade_out_time;
|
||||
|
||||
/** Additional force added to the acceleration. */
|
||||
float m_zipper_force;
|
||||
|
||||
/** Initial one time speed gain. */
|
||||
float m_zipper_speed_gain;
|
||||
|
||||
/** Absolute increase of the kart's maximum speed (in m/s). */
|
||||
float m_zipper_max_speed_increase;
|
||||
|
||||
/** Max. length of plunger rubber band. */
|
||||
float m_rubber_band_max_length;
|
||||
/** Force of an attached rubber band. */
|
||||
/** Duration a rubber band works. */
|
||||
float m_rubber_band_force;
|
||||
/** How long the rubber band will fly. */
|
||||
float m_rubber_band_duration;
|
||||
/** Increase of maximum speed of the kart when the rubber band pulls. */
|
||||
float m_rubber_band_speed_increase;
|
||||
/** Fade out time when the rubber band is removed. */
|
||||
float m_rubber_band_fade_out_time;
|
||||
/**Duration of plunger in face depending on difficulty. */
|
||||
float m_plunger_in_face_duration;
|
||||
/** Nitro consumption. */
|
||||
float m_nitro_consumption;
|
||||
/* How much the speed of a kart might exceed its maximum speed (in m/s). */
|
||||
float m_nitro_max_speed_increase;
|
||||
/** Additional engine force to affect the kart. */
|
||||
float m_nitro_engine_force;
|
||||
/** How long the increased nitro max speed will be valid after
|
||||
* the kart stops using nitro (and the fade-out-time starts). */
|
||||
float m_nitro_duration;
|
||||
/** Duration during which the increased maximum speed
|
||||
* due to nitro fades out. */
|
||||
float m_nitro_fade_out_time;
|
||||
/** Bubble gum diration. */
|
||||
float m_bubblegum_time;
|
||||
/** Torque to add when a bubble gum was hit in order to make the kart go
|
||||
* sideways a bit. */
|
||||
float m_bubblegum_torque;
|
||||
/** Fraction of top speed that can be reached maximum after hitting a
|
||||
* bubble gum. */
|
||||
float m_bubblegum_speed_fraction;
|
||||
/** How long to fade in the slowdown for a bubble gum. */
|
||||
float m_bubblegum_fade_in_time;
|
||||
/** How long the swatter lasts. */
|
||||
float m_swatter_duration;
|
||||
/** How long a kart will remain squashed. */
|
||||
float m_squash_duration;
|
||||
/** The slowdown to apply while a kart is squashed. The new maxspeed
|
||||
* is max_speed*m_squash_slowdown. */
|
||||
float m_squash_slowdown;
|
||||
|
||||
/** The maximum speed at each difficulty. */
|
||||
float m_max_speed;
|
||||
|
||||
float m_max_speed_reverse_ratio;
|
||||
|
||||
/** How far behind a kart slipstreaming is effective. */
|
||||
float m_slipstream_length;
|
||||
/** How wide the slipstream area is at the end. */
|
||||
float m_slipstream_width;
|
||||
/** Time after which sstream gives a bonus. */
|
||||
float m_slipstream_collect_time;
|
||||
/** Time slip-stream bonus is effective. */
|
||||
float m_slipstream_use_time;
|
||||
/** Additional power due to sstreaming. */
|
||||
float m_slipstream_add_power;
|
||||
/** Minimum speed for slipstream to take effect. */
|
||||
float m_slipstream_min_speed;
|
||||
/** How much the speed of the kart might exceed its
|
||||
* normal maximum speed. */
|
||||
float m_slipstream_max_speed_increase;
|
||||
/** How long the higher speed lasts after slipstream stopped working. */
|
||||
float m_slipstream_duration;
|
||||
/** How long the slip stream speed increase will gradually be reduced. */
|
||||
float m_slipstream_fade_out_time;
|
||||
|
||||
/** If the kart starts within the specified time at index I after 'go',
|
||||
* it receives the speed boost from m_startup_boost[I]. */
|
||||
std::vector<float> m_startup_times;
|
||||
|
||||
/** The startup boost is the kart starts fast enough. */
|
||||
std::vector<float> m_startup_boost;
|
||||
|
||||
|
||||
void load (const std::string &filename,
|
||||
const std::string &node);
|
||||
|
||||
|
||||
public:
|
||||
PlayerDifficulty (const std::string &filename="");
|
||||
~PlayerDifficulty ();
|
||||
void setDifficulty (PerPlayerDifficulty difficulty) { m_difficulty = difficulty; }
|
||||
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
|
||||
void getAllData (const XMLNode * root);
|
||||
std::string getIdent () const;
|
||||
float getStartupBoost () const;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the maximum engine power depending on difficulty. */
|
||||
float getMaxPower () const {return m_engine_power; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Get braking information. */
|
||||
float getBrakeFactor () const {return m_brake_factor; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the additional brake factor which depends on time. */
|
||||
float getBrakeTimeIncrease() const { return m_brake_time_increase; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Get maximum reverse speed ratio. */
|
||||
float getMaxSpeedReverseRatio () const
|
||||
{return m_max_speed_reverse_ratio; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the maximum speed dependent on the difficult level. */
|
||||
float getMaxSpeed () const { return m_max_speed; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the nitro consumption. */
|
||||
float getNitroConsumption () const {return m_nitro_consumption; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the increase of maximum speed due to nitro. */
|
||||
float getNitroMaxSpeedIncrease () const
|
||||
{return m_nitro_max_speed_increase; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
float getNitroEngineForce () const {return m_nitro_engine_force; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long the increased nitro max speed will be valid after
|
||||
* the kart stops using nitro (and the fade-out-time starts). */
|
||||
float getNitroDuration () const {return m_nitro_duration; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the duration during which the increased maximum speed
|
||||
* due to nitro fades out. */
|
||||
float getNitroFadeOutTime () const {return m_nitro_fade_out_time; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long a bubble gum is active. */
|
||||
float getBubblegumTime() const { return m_bubblegum_time; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the torque to add when a bubble gum was hit . */
|
||||
float getBubblegumTorque() const { return m_bubblegum_torque; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the fraction of top speed that can be reached maximum after
|
||||
* hitting a bubble gum. */
|
||||
float getBubblegumSpeedFraction() const {return m_bubblegum_speed_fraction;}
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long to fade in the slowdown for a bubble gum. */
|
||||
float getBubblegumFadeInTime() const { return m_bubblegum_fade_in_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time a kart is rised during a rescue. */
|
||||
float getRescueTime () const {return m_rescue_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time an explosion animation is shown. */
|
||||
float getExplosionTime () const {return m_explosion_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long a kart is invulnerable after being hit by an
|
||||
explosion. */
|
||||
float getExplosionInvulnerabilityTime() const
|
||||
{ return m_explosion_invulnerability_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the maximum length of a rubber band before it breaks. */
|
||||
float getRubberBandMaxLength () const {return m_rubber_band_max_length;}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns force a rubber band has when attached to a kart. */
|
||||
float getRubberBandForce () const {return m_rubber_band_force; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the duration a rubber band is active for. */
|
||||
float getRubberBandDuration () const {return m_rubber_band_duration; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the increase of maximum speed while a rubber band is
|
||||
* pulling. */
|
||||
float getRubberBandSpeedIncrease() const
|
||||
{
|
||||
return m_rubber_band_speed_increase;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Return the fade out time once a rubber band is removed. */
|
||||
float getRubberBandFadeOutTime() const
|
||||
{
|
||||
return m_rubber_band_fade_out_time;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns duration of a plunger in your face. */
|
||||
float getPlungerInFaceTime () const {return m_plunger_in_face_duration;}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time a zipper is active. */
|
||||
float getZipperTime () const {return m_zipper_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the time a zipper is active. */
|
||||
float getZipperFadeOutTime () const {return m_zipper_fade_out_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the additional force added applied to the kart. */
|
||||
float getZipperForce () const { return m_zipper_force; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the initial zipper speed gain. */
|
||||
float getZipperSpeedGain () const { return m_zipper_speed_gain; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the increase of the maximum speed of the kart
|
||||
* if a zipper is active. */
|
||||
float getZipperMaxSpeedIncrease () const
|
||||
{ return m_zipper_max_speed_increase;}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how far behind a kart slipstreaming works. */
|
||||
float getSlipstreamLength () const {return m_slipstream_length; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how wide the slipstream area is at the end. */
|
||||
float getSlipstreamWidth () const {return m_slipstream_width; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns time after which slipstream has maximum effect. */
|
||||
float getSlipstreamCollectTime () const
|
||||
{return m_slipstream_collect_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns time after which slipstream has maximum effect. */
|
||||
float getSlipstreamUseTime () const {return m_slipstream_use_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns additional power due to slipstreaming. */
|
||||
float getSlipstreamAddPower () const {return m_slipstream_add_power; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the minimum slipstream speed. */
|
||||
float getSlipstreamMinSpeed () const {return m_slipstream_min_speed; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the increase of the maximum speed of a kart
|
||||
* due to slipstream. */
|
||||
float getSlipstreamMaxSpeedIncrease() const
|
||||
{ return m_slipstream_max_speed_increase; }
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long the higher speed lasts after slipstream
|
||||
* stopped working. */
|
||||
float getSlipstreamDuration () const { return m_slipstream_duration; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long the slip stream speed increase will gradually
|
||||
* be reduced. */
|
||||
float getSlipstreamFadeOutTime () const
|
||||
{ return m_slipstream_fade_out_time; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long a swatter will stay attached/ready to be used. */
|
||||
float getSwatterDuration() const { return m_swatter_duration; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns how long a kart remains squashed. */
|
||||
float getSquashDuration() const {return m_squash_duration; }
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
/** Returns the slowdown of a kart that is squashed. */
|
||||
float getSquashSlowdown() const {return m_squash_slowdown; }
|
||||
}; // KartProperties
|
||||
|
||||
#endif
|
||||
|
@ -39,8 +39,7 @@ RescueAnimation::RescueAnimation(AbstractKart *kart, bool is_auto_rescue)
|
||||
{
|
||||
m_referee = new Referee(*m_kart);
|
||||
m_kart->getNode()->addChild(m_referee->getSceneNode());
|
||||
m_timer = m_kart->getKartProperties()->getRescueTime() *
|
||||
m_kart->getPlayerDifficulty()->getRescueTime();
|
||||
m_timer = m_kart->getKartProperties()->getRescueTime();
|
||||
m_velocity = m_kart->getKartProperties()->getRescueHeight() / m_timer;
|
||||
m_xyz = m_kart->getXYZ();
|
||||
|
||||
|
@ -106,7 +106,7 @@ void ProfileWorld::setProfileModeLaps(int laps)
|
||||
AbstractKart *ProfileWorld::createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType type,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
{
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
|
||||
|
@ -75,7 +75,7 @@ protected:
|
||||
virtual AbstractKart *createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType type,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
|
||||
public:
|
||||
ProfileWorld();
|
||||
|
@ -467,7 +467,7 @@ int SoccerWorld::getTeamLeader(unsigned int team)
|
||||
AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType kart_type,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
{
|
||||
int posIndex = index;
|
||||
int position = index+1;
|
||||
|
@ -107,7 +107,7 @@ protected:
|
||||
virtual AbstractKart *createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType type,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
}; // SoccerWorld
|
||||
|
||||
|
||||
|
@ -183,12 +183,10 @@ void World::init()
|
||||
: race_manager->getKartIdent(i);
|
||||
int local_player_id = race_manager->getKartLocalPlayerId(i);
|
||||
int global_player_id = race_manager->getKartGlobalPlayerId(i);
|
||||
const PlayerDifficulty *player_difficulty =
|
||||
stk_config->getPlayerDifficulty(race_manager->getPlayerDifficulty(i));
|
||||
AbstractKart* newkart = createKart(kart_ident, i, local_player_id,
|
||||
global_player_id,
|
||||
race_manager->getKartType(i),
|
||||
player_difficulty);
|
||||
race_manager->getPlayerDifficulty(i));
|
||||
m_karts.push_back(newkart);
|
||||
m_track->adjustForFog(newkart->getNode());
|
||||
|
||||
@ -301,7 +299,7 @@ void World::createRaceGUI()
|
||||
AbstractKart *World::createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType kart_type,
|
||||
const PlayerDifficulty *difficulty)
|
||||
PerPlayerDifficulty difficulty)
|
||||
{
|
||||
int position = index+1;
|
||||
btTransform init_pos = m_track->getStartTransform(index);
|
||||
|
@ -126,7 +126,7 @@ protected:
|
||||
virtual AbstractKart *createKart(const std::string &kart_ident, int index,
|
||||
int local_player_id, int global_player_id,
|
||||
RaceManager::KartType type,
|
||||
const PlayerDifficulty *difficulty);
|
||||
PerPlayerDifficulty difficulty);
|
||||
/** Pointer to the track. The track is managed by world. */
|
||||
Track* m_track;
|
||||
|
||||
|
@ -219,8 +219,8 @@ void Physics::update(float dt)
|
||||
else if (obj->isFlattenKartObject())
|
||||
{
|
||||
const KartProperties* kp = kart->getKartProperties();
|
||||
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
|
||||
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
|
||||
kart->setSquash(kp->getSquashDuration(),
|
||||
kp->getSquashSlowdown());
|
||||
}
|
||||
else if(obj->isSoccerBall() &&
|
||||
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
|
||||
@ -249,8 +249,8 @@ void Physics::update(float dt)
|
||||
{
|
||||
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
|
||||
const KartProperties* kp = kart->getKartProperties();
|
||||
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
|
||||
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
|
||||
kart->setSquash(kp->getSquashDuration(),
|
||||
kp->getSquashSlowdown());
|
||||
}
|
||||
continue;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user