19#ifndef HEADER_ARENA_AI_HPP
20#define HEADER_ARENA_AI_HPP
22#include "karts/controller/ai_base_controller.hpp"
23#include "race/race_manager.hpp"
27#include "graphics/irr_driver.hpp"
35 namespace scene {
class ISceneNode; }
154 virtual bool canSkid(
float steer_fraction) OVERRIDE
189 virtual void update(
int ticks) OVERRIDE;
191 virtual void reset() OVERRIDE;
A base class for all AI karts.
Definition: ai_base_controller.hpp:34
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
A base class for AI that use navmesh to work.
Definition: arena_ai.hpp:42
bool m_is_uturn
Indicates that the kart need a uturn to reach a node behind, and m_time_since_uturn is counting down.
Definition: arena_ai.hpp:101
virtual void findTarget()=0
Find a suitable target for this frame, implemented by sub-class.
irr::scene::ISceneNode * m_debug_sphere_next
For debugging purpose: a sphere indicating where the first turning corner is located.
Definition: arena_ai.hpp:67
AbstractKart * m_closest_kart
Pointer to the closest kart around this kart.
Definition: arena_ai.hpp:50
int m_current_forward_node
The ArenaNode at which the forward point located on.
Definition: arena_ai.hpp:134
void configSteering()
This function config the steering (m_steering_angle) of AI.
Definition: arena_ai.cpp:246
void useItems(const float dt)
Determine how AI should use its item, different m_cur_difficulty will have a corresponding strategy.
Definition: arena_ai.cpp:419
bool m_mini_skid
True if AI can skid, currently only do when close to target, see doSkiddingTest().
Definition: arena_ai.hpp:77
Vec3 m_target_point
The coordinates of target point.
Definition: arena_ai.hpp:73
int m_ticks_since_off_road
This is a timer that counts when the kart start going off road.
Definition: arena_ai.hpp:120
virtual bool canSkid(float steer_fraction) OVERRIDE
Return true if AI can skid now.
Definition: arena_ai.hpp:154
int m_closest_kart_node
The ArenaNode at which the closest kart located on.
Definition: arena_ai.hpp:53
void doSkiddingTest()
Determine if AI should skid: When it's close to target, but not straight ahead, in front of it,...
Definition: arena_ai.cpp:635
virtual bool isWaiting() const =0
If true, AI will stop moving.
float m_time_since_uturn
This is a timer that counts down when the kart is doing u-turn.
Definition: arena_ai.hpp:117
virtual void reset() OVERRIDE
Resets the AI when a race is restarted.
Definition: arena_ai.cpp:47
std::set< int > m_on_node
Holds the unique node ai has driven through, useful to tell if AI is stuck by determine the size of t...
Definition: arena_ai.hpp:105
virtual bool ignorePathFinding()
If true, AI will drive directly to target without path finding.
Definition: arena_ai.hpp:171
virtual bool forceBraking()
If true, AI will always try to brake for this frame.
Definition: arena_ai.hpp:161
virtual void resetAfterStop()
Overridden if any action is needed to be done when AI stopped moving or changed driving direction.
Definition: arena_ai.hpp:182
RaceManager::Difficulty m_cur_difficulty
Holds the current difficulty.
Definition: arena_ai.hpp:59
void determinePath(int forward, std::vector< int > *path)
Determine if the path to target needs to be changed to avoid bad items, it will also set the turn rad...
Definition: arena_ai.cpp:657
virtual void newLap(int lap) OVERRIDE
Callback whenever a new lap is triggered.
Definition: arena_ai.hpp:193
virtual float getKartDistance(const AbstractKart *kart) const =0
Return the distance based on graph distance matrix to any kart.
virtual int getCurrentNode() const =0
Return the current ArenaNode the AI located on.
void configSpeed()
Configure a suitable speed depends on current turn radius.
Definition: arena_ai.cpp:341
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,...
Definition: arena_ai.cpp:581
void checkIfStuck(const float dt)
Determine whether AI is stuck, by checking if it stays on the same node for a long period of time (se...
Definition: arena_ai.cpp:305
bool updateAimingPosition(Vec3 *target_point)
Update aiming position, use path finding if necessary.
Definition: arena_ai.cpp:173
float m_time_since_driving
This is a timer that counts down when the kart is starting to drive.
Definition: arena_ai.hpp:114
float m_turn_radius
Used to determine braking and nitro usage.
Definition: arena_ai.hpp:123
Vec3 m_current_forward_point
The point in front of the AI which distance is m_kart_length, used to compensate the time difference ...
Definition: arena_ai.hpp:131
void doUTurn(const float dt)
Make AI reverse so that it faces in front of the last target point.
Definition: arena_ai.cpp:367
ArenaGraph * m_graph
Pointer to the ArenaGraph.
Definition: arena_ai.hpp:47
float m_steering_angle
Used to determine if skidding can be done.
Definition: arena_ai.hpp:126
Vec3 m_closest_kart_point
The closest kart location.
Definition: arena_ai.hpp:56
virtual void findClosestKart(bool consider_difficulty, bool find_sta)=0
Find the closest kart around this AI, implemented by sub-class.
int m_target_node
The ArenaNode at which the target point located on.
Definition: arena_ai.hpp:70
virtual bool isKartOnRoad() const =0
If true, AI stays on the ArenaNode correctly, otherwise RescueAnimation will be done after sometime.
bool gettingUnstuck(int ticks)
Function to let AI get unstuck.
Definition: arena_ai.cpp:393
irr::scene::ISceneNode * m_debug_sphere
For debugging purpose: a sphere indicating where the AI is targeting at.
Definition: arena_ai.hpp:63
virtual void update(int ticks) OVERRIDE
This is the main entry point for the AI.
Definition: arena_ai.cpp:80
Vec3 m_reverse_point
Save the last target point before reversing, so AI will end reversing until facing in front of it.
Definition: arena_ai.hpp:93
Vec3 m_target_point_lc
Local coordinates of current target point.
Definition: arena_ai.hpp:89
bool m_is_stuck
Indicates that the kart is currently stuck, and m_ticks_since_reversing is counting down.
Definition: arena_ai.hpp:97
float m_time_since_last_shot
Time an item has been collected and not used.
Definition: arena_ai.hpp:108
float m_ticks_since_reversing
This is a timer that counts down when the kart is reversing to get unstuck.
Definition: arena_ai.hpp:111
A graph made from navmesh.
Definition: arena_graph.hpp:35
Definition: item_manager.hpp:47
Difficulty
Game difficulty.
Definition: race_manager.hpp:230
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35