SuperTuxKart
Loading...
Searching...
No Matches
end_controller.hpp
1//
2// SuperTuxKart - a fun racing game with go-kart
3// Copyright (C) 2004-2015 Steve Baker <sjbaker1@airmail.net>
4// Copyright (C) 2006-2015 Eduardo Hernandez Munoz
5// Copyright (C) 2010-2015 Joerg Henrichs
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 3
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21#ifndef HEADER_END_CONTROLLER_HPP
22#define HEADER_END_CONTROLLER_HPP
23
24#include "karts/controller/ai_base_lap_controller.hpp"
25
26class Camera;
27class LinearWorld;
28class Track;
29class Vec3;
30
31namespace irr
32{
33 namespace scene
34 {
35 class ISceneNode;
36 }
37}
38
43{
44private:
49
50 int m_min_steps; //Minimum number of steps to check. If 0, the AI doesn't
51 //even has check around the kart, if 1, it checks around
52 //the kart always, and more than that will check the
53 //remaining number of steps in front of the kart, always
54 float m_max_handicap_accel; //The allowed maximum speed, in percentage,
55 //from 0.0 to 1.0. Used only when
56 //m_wait_for_players == true.
57
58 /*General purpose variables*/
59 //The crash percentage is how much of the time the AI has been crashing,
60 //if the AI has been crashing for some time, use the rescue.
61 float m_crash_time;
62
63 float m_time_since_stuck;
64
67
70 irr::scene::ISceneNode *m_debug_sphere;
71
72 /*Functions called directly from update(). They all represent an action
73 *that can be done, and end up setting their respective m_controls
74 *variable.
75 */
76 void handleSteering(float dt);
77 void handleRescue(const float DELTA);
78
79 void checkCrashes(const int STEPS, const Vec3& pos);
80 void findNonCrashingPoint(Vec3 *result);
81 int calcSteps();
82 virtual bool canSkid(float steer_fraction) { return false; }
83public:
85 Controller *prev_controller);
87 virtual void update (int ticks) ;
88 virtual void reset ();
89 virtual bool action (PlayerAction action, int value,
90 bool dry_run = false);
91 virtual void newLap (int lap);
92 // ------------------------------------------------------------------------
93 virtual bool canGetAchievements() const
94 {
96 } // canGetAchievements
97 // ------------------------------------------------------------------------
101 virtual bool isPlayerController () const
102 {
104 } // isPlayerController
105 // ------------------------------------------------------------------------
109 virtual bool isLocalPlayerController () const
110 {
112 } // isLocalPlayerController
113 // ------------------------------------------------------------------------
116 core::stringw getName(bool include_handicap_string = true) const
117 { return m_previous_controller->getName(include_handicap_string); }
118
119}; // EndKart
120
121#endif
122
123/* EOF */
A base class for all AI karts.
Definition: ai_base_lap_controller.hpp:33
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
This is the base class for all cameras.
Definition: camera.hpp:49
This is the base class for kart controller - that can be a player or a a robot.
Definition: controller.hpp:46
virtual bool isLocalPlayerController() const =0
This function checks if this is a local player.
virtual core::stringw getName(bool include_handicap_string=true) const
Display name of the controller.
Definition: controller.cpp:39
virtual bool isPlayerController() const =0
This function checks if this player is not an AI, i.e.
virtual bool canGetAchievements() const
Only local players can get achievements.
Definition: controller.hpp:109
Definition: end_controller.hpp:43
virtual void newLap(int lap)
Callback when a new lap is triggered.
Definition: end_controller.cpp:154
virtual bool canSkid(float steer_fraction)
Return true if AI can skid now.
Definition: end_controller.hpp:82
core::stringw getName(bool include_handicap_string=true) const
Returns the name of the previous controller (which has the right player name associated).
Definition: end_controller.hpp:116
~EndController()
The destructor deletes the shared TrackInfo objects if no more EndController instances are around.
Definition: end_controller.cpp:116
int calcSteps()
calc_steps() divides the velocity vector by the lenght of the kart, and gets the number of steps to u...
Definition: end_controller.cpp:321
virtual void update(int ticks)
Updates the ai base controller each time step.
Definition: end_controller.cpp:176
Controller * m_previous_controller
Stores a pointer to the original controller.
Definition: end_controller.hpp:66
virtual bool isPlayerController() const
Returns if the original controller of the kart was a player controller.
Definition: end_controller.hpp:101
bool m_was_player_controller
Stores the type of the previous controller.
Definition: end_controller.hpp:48
void findNonCrashingPoint(Vec3 *result)
Find the sector that at the longest distance from the kart, that can be driven to without crashing wi...
Definition: end_controller.cpp:265
irr::scene::ISceneNode * m_debug_sphere
For debugging purpose: a sphere indicating where the AI is targeting at.
Definition: end_controller.hpp:70
virtual bool canGetAchievements() const
Only local players can get achievements.
Definition: end_controller.hpp:93
virtual bool action(PlayerAction action, int value, bool dry_run=false)
The end controller must forward 'fire' presses to the race gui.
Definition: end_controller.cpp:165
virtual bool isLocalPlayerController() const
Returns if the original controller of the kart was a local player controller.
Definition: end_controller.hpp:109
Definition: linear_world.hpp:36
Definition: track.hpp:114
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
PlayerAction
types of input events / what actions the players can do
Definition: input.hpp:117