Add minimal supersize AI ; special effect when swattered

This commit is contained in:
Alayan 2018-09-21 06:25:02 +02:00
parent d9581d9f70
commit a9b49305db
4 changed files with 35 additions and 1 deletions

View File

@ -268,6 +268,9 @@ public:
/** Returns if the kart is currently being squashed. */
virtual bool isSquashed() const = 0;
// ------------------------------------------------------------------------
/** Returns if the kart is currently being super-sized. */
virtual bool isSuperSized() const = 0;
// ------------------------------------------------------------------------
/** Squashes this kart: it will scale the kart in up direction, and causes
* a slowdown while this kart is squashed.
* \param time How long the kart will be squashed.

View File

@ -1241,6 +1241,12 @@ void SkiddingAI::handleItems(const float dt, const Vec3 *aim_point, int last_nod
m_controls->setFire(true);
break; // POWERUP_PARACHUTE
case PowerupManager::POWERUP_SUPER_SIZE:
// FIXME : this is a temporary AI to avoid crashes
if(m_time_since_last_shot > 1.0f)
m_controls->setFire(true);
break; // POWERUP_SUPER_SIZE
case PowerupManager::POWERUP_SWATTER:
{
// if the kart has a shield, do not break it by using a swatter.

View File

@ -1795,7 +1795,12 @@ void Kart::setSquash(float time, float slowdown)
return;
}
unsetSuper(true /*instant*/);
if(isSuperSized())
{
unsetSuper(true /*instant*/);
setInvulnerableTicks(stk_config->time2Ticks(2.5f));
return;
}
m_max_speed->setSlowdown(MaxSpeed::MS_DECREASE_SQUASH, slowdown,
stk_config->time2Ticks(0.1f),
@ -1869,6 +1874,8 @@ void Kart::setSuper()
stk_config->time2Ticks(duration),
stk_config->time2Ticks(fade_out_time));
//FIXME : Use something based on config/Time2Ticks
//FIXME : check current scaling status before upscaling
m_scale_change_ticks = 40;
m_super_time = duration;
} // setSuper
@ -1878,6 +1885,7 @@ void Kart::setSuper()
*/
void Kart::updateScale(int ticks)
{
//TODO update physics model too
if (m_scale_change_ticks == 0) return;
@ -1895,7 +1903,9 @@ void Kart::updateScale(int ticks)
scale_factor = 1.0 - (m_scale_change_ticks*0.01);
}
#ifndef SERVER_ONLY
m_node->setScale(core::vector3df(scale_factor,scale_factor,scale_factor));
#endif
} // setSuper
//-----------------------------------------------------------------------------
@ -1907,7 +1917,9 @@ void Kart::unsetSuper(bool instant)
m_super_time = std::numeric_limits<float>::max();
if (instant)
{
#ifndef SERVER_ONLY
m_node->setScale(core::vector3df(1.0f,1.0f,1.0f));
#endif
m_scale_change_ticks = 0;
// This resets the speed boost
m_max_speed->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SUPER,
@ -1931,6 +1943,16 @@ bool Kart::isSquashed() const
m_max_speed->isSpeedDecreaseActive(MaxSpeed::MS_DECREASE_SQUASH) == 1;
} // setSquash
//-----------------------------------------------------------------------------
/** Returns if the kart is currently super-sized
*/
bool Kart::isSuperSized() const
{
return
m_max_speed->getSpeedIncreaseTicksLeft(MaxSpeed::MS_INCREASE_SUPER) > 0;
} // setSquash
//-----------------------------------------------------------------------------
/** Plays any terrain specific sound effect.
*/

View File

@ -517,6 +517,9 @@ public:
/** Returns if the kart is currently being squashed. */
virtual bool isSquashed() const OVERRIDE;
// ------------------------------------------------------------------------
/** Returns if the kart is currently super sized. */
virtual bool isSuperSized() const OVERRIDE;
// ------------------------------------------------------------------------
/** Shows the star effect for a certain time. */
virtual void showStarEffect(float t) OVERRIDE;
// ------------------------------------------------------------------------