18#ifndef CAPTURE_THE_FLAG_HPP
19#define CAPTURE_THE_FLAG_HPP
21#include "modes/free_for_all.hpp"
30 class IAnimatedMeshSceneNode;
class IAnimatedMesh;
class ISceneNode;
39 scene::IAnimatedMeshSceneNode* m_red_flag_node;
41 scene::IAnimatedMeshSceneNode* m_blue_flag_node;
43 scene::IAnimatedMesh* m_red_flag_mesh;
45 scene::IAnimatedMesh* m_blue_flag_mesh;
47 scene::ISceneNode* m_red_flag_indicator;
49 scene::ISceneNode* m_blue_flag_indicator;
53 int m_red_scores, m_blue_scores;
56 int m_last_captured_flag_ticks;
59 int m_red_flag_status, m_blue_flag_status;
61 std::map<int, int> m_swatter_reset_kart_ticks;
63 std::shared_ptr<CTFFlag> m_red_flag, m_blue_flag;
66 bool getDroppedFlagTrans(
const btTransform& kt, btTransform* out)
const;
68 void resetRedFlagToOrigin();
70 void resetBlueFlagToOrigin();
72 virtual video::SColor getColor(
unsigned int kart_id)
const OVERRIDE;
80 virtual void init() OVERRIDE;
82 virtual void reset(
bool restart=
false) OVERRIDE;
84 virtual void update(
int ticks) OVERRIDE;
88 virtual bool hasTeam()
const OVERRIDE {
return true; }
92 virtual bool kartHit(
int kart_id,
int hitter = -1) OVERRIDE;
96 virtual const std::string&
getIdent()
const OVERRIDE;
98 bool getKartCTFResult(
unsigned int kart_id)
const
100 if (m_red_scores == m_blue_scores)
103 bool red_win = m_red_scores > m_blue_scores;
106 if ((red_win && team == KART_TEAM_RED) ||
107 (!red_win && team == KART_TEAM_BLUE))
113 int getRedScore()
const {
return m_red_scores; }
115 int getBlueScore()
const {
return m_blue_scores; }
117 int getRedHolder()
const;
119 int getBlueHolder()
const;
121 bool isRedFlagInBase()
const;
123 bool isBlueFlagInBase()
const;
125 const Vec3& getRedFlag()
const;
127 const Vec3& getBlueFlag()
const;
129 void ctfScored(
int kart_id,
bool red_team_scored,
int new_kart_score,
130 int new_red_score,
int new_blue_score);
132 void loseFlagForKart(
int kart_id);
134 void resetKartForSwatterHit(
int kart_id,
int at_world_ticks)
135 { m_swatter_reset_kart_ticks[kart_id] = at_world_ticks; }
140 std::pair<uint32_t, uint32_t> progress(
141 std::numeric_limits<uint32_t>::max(),
142 std::numeric_limits<uint32_t>::max());
143 if (RaceManager::get()->hasTimeTarget())
145 progress.first = (uint32_t)
m_time;
147 if (m_red_scores > m_blue_scores)
149 progress.second = (uint32_t)((
float)m_red_scores /
150 (float)RaceManager::get()->getHitCaptureLimit() * 100.0f);
154 progress.second = (uint32_t)((
float)m_blue_scores /
155 (float)RaceManager::get()->getHitCaptureLimit() * 100.0f);
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: ctf_flag.hpp:44
Definition: capture_the_flag.hpp:37
CaptureTheFlag()
Constructor.
Definition: capture_the_flag.cpp:50
virtual std::pair< uint32_t, uint32_t > getGameStartedProgress() const OVERRIDE
Used by server to get the current started game progress in either or both remaining time or progress ...
Definition: capture_the_flag.hpp:137
virtual bool isRaceOver() OVERRIDE
The battle is over if only one kart is left, or no player kart.
Definition: capture_the_flag.cpp:473
virtual const std::string & getIdent() const OVERRIDE
Returns the internal identifier for this race.
Definition: capture_the_flag.cpp:556
virtual bool kartHit(int kart_id, int hitter=-1) OVERRIDE
Called when a kart is hit.
Definition: capture_the_flag.cpp:534
virtual void reset(bool restart=false) OVERRIDE
Called when a battle is restarted.
Definition: capture_the_flag.cpp:139
virtual unsigned int getRescuePositionIndex(AbstractKart *kart) OVERRIDE
Determines the rescue position for a kart.
Definition: capture_the_flag.cpp:548
virtual void update(int ticks) OVERRIDE
Updates the physics, all karts, the track, and projectile manager.
Definition: capture_the_flag.cpp:226
virtual void init() OVERRIDE
call just after instanciating.
Definition: capture_the_flag.cpp:93
virtual void updateGraphics(float dt) OVERRIDE
This updates all only graphical elements.
Definition: capture_the_flag.cpp:164
Definition: free_for_all.hpp:29
The base class for sound effects.
Definition: sfx_base.hpp:43
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
double m_time
Elasped/remaining time in seconds.
Definition: world_status.hpp:94
KartTeam getKartTeam(unsigned int kart_id) const
Get the team of kart in world (including AIs)
Definition: world.cpp:1663