SuperTuxKart
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SpareTireAI Class Reference

The AI for spare tire karts in battle mode, allowing kart to gain life. More...

#include <spare_tire_ai.hpp>

Inheritance diagram for SpareTireAI:
Inheritance graph
[legend]

Public Member Functions

 SpareTireAI (AbstractKart *kart)
 
virtual void crashed (const AbstractKart *k) OVERRIDE
 Callback function when a kart crashes into the SpareTireAI, the kart will increase one life if its life is not equal 3. More...
 
virtual void update (int ticks) OVERRIDE
 Besides calling update from parent class, it will auto unspawn if m_timer reaches zero which it will be decreased here. More...
 
virtual void reset () OVERRIDE
 Resets the AI when a race is restarted.
 
void spawn (int ticks_to_last)
 Spawn the SpareTireAI, it will start appearing in the battle mode and moving around. More...
 
void unspawn ()
 Unspawn the SpareTireAI, it will be hidden in the battle mode but not deleted, so it can be called with spawn again later.
 
bool isMoving () const
 Return true if this AI needed to be called update by World, ie it is spawned. More...
 
- Public Member Functions inherited from BattleAI
 BattleAI (AbstractKart *kart)
 
- Public Member Functions inherited from ArenaAI
 ArenaAI (AbstractKart *kart)
 
virtual void newLap (int lap) OVERRIDE
 Callback whenever a new lap is triggered. More...
 
- Public Member Functions inherited from AIBaseController
 AIBaseController (AbstractKart *kart)
 
virtual bool disableSlipstreamBonus () const OVERRIDE
 Certain AI levels will not receive a slipstream bonus in order to be not as hard.
 
virtual void crashed (const Material *m) OVERRIDE
 This is called when the kart crashed with the terrain. More...
 
virtual void handleZipper (bool play_sound) OVERRIDE
 
virtual void finishedRace (float time) OVERRIDE
 Called whan this controller's kart finishes the last lap. More...
 
virtual void collectedItem (const ItemState &item, float previous_energy=0) OVERRIDE
 
virtual void setPosition (int p) OVERRIDE
 
virtual bool isPlayerController () const OVERRIDE
 This function checks if this player is not an AI, i.e. More...
 
virtual bool isLocalPlayerController () const OVERRIDE
 This function checks if this is a local player. More...
 
virtual bool action (PlayerAction action, int value, bool dry_run=false) OVERRIDE
 Default: ignore actions. More...
 
virtual void skidBonusTriggered () OVERRIDE
 
virtual bool saveState (BareNetworkString *buffer) const OVERRIDE
 
virtual void rewindTo (BareNetworkString *buffer) OVERRIDE
 
void setNetworkAI (bool val)
 
- Public Member Functions inherited from Controller
 Controller (AbstractKart *kart)
 Constructor, saves the kart pointer and a pointer to the KartControl of the kart.
 
const std::string & getControllerName () const
 Returns the name of this controller. More...
 
virtual KartControlgetControls ()
 Get a pointer on the kart controls. More...
 
void setControls (KartControl *kc)
 
virtual bool canGetAchievements () const
 Only local players can get achievements. More...
 
virtual core::stringw getName (bool include_handicap_string=true) const
 Display name of the controller. More...
 
AbstractKartgetKart () const
 Returns the kart controlled by this controller. More...
 

Private Member Functions

virtual void findTarget () OVERRIDE
 For SpareTireAI, it will pick next node in m_fixed_target_nodes after reach the one in m_idx, or the first one if it's the last.
 
void findDefaultPath ()
 Randomly find a start node for spare tire kart to move, called after spawn.
 

Private Attributes

int m_fixed_target_nodes [4]
 The 4 bounding boxes ArenaNode to follow. More...
 
int m_idx
 The current index of ArenaNode in m_fixed_target_nodes to follow, if it's -1, update is not needed to be called. More...
 
int m_timer
 Store the time before calling unspawn. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from AIBaseController
static void enableDebug ()
 
static void setTestAI (int n)
 
static int getTestAI ()
 
- Protected Member Functions inherited from BattleAI
virtual void findClosestKart (bool consider_difficulty, bool find_sta) OVERRIDE
 Find the closest kart around this AI, if consider_difficulty is true, AI will try to follow human players more or less depends on difficulty. More...
 
virtual int getCurrentNode () const OVERRIDE
 Return the current ArenaNode the AI located on. More...
 
- Protected Member Functions inherited from ArenaAI
void tryCollectItem (Vec3 *aim_point, int *target_node) const
 Try to collect item in arena, if no suitable item is found, like they are swapped, it will follow closest kart instead. More...
 
