aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities
diff options
context:
space:
mode:
authorNay <dnpd.dd@gmail.com>2012-09-06 18:01:51 +0100
committerNay <dnpd.dd@gmail.com>2012-09-06 18:01:51 +0100
commit0522e50c8670a34698b15003ceb5e514db72e427 (patch)
treed6406bcbd2e836f5f08be8e67f1a01de4c938d48 /src/server/game/Entities
parent42a899a90eabae2ce6fc8ca103e7692c07153315 (diff)
parent9f09713b3e286ba94948c15d64b76b2aed16f8cd (diff)
Merge remote-tracking branch 'origin/master' into mmaps
Conflicts: src/server/game/Spells/Spell.cpp
Diffstat (limited to 'src/server/game/Entities')
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp31
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp73
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h3
3 files changed, 58 insertions, 49 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 751107ac011..808cbd9a5e4 100755
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -133,13 +133,13 @@ void GameObject::AddToWorld()
m_zoneScript->OnGameObjectCreate(this);
sObjectAccessor->AddObject(this);
- bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
+
// The state can be changed after GameObject::Create but before GameObject::AddToWorld
- bool toggledState = GetGOData() ? GetGOData()->go_state != GO_STATE_READY : false;
+ bool toggledState = GetGoType() == GAMEOBJECT_TYPE_CHEST ? getLootState() == GO_READY : GetGoState() == GO_STATE_READY;
if (m_model)
GetMap()->InsertGameObjectModel(*m_model);
- EnableCollision(startOpen ^ toggledState);
+ EnableCollision(toggledState);
WorldObject::AddToWorld();
}
}
@@ -1926,17 +1926,12 @@ void GameObject::SetLootState(LootState state, Unit* unit)
sScriptMgr->OnGameObjectLootStateChanged(this, state, unit);
if (m_model)
{
- // startOpen determines whether we are going to add or remove the LoS on activation
- bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
-
+ bool collision = false;
// Use the current go state
- if (GetGoState() != GO_STATE_READY)
- startOpen = !startOpen;
+ if ((GetGoState() != GO_STATE_READY && (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)) || state == GO_READY)
+ collision = !collision;
- if (state == GO_ACTIVATED || state == GO_JUST_DEACTIVATED)
- EnableCollision(startOpen);
- else if (state == GO_READY)
- EnableCollision(!startOpen);
+ EnableCollision(collision);
}
}
@@ -1950,12 +1945,11 @@ void GameObject::SetGoState(GOState state)
return;
// startOpen determines whether we are going to add or remove the LoS on activation
- bool startOpen = (GetGoType() == GAMEOBJECT_TYPE_DOOR || GetGoType() == GAMEOBJECT_TYPE_BUTTON ? GetGOInfo()->door.startOpen : false);
-
- if (state != GO_STATE_READY)
- startOpen = !startOpen;
+ bool collision = false;
+ if (state == GO_STATE_READY)
+ collision = !collision;
- EnableCollision(startOpen);
+ EnableCollision(collision);
}
}
@@ -1968,7 +1962,8 @@ void GameObject::SetDisplayId(uint32 displayid)
void GameObject::SetPhaseMask(uint32 newPhaseMask, bool update)
{
WorldObject::SetPhaseMask(newPhaseMask, update);
- EnableCollision(true);
+ if (m_model && m_model->isEnabled())
+ EnableCollision(true);
}
void GameObject::EnableCollision(bool enable)
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 4c279cad9f4..a4c130193be 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -256,6 +256,7 @@ m_HostileRefManager(this), m_TempSpeed(0.0f), m_AutoRepeatFirstCast(false)
_focusSpell = NULL;
_targetLocked = false;
_lastLiquid = NULL;
+ _isWalkingBeforeCharm = false;
}
////////////////////////////////////////////////////////////
@@ -380,9 +381,7 @@ void Unit::MonsterMoveWithSpeed(float x, float y, float z, float speed, bool gen
void Unit::UpdateSplineMovement(uint32 t_diff)
{
- enum{
- POSITION_UPDATE_DELAY = 400,
- };
+ uint32 const positionUpdateDelay = 400;
if (movespline->Finalized())
return;
@@ -396,7 +395,7 @@ void Unit::UpdateSplineMovement(uint32 t_diff)
m_movesplineTimer.Update(t_diff);
if (m_movesplineTimer.Passed() || arrived)
{
- m_movesplineTimer.Reset(POSITION_UPDATE_DELAY);
+ m_movesplineTimer.Reset(positionUpdateDelay);
Movement::Location loc = movespline->ComputePosition();
if (HasUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
@@ -542,12 +541,11 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
GetAI()->DamageDealt(victim, damage, damagetype);
if (victim->GetTypeId() == TYPEID_PLAYER)
+ {
if (victim->ToPlayer()->GetCommandStatus(CHEAT_GOD))
return 0;
- // Signal to pets that their owner was attacked
- if (victim->GetTypeId() == TYPEID_PLAYER)
- {
+ // Signal to pets that their owner was attacked
Pet* pet = victim->ToPlayer()->GetPet();
if (pet && pet->isAlive())
@@ -6727,10 +6725,13 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Judgement of Light
case 20185:
{
- // 2% of base mana
- basepoints0 = int32(victim->CountPctFromMaxHealth(2));
- victim->CastCustomSpell(victim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura);
- return true;
+ if (!victim)
+ return false;
+
+ // 2% of base mana
+ basepoints0 = int32(victim->CountPctFromMaxHealth(2));
+ victim->CastCustomSpell(victim, 20267, &basepoints0, 0, 0, true, 0, triggeredByAura);
+ return true;
}
// Judgement of Wisdom
case 20186:
@@ -9978,7 +9979,8 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (!charm->AddUInt64Value(UNIT_FIELD_CHARMEDBY, GetGUID()))
sLog->outFatal(LOG_FILTER_UNITS, "Unit %u is being charmed, but it already has a charmer " UI64FMTD "", charm->GetEntry(), charm->GetCharmerGUID());
- if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
+ _isWalkingBeforeCharm = charm->IsWalking();
+ if (_isWalkingBeforeCharm)
{
charm->SetWalk(false);
charm->SendMovementFlagUpdate();
@@ -10016,6 +10018,12 @@ void Unit::SetCharm(Unit* charm, bool apply)
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
}
+ if (charm->IsWalking() != _isWalkingBeforeCharm)
+ {
+ charm->SetWalk(_isWalkingBeforeCharm);
+ charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player.
+ }
+
if (charm->GetTypeId() == TYPEID_PLAYER
|| !charm->ToCreature()->HasUnitTypeMask(UNIT_MASK_MINION)
|| charm->GetOwnerGUID() != GetGUID())
@@ -10290,6 +10298,10 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
if (!spellProto || !victim || damagetype == DIRECT_DAMAGE)
return pdamage;
+ // Some spells don't benefit from done mods
+ if (spellProto->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS)
+ return pdamage;
+
// small exception for Deep Wounds, can't find any general rule
// should ignore ALL damage mods, they already calculated in trigger spell
if (spellProto->Id == 12721) // Deep Wounds
@@ -10691,13 +10703,6 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
DoneTotal += int32(DoneAdvertisedBenefit * coeff * factorMod);
}
- // Some spells don't benefit from done mods
- if (spellProto->AttributesEx3 & SPELL_ATTR3_NO_DONE_BONUS)
- {
- DoneTotal = 0;
- DoneTotalMod = 1.0f;
- }
-
float tmpDamage = (int32(pdamage) + DoneTotal) * DoneTotalMod;
// apply spellmod to Done damage (flat and pct)
if (Player* modOwner = GetSpellModOwner())
@@ -11081,9 +11086,12 @@ uint32 Unit::SpellCriticalDamageBonus(SpellInfo const* spellProto, uint32 damage
crit_bonus -= damage;
- // adds additional damage to crit_bonus (from talents)
- if (Player* modOwner = GetSpellModOwner())
- modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
+ if (damage > uint32(crit_bonus))
+ {
+ // adds additional damage to critBonus (from talents)
+ if (Player* modOwner = GetSpellModOwner())
+ modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
+ }
crit_bonus += damage;
@@ -14763,11 +14771,11 @@ void Unit::StopMoving()
init.Launch();
}
-void Unit::SendMovementFlagUpdate()
+void Unit::SendMovementFlagUpdate(bool self /* = false */)
{
WorldPacket data;
BuildHeartBeatMsg(&data);
- SendMessageToSet(&data, false);
+ SendMessageToSet(&data, self);
}
bool Unit::IsSitState() const
@@ -16144,7 +16152,8 @@ void Unit::RemoveCharmedBy(Unit* charmer)
if (Creature* creature = ToCreature())
{
- creature->AI()->OnCharmed(false);
+ if (creature->AI())
+ creature->AI()->OnCharmed(false);
if (type != CHARM_TYPE_VEHICLE) // Vehicles' AI is never modified
{
@@ -17044,6 +17053,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
sLog->outDebug(LOG_FILTER_VEHICLES, "EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId);
ChangeSeat(seatId);
}
+
return;
}
else
@@ -17079,6 +17089,7 @@ void Unit::_EnterVehicle(Vehicle* vehicle, int8 seatId, AuraApplication const* a
ASSERT(!m_vehicle);
m_vehicle = vehicle;
+
if (!m_vehicle->AddPassenger(this, seatId))
{
m_vehicle = NULL;
@@ -17131,9 +17142,11 @@ void Unit::_ExitVehicle(Position const* exitPosition)
m_vehicle->RemovePassenger(this);
+ Player* player = ToPlayer();
+
// If player is on mouted duel and exits the mount should immediatly lose the duel
- if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->duel && ToPlayer()->duel->isMounted)
- ToPlayer()->DuelComplete(DUEL_FLED);
+ if (player && player->duel && player->duel->isMounted)
+ player->DuelComplete(DUEL_FLED);
// This should be done before dismiss, because there may be some aura removal
Vehicle* vehicle = m_vehicle;
@@ -17150,8 +17163,8 @@ void Unit::_ExitVehicle(Position const* exitPosition)
AddUnitState(UNIT_STATE_MOVE);
- if (GetTypeId() == TYPEID_PLAYER)
- ToPlayer()->SetFallInformation(0, GetPositionZ());
+ if (player)
+ player->SetFallInformation(0, GetPositionZ());
else if (HasUnitMovementFlag(MOVEMENTFLAG_ROOT))
{
WorldPacket data(SMSG_SPLINE_MOVE_UNROOT, 8);
@@ -17167,7 +17180,7 @@ void Unit::_ExitVehicle(Position const* exitPosition)
//GetMotionMaster()->MoveFall(); // Enable this once passenger positions are calculater properly (see above)
- if (Player* player = ToPlayer())
+ if (player)
player->ResummonPetTemporaryUnSummonedIfAny();
if (vehicle->GetBase()->HasUnitTypeMask(UNIT_MASK_MINION))
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 5c29537db40..305b0e9aa7d 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1607,7 +1607,7 @@ class Unit : public WorldObject
void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false);
//void SetFacing(float ori, WorldObject* obj = NULL);
//void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL);
- void SendMovementFlagUpdate();
+ void SendMovementFlagUpdate(bool self = false);
/*! These methods send the same packet to the client in apply and unapply case.
The client-side interpretation of this packet depends on the presence of relevant movementflags
@@ -2357,6 +2357,7 @@ class Unit : public WorldObject
Spell const* _focusSpell;
bool _targetLocked; // locks the target during spell cast for proper facing
+ bool _isWalkingBeforeCharm; // Are we walking before we were charmed?
};
namespace Trinity