Friendly-fire in soccer mode

This commit is contained in:
Benau 2016-01-15 21:47:21 +08:00
parent e296ebe4af
commit 82dca17f42
2 changed files with 35 additions and 3 deletions

View File

@ -35,6 +35,7 @@
#include "karts/abstract_kart.hpp"
#include "karts/explosion_animation.hpp"
#include "modes/world.hpp"
#include "modes/soccer_world.hpp"
#include "physics/physics.hpp"
#include "tracks/track.hpp"
#include "utils/constants.hpp"
@ -226,6 +227,16 @@ void Flyable::getClosestKart(const AbstractKart **minKart,
if(kart->isEliminated() || kart == m_owner ||
kart->isInvulnerable() ||
kart->getKartAnimation() ) continue;
const SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
if (sw)
{
// Don't hit teammates in soccer world
if (sw->getKartTeam(kart->getWorldKartId()) == sw
->getKartTeam(m_owner->getWorldKartId()))
continue;
}
btTransform t=kart->getTrans();
Vec3 delta = t.getOrigin()-trans_projectile.getOrigin();
@ -461,6 +472,15 @@ void Flyable::explode(AbstractKart *kart_hit, PhysicalObject *object,
{
AbstractKart *kart = world->getKart(i);
const SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
if (sw)
{
// Don't explode teammates in soccer world
if (sw->getKartTeam(kart->getWorldKartId()) == sw
->getKartTeam(m_owner->getWorldKartId()))
continue;
}
// If no secondary hits should be done, only hit the
// direct hit kart.
if(!secondary_hits && kart!=kart_hit)

View File

@ -38,6 +38,7 @@
#include "karts/explosion_animation.hpp"
#include "karts/kart_properties.hpp"
#include "modes/world.hpp"
#include "modes/soccer_world.hpp"
#include "karts/abstract_kart.hpp"
#define SWAT_POS_OFFSET core::vector3df(0.0, 0.2f, -0.4f)
@ -196,10 +197,12 @@ bool Swatter::updateAndTestFinished(float dt)
// change the current phase
squashThingsAround();
m_animation_phase = SWATTER_FROM_TARGET;
if (race_manager->getMinorMode()==
RaceManager::MINOR_MODE_3_STRIKES)
if (race_manager
->getMinorMode()==RaceManager::MINOR_MODE_3_STRIKES ||
race_manager
->getMinorMode()==RaceManager::MINOR_MODE_SOCCER)
{
// Remove swatter from kart in 3 strikes battle
// Remove swatter from kart in arena gameplay
// after one successful hit
m_discard_now = true;
}
@ -246,6 +249,15 @@ void Swatter::chooseTarget()
if (kart->isInvulnerable() || kart->isSquashed())
continue;
const SoccerWorld* sw = dynamic_cast<SoccerWorld*>(World::getWorld());
if (sw)
{
// Don't hit teammates in soccer world
if (sw->getKartTeam(kart->getWorldKartId()) == sw
->getKartTeam(m_kart->getWorldKartId()))
continue;
}
float dist2 = (kart->getXYZ()-m_kart->getXYZ()).length2();
if(dist2<min_dist2)
{