Added separate fast-ping distance, so that the rubber ball
can start boucing lower/faster earlier, increasing the chances to hit the target when target-distance is set to a small value. Target-distance was set to 25 to decrease the chances of the ball going through e.g. tunnel walls. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10004 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
fbbb67d832
commit
aa74b59dcb
@ -49,7 +49,7 @@
|
||||
scale="1 1 1" interval="1"
|
||||
max-height="4.0" min-height="0"
|
||||
fast-ping-distance="50"
|
||||
target-distance="50" target-max-angle = "90"
|
||||
target-distance="25" target-max-angle = "90"
|
||||
min-interpolation-distance="10"
|
||||
squash-slowdown="0.5" squash-duration="3"
|
||||
delete-time="5.0" max-height-difference="10" />
|
||||
|
@ -36,7 +36,7 @@ float RubberBall::m_st_target_distance;
|
||||
float RubberBall::m_st_target_max_angle;
|
||||
float RubberBall::m_st_delete_time;
|
||||
float RubberBall::m_st_max_height_difference;
|
||||
float RubberBall::m_fast_ping_distance;
|
||||
float RubberBall::m_st_fast_ping_distance;
|
||||
int RubberBall::m_next_id = 0;
|
||||
|
||||
RubberBall::RubberBall(Kart *kart)
|
||||
@ -81,6 +81,7 @@ RubberBall::RubberBall(Kart *kart)
|
||||
// At the start the ball aims at quads till it gets close enough to the
|
||||
// target:
|
||||
m_aiming_at_target = false;
|
||||
m_fast_ping = false;
|
||||
m_height_timer = 0.0f;
|
||||
m_interval = m_st_interval;
|
||||
m_current_max_height = m_max_height;
|
||||
@ -228,7 +229,7 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *bowling)
|
||||
m_st_target_max_angle = 25.0f;
|
||||
m_st_delete_time = 10.0f;
|
||||
m_st_max_height_difference = 10.0f;
|
||||
m_fast_ping_distance = 50.0f;
|
||||
m_st_fast_ping_distance = 50.0f;
|
||||
|
||||
if(!node.get("interval", &m_st_interval))
|
||||
printf("[powerup] Warning: no interval specified for rubber ball.\n");
|
||||
@ -257,11 +258,13 @@ void RubberBall::init(const XMLNode &node, scene::IMesh *bowling)
|
||||
printf(
|
||||
"[powerup] Warning: no max-height-difference specified for "
|
||||
"rubber ball.\n");
|
||||
if(!node.get("fast-ping-distance", &m_fast_ping_distance))
|
||||
if(!node.get("fast-ping-distance", &m_st_fast_ping_distance))
|
||||
printf(
|
||||
"[powerup] Warning: no fast-ping-distancespecified for "
|
||||
"rubber ball.\n");
|
||||
|
||||
if(m_st_fast_ping_distance < m_st_target_distance)
|
||||
printf("Warning: ping-distance is smaller than target distance.\n"
|
||||
"hat should not happen, but is ignored for now.\n");
|
||||
Flyable::init(node, bowling, PowerupManager::POWERUP_RUBBERBALL);
|
||||
} // init
|
||||
|
||||
@ -476,7 +479,7 @@ float RubberBall::updateHeight()
|
||||
|
||||
if(distance<0)
|
||||
distance+=World::getWorld()->getTrack()->getTrackLength();;
|
||||
if(distance<m_st_target_distance)
|
||||
if(m_fast_ping)
|
||||
{
|
||||
// Some experimental formulas
|
||||
m_current_max_height = 0.5f*sqrt(distance);
|
||||
@ -546,20 +549,26 @@ void RubberBall::checkDistanceToTarget()
|
||||
world->getDistanceDownTrackForKart(m_target->getWorldKartId());
|
||||
float ball_distance = getDistanceFromStart();
|
||||
|
||||
float diff = target_distance - ball_distance;
|
||||
if(diff < 0)
|
||||
m_distance_to_target = target_distance - ball_distance;
|
||||
if(m_distance_to_target < 0)
|
||||
{
|
||||
diff += world->getTrack()->getTrackLength();
|
||||
m_distance_to_target += world->getTrack()->getTrackLength();
|
||||
}
|
||||
if(UserConfigParams::logFlyable())
|
||||
printf("ball %d: target %f %f %f diff %f \n",
|
||||
printf("ball %d: target %f %f %f distance_2_target %f \n",
|
||||
m_id, m_target->getXYZ().getX(),m_target->getXYZ().getY(),
|
||||
m_target->getXYZ().getZ(),diff
|
||||
m_target->getXYZ().getZ(),m_distance_to_target
|
||||
);
|
||||
|
||||
if(diff < m_st_target_distance &&
|
||||
fabsf(m_target->getXYZ().getY() - getXYZ().getY()) <
|
||||
m_st_max_height_difference )
|
||||
float height_diff = fabsf(m_target->getXYZ().getY() - getXYZ().getY());
|
||||
|
||||
if(m_distance_to_target < m_st_fast_ping_distance &&
|
||||
height_diff < m_st_max_height_difference)
|
||||
{
|
||||
m_fast_ping = true;
|
||||
}
|
||||
if(m_distance_to_target < m_st_target_distance &&
|
||||
height_diff < m_st_max_height_difference)
|
||||
{
|
||||
m_aiming_at_target = true;
|
||||
return;
|
||||
@ -572,7 +581,7 @@ void RubberBall::checkDistanceToTarget()
|
||||
// new target. If the new distance is nearly the full track
|
||||
// length, assume that the rubber ball has overtaken the
|
||||
// original target, and start deleting it.
|
||||
if(diff > 0.9f * world->getTrack()->getTrackLength())
|
||||
if(m_distance_to_target > 0.9f * world->getTrack()->getTrackLength())
|
||||
{
|
||||
m_delete_timer = m_st_delete_time;
|
||||
}
|
||||
@ -587,8 +596,6 @@ void RubberBall::checkDistanceToTarget()
|
||||
// directly at the target back to interpolating again.
|
||||
initializeControlPoints(m_previous_xyz);
|
||||
m_aiming_at_target = false;
|
||||
|
||||
printf("Target lost, diff %f time %f\n", diff, m_delete_timer);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -66,7 +66,7 @@ private:
|
||||
* bounce faster (which makes more 'ping' sfx for the driver to
|
||||
* hear it coming closer, but also higher probability to hit the
|
||||
* target and not fly over it). */
|
||||
static float m_fast_ping_distance;
|
||||
static float m_st_fast_ping_distance;
|
||||
|
||||
/** The maximum angle the ball can change per second when being close
|
||||
* to the taregt. If the target angle is small, it makes it much harder
|
||||
@ -125,6 +125,16 @@ private:
|
||||
/** How long it takes from one bounce of the ball to the next. */
|
||||
float m_interval;
|
||||
|
||||
/** This flag is set if the target is within the fast ping distance. It
|
||||
* will cause the rubber ball to decrese the jump height and intervall. */
|
||||
bool m_fast_ping;
|
||||
|
||||
/** Distance to target. This is measured in terms of 'distance along
|
||||
* track', but also takes the 3d distance and height difference into
|
||||
* account (in case that the target is on a different part of the
|
||||
* track) */
|
||||
float m_distance_to_target;
|
||||
|
||||
/** This timer is used to determine the height depending on the time.
|
||||
* It is always between 0 and m_interval. */
|
||||
float m_height_timer;
|
||||
|
Loading…
x
Reference in New Issue
Block a user