- Protected Member Functions inherited from AIBaseController
void setControllerName (const std::string &name) OVERRIDE
 In debug mode when the user specified –ai-debug on the command line set the name of the controller as on-screen text, so that the different AI controllers can be distinguished. More...
 
float steerToPoint (const Vec3 &point)
 Computes the steering angle to reach a certain point. More...
 
float normalizeAngle (float angle)
 Normalises an angle to be between -pi and _ pi. More...
 
bool isStuck () const
 This can be called to detect if the kart is stuck (i.e. More...
 
void determineTurnRadius (const Vec3 &end, Vec3 *center, float *radius) const
 Determine the center point and radius of a circle given two points on the circle and the tangent at the first point. More...
 
virtual void setSteering (float angle, float dt)
 Converts the steering angle to a lr steering in the range of -1 to 1. More...
 
- Protected Attributes inherited from BattleAI
WorldWithRankm_world
 Keep a pointer to world. More...
 
ThreeStrikesBattlem_tsb_world
 
- Protected Attributes inherited from ArenaAI
ArenaGraphm_graph
 Pointer to the ArenaGraph. More...
 
AbstractKartm_closest_kart
 Pointer to the closest kart around this kart. More...
 
int m_closest_kart_node
 The ArenaNode at which the closest kart located on. More...
 
Vec3 m_closest_kart_point
 The closest kart location. More...
 
RaceManager::Difficulty m_cur_difficulty
 Holds the current difficulty. More...
 
irr::scene::ISceneNode * m_debug_sphere
 For debugging purpose: a sphere indicating where the AI is targeting at. More...
 
irr::scene::ISceneNode * m_debug_sphere_next
 For debugging purpose: a sphere indicating where the first turning corner is located. More...
 
int m_target_node
 The ArenaNode at which the target point located on. More...
 
Vec3 m_target_point
 The coordinates of target point. More...
 
bool m_mini_skid
 True if AI can skid, currently only do when close to target, see doSkiddingTest(). More...
 
- Protected Attributes inherited from AIBaseController
bool m_enabled_network_ai
 
float m_kart_length
 Length of the kart, storing it here saves many function calls. More...
 
float m_kart_width
 Cache width of kart. More...
 
Trackm_track
 Keep a pointer to the track to reduce calls.
 
const AIPropertiesm_ai_properties
 A pointer to the AI properties for this kart. More...
 
- Protected Attributes inherited from Controller
AbstractKartm_kart
 Pointer to the kart that is controlled by this controller. More...
 
KartControlm_controls
 A pointer to the main controller, from which the kart takes it commands. More...
 
std::string m_controller_name
 The name of the controller, mainly used for debugging purposes. More...
 
- Static Protected Attributes inherited from AIBaseController
static bool m_ai_debug = false
 
static int m_test_ai = 0
 Stores the '–test-ai=n' command line parameter: It indicates which fraction of the AIs are going to be the test AI: 1 means only to use the TestAI, 2 means every second AI will be test etc. More...
 

Detailed Description

The AI for spare tire karts in battle mode, allowing kart to gain life.

Member Function Documentation

◆ crashed()

void SpareTireAI::crashed ( const AbstractKart k)
virtual

Callback function when a kart crashes into the SpareTireAI, the kart will increase one life if its life is not equal 3.

A message will be shown too.

Parameters
kAbstractKart this SpareTireAI crashed.

Reimplemented from AIBaseController.

◆ isMoving()

bool SpareTireAI::isMoving ( ) const
inline

Return true if this AI needed to be called update by World, ie it is spawned.

◆ spawn()

void SpareTireAI::spawn ( int  ticks_to_last)

Spawn the SpareTireAI, it will start appearing in the battle mode and moving around.

Parameters
time_to_lastTime before calling unspawn.

◆ update()

void SpareTireAI::update ( int  ticks)
virtual

Besides calling update from parent class, it will auto unspawn if m_timer reaches zero which it will be decreased here.

Parameters
dtTime step size.

Reimplemented from ArenaAI.

Member Data Documentation

◆ m_fixed_target_nodes

int SpareTireAI::m_fixed_target_nodes[4]
private

The 4 bounding boxes ArenaNode to follow.

◆ m_idx

int SpareTireAI::m_idx
private

The current index of ArenaNode in m_fixed_target_nodes to follow, if it's -1, update is not needed to be called.

◆ m_timer

int SpareTireAI::m_timer
private

Store the time before calling unspawn.


The documentation for this class was generated from the following files: