Core/Movement: Implement spline movement subsystem.

Spline movement controls movements of server-side controlled units (monster movement, taxi movement, etc).
Proper implementation of effects such as charge, jump, cyclic movement will rely on it.
However, need improve our states system before.

Technical changes:

* Added linear, catmullrom and bezier3 splines which based on client's algorthims. They can be reused for proper transport position interpolation.
* Precission increased. There are no more position desync issues since client's position calculation formulas used.
* Now possible to move by paths with multiple points, send whole path to client.

--
Original author of research and implementation: SilverIce. Massive kudos.
Original port for Trinity (ref #4629) Chaplain and Venugh
With the following incremental fixes during my review:

- Restore flightmaster end grid pre-loading
- Fix uninitialized Creature::m_path_id
- Add missing trinity_string entries for .movegens command
- Fix a bug in WaypointMovementGenerator that would trigger unexpected pausing at waypoints for various amounts of time

Known issues:
- Errors like WaypointMovementGenerator::LoadPath creature XXX (Entry: YYYYY GUID: ZZZZZZ) doesn't have waypoint path id: 0.
This is caused by bad DB data. This commit didn't "break" it.

Do not forget to re-run CMake before compiling.
This commit is contained in:
Machiavelli
2012-01-14 15:36:07 +01:00
parent 798677ca54
commit dbbac0bdaa
84 changed files with 3356 additions and 1943 deletions
+2 -36
View File
@@ -2101,6 +2101,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// reset movement flags at teleport, because player will continue move with these flags after teleport
SetUnitMovementFlags(0);
DisableSpline();
if (m_transport)
{
@@ -5148,43 +5149,10 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness)
}
}
/**
* FallMode = 0 implies that the player is dying, or already dead, and the proper death state will be set.
* = 1 simply causes the player to plummet towards the ground, and not suffer any damage.
* = 2 causes the player to plummet towards the ground, and causes falling damage, regardless
* of any auras that might of prevented fall damage.
*/
bool Player::FallGround(uint8 FallMode)
{
// Let's abort after we called this function one time
if (getDeathState() == DEAD_FALLING && FallMode == 0)
return false;
float x, y, z;
GetPosition(x, y, z);
float ground_Z = GetMap()->GetHeight(x, y, z);
float z_diff = 0.0f;
if ((z_diff = fabs(ground_Z - z)) < 0.1f)
return false;
GetMotionMaster()->MoveFall(ground_Z, EVENT_FALL_GROUND);
// Below formula for falling damage is from Player::HandleFall
if (FallMode == 2 && z_diff >= 14.57f)
{
uint32 damage = std::min(GetMaxHealth(), (uint32)((0.018f * z_diff - 0.2426f) * GetMaxHealth() * sWorld->getRate(RATE_DAMAGE_FALL)));
if (damage)
EnvironmentalDamage(DAMAGE_FALL, damage);
}
else if (FallMode == 0)
Unit::setDeathState(DEAD_FALLING);
return true;
}
void Player::KillPlayer()
{
if (IsFlying() && !GetTransport())
FallGround();
i_motionMaster.MoveFall();
SetMovement(MOVE_ROOT);
@@ -21474,8 +21442,6 @@ void Player::SendInitialVisiblePackets(Unit* target)
SendAurasForTarget(target);
if (target->isAlive())
{
if (target->GetMotionMaster()->GetCurrentMovementGeneratorType() != IDLE_MOTION_TYPE)
target->SendMonsterMoveWithSpeedToCurrentDestination(this);
if (target->HasUnitState(UNIT_STAT_MELEE_ATTACKING) && target->getVictim())
target->SendMeleeAttackStart(target->getVictim());
}