aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp34
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.cpp2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScriptMgr.h4
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp4
-rw-r--r--src/server/game/Entities/Player/Player.cpp48
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp40
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp16
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp3
-rw-r--r--src/server/game/Spells/Spell.cpp4
-rw-r--r--src/server/game/Spells/SpellEffects.cpp11
-rw-r--r--src/server/game/Spells/SpellMgr.cpp7
-rw-r--r--src/server/scripts/Commands/cs_group.cpp52
-rw-r--r--src/server/scripts/Kalimdor/zone_silithus.cpp2
-rw-r--r--src/server/scripts/Outland/zone_shadowmoon_valley.cpp2
14 files changed, 146 insertions, 83 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index f01d0d1ab03..7ea6895d028 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -252,7 +252,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (IsUnit(*itr))
{
- (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.onlySelf > 0 ? true : false);
+ (*itr)->SendPlaySound(e.action.sound.sound, e.action.sound.onlySelf > 0);
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_SOUND: target: %s (GuidLow: %u), sound: %u, onlyself: %u",
(*itr)->GetName().c_str(), (*itr)->GetGUIDLow(), e.action.sound.sound, e.action.sound.onlySelf);
}
@@ -516,7 +516,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
me->InterruptNonMeleeSpells(false);
- me->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) ? true : false);
+ me->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_CAST:: Creature %u casts spell %u on target %u with castflags %u",
me->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
@@ -547,7 +547,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.action.cast.flags & SMARTCAST_INTERRUPT_PREVIOUS)
tempLastInvoker->InterruptNonMeleeSpells(false);
- tempLastInvoker->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) ? true : false);
+ tempLastInvoker->CastSpell((*itr)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker %u casts spell %u on target %u with castflags %u",
tempLastInvoker->GetGUIDLow(), e.action.cast.spell, (*itr)->GetGUIDLow(), e.action.cast.flags);
}
@@ -697,7 +697,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack ? true : false);
+ CAST_AI(SmartAI, me->AI())->SetAutoAttack(e.action.autoAttack.attack);
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_AUTO_ATTACK: Creature: %u bool on = %u",
me->GetGUIDLow(), e.action.autoAttack.attack);
break;
@@ -707,7 +707,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- bool move = e.action.combatMove.move ? true : false;
+ bool move = e.action.combatMove.move;
CAST_AI(SmartAI, me->AI())->SetCombatMove(move);
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "SmartScript::ProcessAction:: SMART_ACTION_ALLOW_COMBAT_MOVEMENT: Creature %u bool on = %u",
me->GetGUIDLow(), e.action.combatMove.move);
@@ -1282,7 +1282,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly ? true : false);
+ CAST_AI(SmartAI, me->AI())->SetFly(e.action.setFly.fly);
break;
}
case SMART_ACTION_SET_RUN:
@@ -1290,7 +1290,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- CAST_AI(SmartAI, me->AI())->SetRun(e.action.setRun.run ? true : false);
+ CAST_AI(SmartAI, me->AI())->SetRun(e.action.setRun.run);
break;
}
case SMART_ACTION_SET_SWIM:
@@ -1298,7 +1298,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim ? true : false);
+ CAST_AI(SmartAI, me->AI())->SetSwim(e.action.setSwim.swim);
break;
}
case SMART_ACTION_WP_START:
@@ -1306,9 +1306,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (!IsSmart())
break;
- bool run = e.action.wpStart.run ? true : false;
+ bool run = e.action.wpStart.run;
uint32 entry = e.action.wpStart.pathID;
- bool repeat = e.action.wpStart.repeat ? true : false;
+ bool repeat = e.action.wpStart.repeat;
ObjectList* targets = GetTargets(e, unit);
StoreTargetList(targets, SMART_ESCORT_TARGETS);
me->SetReactState((ReactStates)e.action.wpStart.reactState);
@@ -1336,7 +1336,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
uint32 DespawnTime = e.action.wpStop.despawnTime;
uint32 quest = e.action.wpStop.quest;
- bool fail = e.action.wpStop.fail ? true : false;
+ bool fail = e.action.wpStop.fail;
CAST_AI(SmartAI, me->AI())->StopPath(DespawnTime, quest, fail);
break;
}
@@ -1689,7 +1689,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
interruptedSpell = true;
}
- (*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED) ? true : false);
+ (*itr)->ToUnit()->CastSpell((*it)->ToUnit(), e.action.cast.spell, (e.action.cast.flags & SMARTCAST_TRIGGERED));
}
else
TC_LOG_DEBUG(LOG_FILTER_DATABASE_AI, "Spell %u not casted because it has flag SMARTCAST_AURA_NOT_PRESENT and the target (Guid: " UI64FMTD " Entry: %u Type: %u) already has the aura", e.action.cast.spell, (*it)->GetGUID(), (*it)->GetEntry(), uint32((*it)->GetTypeId()));
@@ -2050,7 +2050,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (IsCreature(*itr))
- (*itr)->ToCreature()->setRegeneratingHealth(e.action.setHealthRegen.regenHealth ? true : false);
+ (*itr)->ToCreature()->setRegeneratingHealth(e.action.setHealthRegen.regenHealth);
delete targets;
break;
@@ -2063,7 +2063,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr)
if (IsCreature(*itr))
- (*itr)->ToCreature()->SetControlled(e.action.setRoot.root ? true : false, UNIT_STATE_ROOT);
+ (*itr)->ToCreature()->SetControlled(e.action.setRoot.root, UNIT_STATE_ROOT);
delete targets;
break;
@@ -2519,7 +2519,7 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /*
}
case SMART_TARGET_CLOSEST_CREATURE:
{
- Creature* target = GetClosestCreatureWithEntry(baseObject, e.target.closest.entry, (float)(e.target.closest.dist ? e.target.closest.dist : 100), e.target.closest.dead ? false : true);
+ Creature* target = GetClosestCreatureWithEntry(baseObject, e.target.closest.entry, (float)(e.target.closest.dist ? e.target.closest.dist : 100), !e.target.closest.dead);
if (target)
l->push_back(target);
break;
@@ -2686,7 +2686,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->GetVictim());
break;
}
- case SMART_EVENT_TARGET_CASTING:
+ case SMART_EVENT_VICTIM_CASTING:
{
if (!me || !me->IsInCombat())
return;
@@ -3148,7 +3148,7 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
case SMART_EVENT_MANA_PCT:
case SMART_EVENT_TARGET_MANA_PCT:
case SMART_EVENT_RANGE:
- case SMART_EVENT_TARGET_CASTING:
+ case SMART_EVENT_VICTIM_CASTING:
case SMART_EVENT_FRIENDLY_HEALTH:
case SMART_EVENT_FRIENDLY_IS_CC:
case SMART_EVENT_FRIENDLY_MISSING_BUFF:
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
index 361cf025647..87c35d59cc0 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp
@@ -438,7 +438,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
if (e.event.kill.creature && !IsCreatureValid(e, e.event.kill.creature))
return false;
break;
- case SMART_EVENT_TARGET_CASTING:
+ case SMART_EVENT_VICTIM_CASTING:
if (e.event.targetCasting.spellId > 0 && !sSpellMgr->GetSpellInfo(e.event.targetCasting.spellId))
{
sLog->outError(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
index f12f2ab69c0..7ed8e60ed44 100644
--- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h
+++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h
@@ -94,7 +94,7 @@ enum SMART_EVENT
SMART_EVENT_OOC_LOS = 10, // NoHostile, MaxRnage, CooldownMin, CooldownMax
SMART_EVENT_RESPAWN = 11, // type, MapId, ZoneId
SMART_EVENT_TARGET_HEALTH_PCT = 12, // HPMin%, HPMax%, RepeatMin, RepeatMax
- SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax, spellid
+ SMART_EVENT_VICTIM_CASTING = 13, // RepeatMin, RepeatMax, spellid
SMART_EVENT_FRIENDLY_HEALTH = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_IS_CC = 15, // Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax
@@ -1196,7 +1196,7 @@ const uint32 SmartAIEventMask[SMART_EVENT_END][2] =
{SMART_EVENT_OOC_LOS, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_RESPAWN, SMART_SCRIPT_TYPE_MASK_CREATURE + SMART_SCRIPT_TYPE_MASK_GAMEOBJECT },
{SMART_EVENT_TARGET_HEALTH_PCT, SMART_SCRIPT_TYPE_MASK_CREATURE },
- {SMART_EVENT_TARGET_CASTING, SMART_SCRIPT_TYPE_MASK_CREATURE },
+ {SMART_EVENT_VICTIM_CASTING, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_FRIENDLY_HEALTH, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_FRIENDLY_IS_CC, SMART_SCRIPT_TYPE_MASK_CREATURE },
{SMART_EVENT_FRIENDLY_MISSING_BUFF, SMART_SCRIPT_TYPE_MASK_CREATURE },
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index af92f0e9df4..6d940623963 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -105,7 +105,11 @@ void GameObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
RemoveFromOwner();
if (GetTransport() && !ToTransport())
+ {
GetTransport()->RemovePassenger(this);
+ SetTransport(NULL);
+ m_movementInfo.transport.Reset();
+ }
}
void GameObject::RemoveFromOwner()
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 40dbe6c2fe7..eaee6dc090a 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -923,9 +923,6 @@ void Player::CleanupsBeforeDelete(bool finalCleanup)
Unit::CleanupsBeforeDelete(finalCleanup);
- if (m_transport)
- m_transport->RemovePassenger(this);
-
// clean up player-instance binds, may unload some instance saves
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr)
@@ -2181,8 +2178,26 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
if (!(options & TELE_TO_NOT_LEAVE_COMBAT))
CombatStop();
+ // new final coordinates
+ float final_x = x;
+ float final_y = y;
+ float final_z = z;
+ float final_o = orientation;
+
+ // Calculate final positions if on transport
+ if (m_transport)
+ {
+ float tx, ty, tz, to;
+ m_movementInfo.transport.pos.GetPosition(tx, ty, tz, to);
+
+ final_x = x + tx * std::cos(orientation) - ty * std::sin(orientation);
+ final_y = y + ty * std::cos(orientation) + tx * std::sin(orientation);
+ final_z = z + tz;
+ final_o = Position::NormalizeOrientation(orientation + m_movementInfo.transport.pos.GetOrientation());
+ }
+
// this will be used instead of the current location in SaveToDB
- m_teleport_dest = WorldLocation(mapid, x, y, z, orientation);
+ m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
SetFallInformation(0, z);
// code for finish transfer called in WorldSession::HandleMovementOpcodes()
@@ -2193,7 +2208,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
{
Position oldPos;
GetPosition(&oldPos);
- Relocate(x, y, z, orientation);
+ Relocate(final_x, final_y, final_z, final_o);
SendTeleportAckPacket();
SendTeleportPacket(oldPos); // this automatically relocates to oldPos in order to broadcast the packet in the right place
}
@@ -2295,16 +2310,20 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
float final_z = z;
float final_o = orientation;
+ // Calculate final positions if on transport
if (m_transport)
{
- final_x += m_movementInfo.transport.pos.GetPositionX();
- final_y += m_movementInfo.transport.pos.GetPositionY();
- final_z += m_movementInfo.transport.pos.GetPositionZ();
- final_o += m_movementInfo.transport.pos.GetOrientation();
+ float tx, ty, tz, to;
+ m_movementInfo.transport.pos.GetPosition(tx, ty, tz, to);
+
+ final_x = x + tx * std::cos(orientation) - ty * std::sin(orientation);
+ final_y = y + ty * std::cos(orientation) + tx * std::sin(orientation);
+ final_z = z + tz;
+ final_o = Position::NormalizeOrientation(orientation + m_movementInfo.transport.pos.GetOrientation());
}
m_teleport_dest = WorldLocation(mapid, final_x, final_y, final_z, final_o);
- SetFallInformation(0, final_z);
+ SetFallInformation(0, z);
// if the player is saved before worldportack (at logout for example)
// this will be used instead of the current location in SaveToDB
@@ -15459,9 +15478,6 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg)
// can be start if only all quests in prev quest exclusive group completed and rewarded
ObjectMgr::ExclusiveQuestGroupsBounds range(sObjectMgr->mExclusiveQuestGroups.equal_range(qPrevInfo->GetExclusiveGroup()));
- // always must be found if qPrevInfo->ExclusiveGroup != 0
- ASSERT(range.first != range.second);
-
for (; range.first != range.second; ++range.first)
{
uint32 exclude_Id = range.first->second;
@@ -15495,9 +15511,6 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg)
// can be start if only all quests in prev quest exclusive group active
ObjectMgr::ExclusiveQuestGroupsBounds range(sObjectMgr->mExclusiveQuestGroups.equal_range(qPrevInfo->GetExclusiveGroup()));
- // always must be found if qPrevInfo->ExclusiveGroup != 0
- ASSERT(range.first != range.second);
-
for (; range.first != range.second; ++range.first)
{
uint32 exclude_Id = range.first->second;
@@ -15665,9 +15678,6 @@ bool Player::SatisfyQuestExclusiveGroup(Quest const* qInfo, bool msg)
ObjectMgr::ExclusiveQuestGroupsBounds range(sObjectMgr->mExclusiveQuestGroups.equal_range(qInfo->GetExclusiveGroup()));
- // always must be found if qInfo->ExclusiveGroup != 0
- ASSERT(range.first != range.second);
-
for (; range.first != range.second; ++range.first)
{
uint32 exclude_Id = range.first->second;
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 06af4244246..30b7b61f574 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -181,8 +181,8 @@ void Transport::Update(uint32 diff)
float t = CalculateSegmentPos(float(timer) * 0.001f);
G3D::Vector3 pos, dir;
_currentFrame->Spline->evaluate_percent(_currentFrame->Index, t, pos);
- //_currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
- UpdatePosition(pos.x, pos.y, pos.z, 0.0f/*atan2(dir.x, dir.y)*/);
+ _currentFrame->Spline->evaluate_derivative(_currentFrame->Index, t, dir);
+ UpdatePosition(pos.x, pos.y, pos.z, atan2(dir.x, dir.y));
}
}
@@ -450,40 +450,19 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
}
}
- // Teleport passengers after everyone on destination map are sent create packet
- // but before transport itself is registered there and begins updating
- for (std::set<WorldObject*>::iterator itr = _staticPassengers.begin(); itr != _staticPassengers.end(); ++itr)
+ for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end();)
{
- switch ((*itr)->GetTypeId())
- {
- case TYPEID_UNIT:
- (*itr)->ToCreature()->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation());
- break;
- case TYPEID_GAMEOBJECT:
- {
- GameObject* go = (*itr)->ToGameObject();
- go->GetMap()->RemoveFromMap(go, false);
- Relocate(x, y, z, go->GetOrientation());
- SetMap(newMap);
- newMap->AddToMap(go);
- break;
- }
- default:
- break;
- }
- }
+ WorldObject* obj = (*itr++);
- for (std::set<WorldObject*>::iterator itr = _passengers.begin(); itr != _passengers.end(); ++itr)
- {
- switch ((*itr)->GetTypeId())
+ switch (obj->GetTypeId())
{
case TYPEID_UNIT:
- if (!IS_PLAYER_GUID((*itr)->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
- (*itr)->ToCreature()->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation());
+ if (!IS_PLAYER_GUID(obj->ToUnit()->GetOwnerGUID())) // pets should be teleported with player
+ obj->ToCreature()->FarTeleportTo(newMap, x, y, z, obj->GetOrientation());
break;
case TYPEID_GAMEOBJECT:
{
- GameObject* go = (*itr)->ToGameObject();
+ GameObject* go = obj->ToGameObject();
go->GetMap()->RemoveFromMap(go, false);
Relocate(x, y, z, go->GetOrientation());
SetMap(newMap);
@@ -491,7 +470,8 @@ void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
break;
}
case TYPEID_PLAYER:
- (*itr)->ToPlayer()->TeleportTo(newMapid, x, y, z, (*itr)->GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
+ if (!obj->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT))
+ _passengers.erase(obj);
break;
default:
break;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 2fd1c500305..c3a611c441f 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -7575,7 +7575,7 @@ bool Unit::HandleAuraProc(Unit* victim, uint32 damage, Aura* triggeredByAura, Sp
CastSpell(this, 28682, true);
- return (procEx & PROC_EX_CRITICAL_HIT) ? true : false;
+ return (procEx & PROC_EX_CRITICAL_HIT);
}
// Empowered Fire
case 31656:
@@ -8914,6 +8914,9 @@ bool Unit::Attack(Unit* victim, bool meleeAttack)
if (GetTypeId() == TYPEID_PLAYER && IsMounted())
return false;
+ if (HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED))
+ return false;
+
// nobody can attack GM in GM-mode
if (victim->GetTypeId() == TYPEID_PLAYER)
{
@@ -13349,7 +13352,7 @@ void Unit::SetPower(Powers power, uint32 val)
data.append(GetPackGUID());
data << uint8(power);
data << uint32(val);
- SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER ? true : false);
+ SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
// group update
if (Player* player = ToPlayer())
@@ -13499,9 +13502,12 @@ void Unit::CleanupsBeforeDelete(bool finalCleanup)
{
CleanupBeforeRemoveFromMap(finalCleanup);
- if (Creature* thisCreature = ToCreature())
- if (GetTransport())
- GetTransport()->RemovePassenger(thisCreature);
+ if (GetTransport())
+ {
+ GetTransport()->RemovePassenger(this);
+ SetTransport(NULL);
+ m_movementInfo.transport.Reset();
+ }
}
void Unit::UpdateCharmAI()
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index d6f96f79cc1..3309a8c010e 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -2301,7 +2301,10 @@ void AuraEffect::HandleAuraModPacify(AuraApplication const* aurApp, uint8 mode,
Unit* target = aurApp->GetTarget();
if (apply)
+ {
target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PACIFIED);
+ target->AttackStop();
+ }
else
{
// do not remove unit flag if there are more than this auraEffect of that kind on unit on unit
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 2eee80924a4..aa629b46e28 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2680,7 +2680,9 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
m_diminishLevel = unit->GetDiminishing(m_diminishGroup);
DiminishingReturnsType type = GetDiminishingReturnsGroupType(m_diminishGroup);
// Increase Diminishing on unit, current informations for actually casts will use values above
- if ((type == DRTYPE_PLAYER && unit->GetCharmerOrOwnerPlayerOrPlayerItself()) || type == DRTYPE_ALL)
+ if ((type == DRTYPE_PLAYER &&
+ (unit->GetCharmerOrOwnerPlayerOrPlayerItself() || (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) ||
+ type == DRTYPE_ALL)
unit->IncrDiminishing(m_diminishGroup);
}
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 562d7fee518..0732c389bfa 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -1150,10 +1150,15 @@ void Spell::EffectTeleportUnits(SpellEffIndex /*effIndex*/)
orientation = m_targets.GetUnitTarget()->GetOrientation();
TC_LOG_DEBUG(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - teleport unit to %u %f %f %f %f\n", mapid, x, y, z, orientation);
- if (mapid == unitTarget->GetMapId())
- unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
- else if (unitTarget->GetTypeId() == TYPEID_PLAYER)
+ if (unitTarget->GetTypeId() == TYPEID_PLAYER)
unitTarget->ToPlayer()->TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TELE_TO_SPELL : 0);
+ else if (mapid == unitTarget->GetMapId())
+ unitTarget->NearTeleportTo(x, y, z, orientation, unitTarget == m_caster);
+ else
+ {
+ TC_LOG_ERROR(LOG_FILTER_SPELLS_AURAS, "Spell::EffectTeleportUnits - spellId %u attempted to teleport creature to a different map.", m_spellInfo->Id);
+ return;
+ }
// post effects for TARGET_DEST_DB
switch (m_spellInfo->Id)
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index ff89cc61f6f..52ffb2ff525 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -191,6 +191,13 @@ DiminishingGroup GetDiminishingReturnsGroupForSpell(SpellInfo const* spellproto,
return DIMINISHING_FEAR;
break;
}
+ case SPELLFAMILY_SHAMAN:
+ {
+ // Storm, Earth and Fire - Earthgrab
+ if (spellproto->SpellFamilyFlags[2] & 0x4000)
+ return DIMINISHING_NONE;
+ break;
+ }
case SPELLFAMILY_DEATHKNIGHT:
{
// Hungering Cold (no flags)
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index 8c38d954203..1c0949398b9 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -260,24 +260,36 @@ public:
static bool HandleGroupListCommand(ChatHandler* handler, char const* args)
{
+ // Get ALL the variables!
Player* playerTarget;
+ uint32 phase = 0;
+ uint32 groupCounter = 0;
uint64 guidTarget;
std::string nameTarget;
+ std::string zoneName;
+ const char* onlineState = "";
+ // Parse the guid to uint32...
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
+ // ... and try to extract a player out of it.
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, nameTarget))
{
playerTarget = sObjectMgr->GetPlayerByLowGUID(parseGUID);
guidTarget = parseGUID;
}
+ // If not, we return false and end right away.
else if (!handler->extractPlayerTarget((char*)args, &playerTarget, &guidTarget, &nameTarget))
return false;
+ // Next, we need a group. So we define a group variable.
Group* groupTarget = NULL;
+
+ // We try to extract a group from an online player.
if (playerTarget)
groupTarget = playerTarget->GetGroup();
+ // If not, we extract it from the SQL.
if (!groupTarget)
{
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GROUP_MEMBER);
@@ -287,6 +299,7 @@ public:
groupTarget = sGroupMgr->GetGroupByDbStoreId((*resultGroup)[0].GetUInt32());
}
+ // If both fails, players simply has no party. Return false.
if (!groupTarget)
{
handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, nameTarget.c_str());
@@ -294,12 +307,20 @@ public:
return false;
}
- handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"));
+ // We get the group members after successfully detecting a group.
Group::MemberSlotList const& members = groupTarget->GetMemberSlots();
+
+ // To avoid a cluster fuck, namely trying multiple queries to simply get a group member count...
+ handler->PSendSysMessage(LANG_GROUP_TYPE, (groupTarget->isRaidGroup() ? "raid" : "party"), members.size());
+ // ... we simply move the group type and member count print after retrieving the slots and simply output it's size.
+
+ // While rather dirty codestyle-wise, it saves space (if only a little). For each member, we look several informations up.
for (Group::MemberSlotList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
{
+ // Define temporary variable slot to iterator.
Group::MemberSlot const& slot = *itr;
+ // Check for given flag and assign it to that iterator
std::string flags;
if (slot.flags & MEMBER_FLAG_ASSISTANT)
flags = "Assistant";
@@ -321,13 +342,38 @@ public:
if (flags.empty())
flags = "None";
+ // Check if iterator is online. If is...
Player* p = ObjectAccessor::FindPlayer((*itr).guid);
- const char* onlineState = (p && p->IsInWorld()) ? "online" : "offline";
+ if (p && p->IsInWorld())
+ {
+ // ... than, it prints information like "is online", where he is, etc...
+ onlineState = "online";
+ phase = (!p->IsGameMaster() ? p->GetPhaseMask() : -1);
+ uint32 locale = handler->GetSessionDbcLocale();
+
+ AreaTableEntry const* area = GetAreaEntryByAreaID(p->GetAreaId());
+ if (area)
+ {
+ AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
+ if (zone)
+ zoneName = zone->area_name[locale];
+ }
+ }
+ else
+ {
+ // ... else, everything is set to offline or neutral values.
+ zoneName = "<ERROR>";
+ onlineState = "Offline";
+ phase = 0;
+ }
+ // Now we can print those informations for every single member of each group!
handler->PSendSysMessage(LANG_GROUP_PLAYER_NAME_GUID, slot.name.c_str(), onlineState,
- GUID_LOPART(slot.guid), flags.c_str(), lfg::GetRolesString(slot.roles).c_str());
+ zoneName.c_str(), phase, GUID_LOPART(slot.guid), flags.c_str(),
+ lfg::GetRolesString(slot.roles).c_str());
}
+ // And finish after every iterator is done.
return true;
}
};
diff --git a/src/server/scripts/Kalimdor/zone_silithus.cpp b/src/server/scripts/Kalimdor/zone_silithus.cpp
index fd8a1069ff7..79bd6f691e6 100644
--- a/src/server/scripts/Kalimdor/zone_silithus.cpp
+++ b/src/server/scripts/Kalimdor/zone_silithus.cpp
@@ -1014,7 +1014,7 @@ public:
uint8 DeadMemberCount = 0;
uint8 FailedMemberCount = 0;
- Group::MemberSlotList const members = EventGroup->GetMemberSlots();
+ Group::MemberSlotList const& members = EventGroup->GetMemberSlots();
for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
{
diff --git a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
index eac3dce43b0..24fbcf881b2 100644
--- a/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
+++ b/src/server/scripts/Outland/zone_shadowmoon_valley.cpp
@@ -1467,7 +1467,7 @@ public:
uint8 DeadMemberCount = 0;
uint8 FailedMemberCount = 0;
- const Group::MemberSlotList members = EventGroup->GetMemberSlots();
+ Group::MemberSlotList const& members = EventGroup->GetMemberSlots();
for (Group::member_citerator itr = members.begin(); itr!= members.end(); ++itr)
{