[7373] Implement expansion check at character loading (for homebind, transport and plain coordinates). Author: VladimirMangos
Also move fall damage calucaltion in new function. --HG-- branch : trunk
This commit is contained in:
@@ -233,7 +233,7 @@ void WorldSession::HandleMovementOpcodes( WorldPacket & recv_data )
|
||||
|
||||
// fall damage generation (ignore in flight case that can be triggered also at lags in moment teleportation to another map).
|
||||
if (opcode == MSG_MOVE_FALL_LAND && !GetPlayer()->isInFlight())
|
||||
GetPlayer()->HandleFallDamage(movementInfo);
|
||||
GetPlayer()->HandleFall(movementInfo);
|
||||
|
||||
if(((movementInfo.flags & MOVEMENTFLAG_SWIMMING) != 0) != GetPlayer()->IsInWater())
|
||||
{
|
||||
|
||||
+71
-49
@@ -1645,6 +1645,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
else
|
||||
// this will be used instead of the current location in SaveToDB
|
||||
m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
|
||||
|
||||
SetFallInformation(0, z);
|
||||
|
||||
//BuildHeartBeatMsg(&data);
|
||||
@@ -14696,6 +14697,14 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
{
|
||||
if( (*iter)->GetGUIDLow() == transGUID)
|
||||
{
|
||||
MapEntry const* transMapEntry = sMapStore.LookupEntry((*iter)->GetMapId());
|
||||
// client without expansion support
|
||||
if(GetSession()->Expansion() < transMapEntry->Expansion())
|
||||
{
|
||||
sLog.outDebug("Player %s using client without required expansion tried login at transport at non accessible map %u", GetName(), (*iter)->GetMapId());
|
||||
break;
|
||||
}
|
||||
|
||||
m_transport = *iter;
|
||||
m_transport->AddPassenger(this);
|
||||
SetMapId(m_transport->GetMapId());
|
||||
@@ -14705,7 +14714,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
|
||||
if(!m_transport)
|
||||
{
|
||||
sLog.outError("ERROR: Player (guidlow %d) have invalid transport guid (%u). Teleport to default race/class locations.",
|
||||
sLog.outError("ERROR: Player (guidlow %d) have problems with transport guid (%u). Teleport to default race/class locations.",
|
||||
guid,transGUID);
|
||||
|
||||
RelocateToHomebind();
|
||||
@@ -14718,6 +14727,16 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
|
||||
transGUID = 0;
|
||||
}
|
||||
}
|
||||
else // not transport case
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(GetMapId());
|
||||
// client without expansion support
|
||||
if(GetSession()->Expansion() < mapEntry->Expansion())
|
||||
{
|
||||
sLog.outDebug("Player %s using client without required expansion tried login at non accessible map %u", GetName(), GetMapId());
|
||||
RelocateToHomebind();
|
||||
}
|
||||
}
|
||||
|
||||
// NOW player must have valid map
|
||||
// load the player's map here if it's not already loaded
|
||||
@@ -15986,9 +16005,11 @@ bool Player::_LoadHomeBind(QueryResult *result)
|
||||
m_homebindZ = fields[4].GetFloat();
|
||||
delete result;
|
||||
|
||||
// accept saved data only for valid position (and non instanceable)
|
||||
MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId);
|
||||
|
||||
// accept saved data only for valid position (and non instanceable), and accessable
|
||||
if( MapManager::IsValidMapCoord(m_homebindMapId,m_homebindX,m_homebindY,m_homebindZ) &&
|
||||
!sMapStore.LookupEntry(m_homebindMapId)->Instanceable() )
|
||||
!bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion())
|
||||
{
|
||||
ok = true;
|
||||
}
|
||||
@@ -19930,52 +19951,6 @@ bool ItemPosCount::isContainedIn(ItemPosCountVec const& vec) const
|
||||
//-------------TRINITY---------------
|
||||
//***********************************
|
||||
|
||||
void Player::HandleFallDamage(MovementInfo& movementInfo)
|
||||
{
|
||||
//if(movementInfo.fallTime < 1500)
|
||||
// return;
|
||||
|
||||
// calculate total z distance of the fall
|
||||
float z_diff = m_lastFallZ - movementInfo.z;
|
||||
sLog.outDebug("zDiff = %f", z_diff);
|
||||
|
||||
//Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
|
||||
// 14.57 can be calculated by resolving damageperc formular below to 0
|
||||
if (z_diff >= 14.57f && !isDead() && !isGameMaster() &&
|
||||
!HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) &&
|
||||
!HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL) )
|
||||
{
|
||||
//Safe fall, fall height reduction
|
||||
int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL);
|
||||
|
||||
float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f;
|
||||
|
||||
if(damageperc >0 )
|
||||
{
|
||||
uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL));
|
||||
|
||||
float height = movementInfo.z;
|
||||
UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height);
|
||||
|
||||
if (damage > 0)
|
||||
{
|
||||
//Prevent fall damage from being more than the player maximum health
|
||||
if (damage > GetMaxHealth())
|
||||
damage = GetMaxHealth();
|
||||
|
||||
// Gust of Wind
|
||||
if (GetDummyAura(43621))
|
||||
damage = GetMaxHealth()/2;
|
||||
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_FALL, damage);
|
||||
}
|
||||
|
||||
//Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction
|
||||
DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.z, height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::HandleFallUnderMap()
|
||||
{
|
||||
if(InBattleGround()
|
||||
@@ -20534,3 +20509,50 @@ uint8 Player::CanEquipUniqueItem( ItemPrototype const* itemProto, uint8 except_s
|
||||
|
||||
return EQUIP_ERR_OK;
|
||||
}
|
||||
|
||||
void Player::HandleFall(MovementInfo const& movementInfo)
|
||||
{
|
||||
// calculate total z distance of the fall
|
||||
float z_diff = m_lastFallZ - movementInfo.z;
|
||||
sLog.outDebug("zDiff = %f", z_diff);
|
||||
|
||||
//Players with low fall distance, Feather Fall or physical immunity (charges used) are ignored
|
||||
// 14.57 can be calculated by resolving damageperc formular below to 0
|
||||
if (z_diff >= 14.57f && !isDead() && !isGameMaster() &&
|
||||
!HasAuraType(SPELL_AURA_HOVER) && !HasAuraType(SPELL_AURA_FEATHER_FALL) &&
|
||||
!HasAuraType(SPELL_AURA_FLY) && !IsImmunedToDamage(SPELL_SCHOOL_MASK_NORMAL) )
|
||||
{
|
||||
//Safe fall, fall height reduction
|
||||
int32 safe_fall = GetTotalAuraModifier(SPELL_AURA_SAFE_FALL);
|
||||
|
||||
float damageperc = 0.018f*(z_diff-safe_fall)-0.2426f;
|
||||
|
||||
if(damageperc >0 )
|
||||
{
|
||||
uint32 damage = (uint32)(damageperc * GetMaxHealth()*sWorld.getRate(RATE_DAMAGE_FALL));
|
||||
|
||||
float height = movementInfo.z;
|
||||
UpdateGroundPositionZ(movementInfo.x,movementInfo.y,height);
|
||||
|
||||
if (damage > 0)
|
||||
{
|
||||
//Prevent fall damage from being more than the player maximum health
|
||||
if (damage > GetMaxHealth())
|
||||
damage = GetMaxHealth();
|
||||
|
||||
// Gust of Wind
|
||||
if (GetDummyAura(43621))
|
||||
damage = GetMaxHealth()/2;
|
||||
|
||||
EnvironmentalDamage(GetGUID(), DAMAGE_FALL, damage);
|
||||
|
||||
// recheck alive, might have died of EnvironmentalDamage
|
||||
if (isAlive())
|
||||
GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_FALL_WITHOUT_DYING, uint32(z_diff*100));
|
||||
}
|
||||
|
||||
//Z given by moveinfo, LastZ, FallTime, WaterZ, MapZ, Damage, Safefall reduction
|
||||
DEBUG_LOG("FALLDAMAGE z=%f sz=%f pZ=%f FallTime=%d mZ=%f damage=%d SF=%d" , movementInfo.z, height, GetPositionZ(), movementInfo.fallTime, height, damage, safe_fall);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -2016,6 +2016,8 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
m_lastFallTime = time;
|
||||
m_lastFallZ = z;
|
||||
}
|
||||
void HandleFall(MovementInfo const& movementInfo);
|
||||
|
||||
bool isMoving() const { return HasUnitMovementFlag(movementFlagsMask); }
|
||||
bool isMovingOrTurning() const { return HasUnitMovementFlag(movementOrTurningFlagsMask); }
|
||||
|
||||
@@ -2024,7 +2026,6 @@ class TRINITY_DLL_SPEC Player : public Unit
|
||||
bool IsAllowUseFlyMountsHere() const;
|
||||
|
||||
void HandleDrowning();
|
||||
void HandleFallDamage(MovementInfo& movementInfo);
|
||||
void HandleFallUnderMap();
|
||||
|
||||
void SetClientControl(Unit* target, uint8 allowMove);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7372"
|
||||
#define REVISION_NR "7373"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
||||
Reference in New Issue
Block a user