19#ifndef HEADER_RUBBER_BALL_HPP
20#define HEADER_RUBBER_BALL_HPP
24#include "items/flyable.hpp"
25#include "tracks/track_sector.hpp"
26#include "utils/cpp2011.hpp"
196 bool m_restoring_state;
209 const float vertical_offset)
const;
211 void removePingSFX();
216 static void init(
const XMLNode &node, scene::IMesh *rubberball);
The base class for all kart animation, like rescue, explosion, or cannon.
Definition: abstract_kart_animation.hpp:60
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: flyable.hpp:50
Definition: physical_object.hpp:40
Definition: rubber_ball.hpp:35
Vec3 m_control_points[4]
Keep the last two, current, and next aiming points for interpolation.
Definition: rubber_ball.hpp:121
static int16_t m_st_delete_ticks
If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball,...
Definition: rubber_ball.hpp:80
bool m_fast_ping
This flag is set if the target is within the fast ping distance.
Definition: rubber_ball.hpp:185
void interpolate(Vec3 *next_xyz, int ticks)
Uses Hermite splines (Catmull-Rom) to interpolate the position of the ball between the control points...
Definition: rubber_ball.cpp:609
float m_current_max_height
The current maximum height of the ball.
Definition: rubber_ball.hpp:170
void moveTowardsTarget(Vec3 *next_xyz, int ticks)
Moves the rubber ball in a straight line towards the target.
Definition: rubber_ball.cpp:513
static float m_st_fast_ping_distance
Distance between ball and target at which the ball will start to bounce faster (which makes more 'pin...
Definition: rubber_ball.hpp:65
float m_previous_height
To simplify code this stores the previous height above terrain used.
Definition: rubber_ball.hpp:130
static float m_st_min_interpolation_distance
Each control point chosen must be at least this far away from the previous one.
Definition: rubber_ball.hpp:75
void getNextControlPoint()
Determines the next control points to aim at.
Definition: rubber_ball.cpp:262
static float m_st_target_distance
If the ball is closer than this distance to the target, it will start to aim directly at the target (...
Definition: rubber_ball.hpp:52
float m_height_timer
This timer is used to determine the height depending on the time.
Definition: rubber_ball.hpp:166
static float m_st_max_height_difference
In somce track, e.g.
Definition: rubber_ball.hpp:59
static float m_st_max_speed_offset
If the ball is farther to its target than max_offset_distance, the speed in addition to the difficult...
Definition: rubber_ball.hpp:88
float m_length_cp_2_3
Estimated length of the spline between the control points 2 and 3.
Definition: rubber_ball.hpp:138
float updateHeight()
Updates the height of the rubber ball, and if necessary also adjusts the maximum height of the ball d...
Definition: rubber_ball.cpp:695
SFXBase * m_ping_sfx
A 'ping' sound effect to be played when the ball hits the ground.
Definition: rubber_ball.hpp:194
static float m_st_target_max_angle
The maximum angle the ball can change per second when being close to the taregt.
Definition: rubber_ball.hpp:70
static float m_st_max_offset_distance
The distance to target over which the ball is the fastest.
Definition: rubber_ball.hpp:94
float getTunnelHeight(const Vec3 &next_xyz, const float vertical_offset) const
When the ball is in a tunnel, this will return the tunnel height.
Definition: rubber_ball.cpp:757
float m_t
The parameter for the spline, m_t in [0,1].
Definition: rubber_ball.hpp:148
float m_distance_to_target
Distance to target.
Definition: rubber_ball.hpp:162
static float m_st_min_speed_offset
If the ball is closer to its target than min_offset_distance, the speed in addition to the difficulty...
Definition: rubber_ball.hpp:84
static float m_st_squash_duration
A class variable to store the default squash duration.
Definition: rubber_ball.hpp:45
bool checkTunneling()
Checks if the line from the previous ball position to the new position hits something,...
Definition: rubber_ball.cpp:651
virtual bool updateAndDelete(int ticks) OVERRIDE
Updates the rubber ball.
Definition: rubber_ball.cpp:374
static float m_st_early_target_factor
This factor is used to influence how much the rubber ball should aim at its target early.
Definition: rubber_ball.hpp:110
void updateDistanceToTarget()
Determines the distance to the target kart.
Definition: rubber_ball.cpp:775
virtual void onFireFlyable() OVERRIDE
Call when the item is (re-)fired (during rewind if needed) by projectile_manager.
Definition: rubber_ball.cpp:80
static void init(const XMLNode &node, scene::IMesh *rubberball)
Initialises this object with data from the power.xml file (this is a static function).
Definition: rubber_ball.cpp:292
float m_interval
How long it takes from one bounce of the ball to the next.
Definition: rubber_ball.hpp:156
float m_t_increase
How much m_t must increase per second in order to maintain a constant speed, i.e.
Definition: rubber_ball.hpp:153
uint8_t m_tunnel_count
This variable counts how often a ball tunneled (in consecutive frames).
Definition: rubber_ball.hpp:181
virtual ~RubberBall()
Destructor, removes any playing sfx.
Definition: rubber_ball.cpp:137
void updateWeightedSpeed(int ticks)
Calculates the current speed of the basket ball.
Definition: rubber_ball.cpp:552
float m_length_cp_1_2
Estimated length of the spline between the control points 1 and 2.
Definition: rubber_ball.hpp:134
int m_last_aimed_graph_node
The last graph node who's coordinates are stored in m_control_points[3].
Definition: rubber_ball.hpp:117
static float m_st_squash_slowdown
A class variable to store the default squash slowdown.
Definition: rubber_ball.hpp:48
unsigned int getSuccessorToHitTarget(unsigned int node_index, float *f=NULL)
Determines the successor of a graph node.
Definition: rubber_ball.cpp:238
virtual BareNetworkString * saveState(std::vector< std::string > *ru) OVERRIDE
This object does not create an explosion, all affects on karts are handled by this hit() function.
Definition: rubber_ball.cpp:887
virtual void restoreState(BareNetworkString *buffer, int count) OVERRIDE
Called when a state needs to be replayed.
Definition: rubber_ball.cpp:914
void computeTarget()
Determines the first kart that is still in the race.
Definition: rubber_ball.cpp:186
Vec3 m_previous_xyz
Saves the previous location of the ball.
Definition: rubber_ball.hpp:126
int m_id
Used in case of flyable debugging so that each output line gets a unique number for each ball.
Definition: rubber_ball.hpp:39
int16_t m_delete_ticks
If the ball overtakes its target or starts to aim at the kart which originally shot the rubber ball,...
Definition: rubber_ball.hpp:176
const AbstractKart * m_target
A pointer to the target kart.
Definition: rubber_ball.hpp:113
void initializeControlPoints(const Vec3 &xyz)
Sets up the control points for the interpolation.
Definition: rubber_ball.cpp:152
virtual bool hit(AbstractKart *kart, PhysicalObject *obj=NULL) OVERRIDE
Callback from the physics in case that a kart or object is hit.
Definition: rubber_ball.cpp:852
bool m_aiming_at_target
Once the ball is close enough, it will aim for the kart.
Definition: rubber_ball.hpp:191
static float m_st_interval
A class variable to store the default interval size.
Definition: rubber_ball.hpp:42
static float m_st_min_offset_distance
The distance to target under which the ball is the slowest.
Definition: rubber_ball.hpp:91
The base class for sound effects.
Definition: sfx_base.hpp:43
This object keeps track of which sector an object is on.
Definition: track_sector.hpp:39
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48