aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/collision/Models/GameObjectModel.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp7
-rwxr-xr-xsrc/server/game/Achievements/AchievementMgr.cpp2
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp7
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp3
-rwxr-xr-xsrc/server/game/Battlegrounds/Zones/BattlegroundAB.cpp5
-rwxr-xr-xsrc/server/game/Entities/GameObject/GameObject.cpp31
-rwxr-xr-xsrc/server/game/Entities/Totem/Totem.cpp6
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp43
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h3
-rwxr-xr-xsrc/server/game/Handlers/BattleGroundHandler.cpp50
-rwxr-xr-xsrc/server/game/Maps/Map.cpp4
-rwxr-xr-xsrc/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp5
-rwxr-xr-xsrc/server/game/Scripting/ScriptLoader.cpp2
-rwxr-xr-xsrc/server/game/Spells/Auras/SpellAuras.cpp15
-rwxr-xr-xsrc/server/game/Spells/Spell.cpp51
-rwxr-xr-xsrc/server/game/Spells/Spell.h1
-rw-r--r--src/server/game/Spells/SpellInfo.cpp2
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp938
-rw-r--r--src/server/scripts/Northrend/dragonblight.cpp2
-rw-r--r--src/server/scripts/Northrend/storm_peaks.cpp348
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp2
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp2
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp11
-rw-r--r--src/server/shared/Logging/AppenderConsole.cpp4
-rwxr-xr-xsrc/server/shared/Utilities/Util.cpp2
-rwxr-xr-xsrc/server/shared/Utilities/Util.h18
-rw-r--r--src/tools/map_extractor/CMakeLists.txt2
-rw-r--r--src/tools/map_extractor/System.cpp1
29 files changed, 759 insertions, 810 deletions
diff --git a/src/server/collision/Models/GameObjectModel.h b/src/server/collision/Models/GameObjectModel.h
index 0bb6c0f47bc..78a0e876676 100644
--- a/src/server/collision/Models/GameObjectModel.h
+++ b/src/server/collision/Models/GameObjectModel.h
@@ -61,6 +61,8 @@ public:
void disable() { phasemask = 0;}
void enable(uint32 ph_mask) { phasemask = ph_mask;}
+ bool isEnabled() const {return phasemask != 0;}
+
bool intersectRay(const G3D::Ray& Ray, float& MaxDist, bool StopAtFirstHit, uint32 ph_mask) const;
static GameObjectModel* Create(const GameObject& go);
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp
index 0b8236908a0..a7660a0a44b 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -634,8 +634,11 @@ void SmartAI::SpellHitTarget(Unit* target, const SpellInfo* spellInfo)
void SmartAI::DamageTaken(Unit* doneBy, uint32& damage)
{
GetScript()->ProcessEventsFor(SMART_EVENT_DAMAGED, doneBy, damage);
- if ((me->GetHealth() - damage) <= mInvincibilityHpLevel)
- damage = me->GetHealth() - mInvincibilityHpLevel;
+ if ((damage >= me->GetHealth() - mInvincibilityHpLevel) && (mInvincibilityHpLevel > 0))
+ {
+ damage = 0;
+ me->SetHealth(mInvincibilityHpLevel);
+ }
}
void SmartAI::HealReceived(Unit* doneBy, uint32& addhealth)
diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp
index 506495469d3..037000133c4 100755
--- a/src/server/game/Achievements/AchievementMgr.cpp
+++ b/src/server/game/Achievements/AchievementMgr.cpp
@@ -364,7 +364,7 @@ bool AchievementCriteriaData::Meets(uint32 criteria_id, Player const* source, Un
return sScriptMgr->OnCriteriaCheck(this, const_cast<Player*>(source), const_cast<Unit*>(target));
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_DIFFICULTY:
if (source->GetMap()->IsRaid())
- if (source->GetMap()->Is25ManRaid() != (difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN))
+ if (source->GetMap()->Is25ManRaid() != ((difficulty.difficulty & RAID_DIFFICULTY_MASK_25MAN) != 0))
return false;
return source->GetMap()->GetSpawnMode() >= difficulty.difficulty;
case ACHIEVEMENT_CRITERIA_DATA_TYPE_MAP_PLAYER_COUNT:
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index ffc5e48290b..c0cf64ead58 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -60,6 +60,13 @@ Battlefield::Battlefield()
Battlefield::~Battlefield()
{
+ for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
+ delete itr->second;
+
+ for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr)
+ delete *itr;
+
+ m_capturePoints.clear();
}
// Called when a player enters the zone
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index 09783176094..233dbeca077 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -37,6 +37,9 @@ BattlefieldWG::~BattlefieldWG()
{
for (Workshop::const_iterator itr = WorkshopsList.begin(); itr != WorkshopsList.end(); ++itr)
delete *itr;
+
+ for (GameObjectBuilding::const_iterator itr = BuildingsInZone.begin(); itr != BuildingsInZone.end(); ++itr)
+ delete *itr;
}
bool BattlefieldWG::SetupBattlefield()
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
index 8b2543f20ff..9ebaf481098 100755
--- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp
@@ -371,9 +371,10 @@ void BattlegroundAB::_NodeOccupied(uint8 node, Team team)
if (node >= BG_AB_DYNAMIC_NODES_COUNT)//only dynamic nodes, no start points
return;
- Creature* trigger = GetBGCreature(node+7);//0-6 spirit guides
+
+ Creature* trigger = BgCreatures[node+7] ? GetBGCreature(node+7) : NULL;//0-6 spirit guides
if (!trigger)
- trigger = AddCreature(WORLD_TRIGGER, node+7, team, BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1], BG_AB_NodePositions[node][2], BG_AB_NodePositions[node][3]);
+ trigger = AddCreature(WORLD_TRIGGER, node+7, team, BG_AB_NodePositions[node][0], BG_AB_NodePositions[node][1], BG_AB_NodePositions[node][2], BG_AB_NodePositions[node][3]);
//add bonus honor aura trigger creature when node is accupied
//cast bonus aura (+50% honor in 25yards)
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/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp
index a9a0484a4ea..d5d1bd99277 100755
--- a/src/server/game/Entities/Totem/Totem.cpp
+++ b/src/server/game/Entities/Totem/Totem.cpp
@@ -98,6 +98,12 @@ void Totem::InitSummon()
void Totem::UnSummon(uint32 msTime)
{
+ if (msTime)
+ {
+ m_Events.AddEvent(new ForcedUnsummonDelayEvent(*this), m_Events.CalculateTime(msTime));
+ return;
+ }
+
CombatStop();
RemoveAurasDueToSpell(GetSpell(), GetGUID());
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 5118b5810b6..5d397790b44 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;
}
////////////////////////////////////////////////////////////
@@ -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())
@@ -12266,19 +12271,21 @@ bool Unit::_IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, Wo
if (GetReactionTo(target) == REP_NEUTRAL &&
target->GetReactionTo(this) == REP_NEUTRAL)
{
- if (
- !(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) &&
- !(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT)
- )
+ if (!(target->GetTypeId() == TYPEID_PLAYER && GetTypeId() == TYPEID_PLAYER) &&
+ !(target->GetTypeId() == TYPEID_UNIT && GetTypeId() == TYPEID_UNIT))
{
Player const* player = target->GetTypeId() == TYPEID_PLAYER ? target->ToPlayer() : ToPlayer();
Unit const* creature = target->GetTypeId() == TYPEID_UNIT ? target : this;
if (FactionTemplateEntry const* factionTemplate = creature->getFactionTemplateEntry())
- if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
- if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
- if (!(repState->Flags & FACTION_FLAG_AT_WAR))
- return false;
+ {
+ if (!(player->GetReputationMgr().GetForcedRankIfAny(factionTemplate)))
+ if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionTemplate->faction))
+ if (FactionState const* repState = player->GetReputationMgr().GetState(factionEntry))
+ if (!(repState->Flags & FACTION_FLAG_AT_WAR))
+ return false;
+
+ }
}
}
@@ -14761,11 +14768,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
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 2ec3ffec8ef..98d7bbcdcde 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1606,7 +1606,7 @@ class Unit : public WorldObject
void MonsterMoveWithSpeed(float x, float y, float z, float speed);
//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
@@ -2356,6 +2356,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
diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp
index 475c1c42fca..72a6e0e1bec 100755
--- a/src/server/game/Handlers/BattleGroundHandler.cpp
+++ b/src/server/game/Handlers/BattleGroundHandler.cpp
@@ -244,7 +244,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data)
sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId());
}
-void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_data*/)
+void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recv_data*/)
{
sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Recvd MSG_BATTLEGROUND_PLAYER_POSITIONS Message");
@@ -252,39 +252,44 @@ void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket & /*recv_
if (!bg) // can't be received if player not in battleground
return;
- uint32 count = 0;
- Player* aplr = NULL;
- Player* hplr = NULL;
+ uint32 flagCarrierCount = 0;
+ Player* allianceFlagCarrier = NULL;
+ Player* hordeFlagCarrier = NULL;
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_ALLIANCE))
{
- aplr = ObjectAccessor::FindPlayer(guid);
- if (aplr)
- ++count;
+ allianceFlagCarrier = ObjectAccessor::FindPlayer(guid);
+ if (allianceFlagCarrier)
+ ++flagCarrierCount;
}
if (uint64 guid = bg->GetFlagPickerGUID(BG_TEAM_HORDE))
{
- hplr = ObjectAccessor::FindPlayer(guid);
- if (hplr)
- ++count;
+ hordeFlagCarrier = ObjectAccessor::FindPlayer(guid);
+ if (hordeFlagCarrier)
+ ++flagCarrierCount;
}
- WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * count);
- data << 0;
- data << count;
- if (aplr)
+ WorldPacket data(MSG_BATTLEGROUND_PLAYER_POSITIONS, 4 + 4 + 16 * flagCarrierCount);
+ // Used to send several player positions (found used in AV)
+ data << 0; // CGBattlefieldInfo__m_numPlayerPositions
+ /*
+ for (CGBattlefieldInfo__m_numPlayerPositions)
+ data << guid << posx << posy;
+ */
+ data << flagCarrierCount;
+ if (allianceFlagCarrier)
{
- data << uint64(aplr->GetGUID());
- data << float(aplr->GetPositionX());
- data << float(aplr->GetPositionY());
+ data << uint64(allianceFlagCarrier->GetGUID());
+ data << float(allianceFlagCarrier->GetPositionX());
+ data << float(allianceFlagCarrier->GetPositionY());
}
- if (hplr)
+ if (hordeFlagCarrier)
{
- data << uint64(hplr->GetGUID());
- data << float(hplr->GetPositionX());
- data << float(hplr->GetPositionY());
+ data << uint64(hordeFlagCarrier->GetGUID());
+ data << float(hordeFlagCarrier->GetPositionX());
+ data << float(hordeFlagCarrier->GetPositionY());
}
SendPacket(&data);
@@ -457,6 +462,9 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket &recv_data)
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Battleground: player %s (%u) joined battle for bg %u, bgtype %u, queue type %u.", _player->GetName(), _player->GetGUIDLow(), bg->GetInstanceID(), bg->GetTypeID(), bgQueueTypeId);
break;
case 0: // leave queue
+ if (bg->isArena() && bg->GetStatus() != STATUS_WAIT_QUEUE)
+ return;
+
// if player leaves rated arena match before match start, it is counted as he played but he lost
if (ginfo.IsRated && ginfo.IsInvitedToBGInstanceGUID)
{
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index c06c7414e6e..fdf4b9ee8de 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -1223,8 +1223,8 @@ bool GridMap::loadLiquidData(FILE* in, uint32 offset, uint32 /*size*/)
}
if (!(header.flags & MAP_LIQUID_NO_HEIGHT))
{
- _liquidMap = new float[_liquidWidth*_liquidHeight];
- if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != _liquidWidth*_liquidHeight)
+ _liquidMap = new float[uint32(_liquidWidth) * uint32(_liquidHeight)];
+ if (fread(_liquidMap, sizeof(float), _liquidWidth*_liquidHeight, in) != (uint32(_liquidWidth) * uint32(_liquidHeight)))
return false;
}
return true;
diff --git a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
index 7e130a2c143..56818e95a2b 100755
--- a/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
+++ b/src/server/game/Movement/MovementGenerators/FleeingMovementGenerator.cpp
@@ -140,7 +140,12 @@ bool FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float
angle = i_cur_angle + static_cast<float>(M_PI);
distance /= 2;
break;
+ default:
+ angle = 0.0f;
+ distance = 0.0f;
+ break;
}
+
temp_x = x + distance * cos(angle);
temp_y = y + distance * sin(angle);
Trinity::NormalizeMapCoord(temp_x);
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index 1848250ec8e..fc56106ab6f 100755
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -325,6 +325,7 @@ void AddSC_bug_trio();
void AddSC_boss_sartura();
void AddSC_boss_skeram();
void AddSC_boss_twinemperors();
+void AddSC_boss_ouro();
void AddSC_mob_anubisath_sentinel();
void AddSC_instance_temple_of_ahnqiraj();
void AddSC_wailing_caverns(); //Wailing caverns
@@ -953,6 +954,7 @@ void AddKalimdorScripts()
AddSC_boss_sartura();
AddSC_boss_skeram();
AddSC_boss_twinemperors();
+ AddSC_boss_ouro();
AddSC_mob_anubisath_sentinel();
AddSC_instance_temple_of_ahnqiraj();
AddSC_wailing_caverns(); //Wailing caverns
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 9ee05b9a2a4..fb1cdc576ba 100755
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -766,7 +766,7 @@ void Aura::SetCharges(uint8 charges)
uint8 Aura::CalcMaxCharges(Unit* caster) const
{
- uint8 maxProcCharges = m_spellInfo->ProcCharges;
+ uint32 maxProcCharges = m_spellInfo->ProcCharges;
if (SpellProcEntry const* procEntry = sSpellMgr->GetSpellProcEntry(GetId()))
maxProcCharges = procEntry->charges;
@@ -1414,10 +1414,16 @@ void Aura::HandleAuraSpecificMods(AuraApplication const* aurApp, Unit* caster, b
if (caster->GetTypeId() == TYPEID_PLAYER)
{
if (caster->ToPlayer()->HasSpellCooldown(aura->GetId()))
- break;
- // and add if needed
- caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, uint32(time(NULL) + 12));
+ {
+ // This additional check is needed to add a minimal delay before cooldown in in effect
+ // to allow all bubbles broken by a single damage source proc mana return
+ if (caster->ToPlayer()->GetSpellCooldownDelay(aura->GetId()) <= 11)
+ break;
+ }
+ else // and add if needed
+ caster->ToPlayer()->AddSpellCooldown(aura->GetId(), 0, uint32(time(NULL) + 12));
}
+
// effect on caster
if (AuraEffect const* aurEff = aura->GetEffect(0))
{
@@ -2062,6 +2068,7 @@ void Aura::LoadScripts()
{
std::list<AuraScript*>::iterator bitr = itr;
++itr;
+ delete (*bitr);
m_loadedScripts.erase(bitr);
continue;
}
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 95345ed8b93..e64197b5242 100755
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -583,7 +583,7 @@ m_caster((info->AttributesEx6 & SPELL_ATTR6_CAST_BY_CHARMER && caster->GetCharme
&& !m_spellInfo->IsPassive() && !m_spellInfo->IsPositive();
CleanupTargetList();
- CleanupEffectExecuteData();
+ memset(m_effectExecuteData, NULL, MAX_SPELL_EFFECTS * sizeof(ByteBuffer*));
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
m_destTargets[i] = SpellDestination(*m_caster);
@@ -3025,7 +3025,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
-
+
// Set casttime to 0 if .cheat casttime is enabled.
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
m_casttime = 0;
@@ -3323,7 +3323,7 @@ void Spell::cast(bool skipCheck)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
-
+
//Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true);
@@ -4083,41 +4083,47 @@ void Spell::WriteAmmoToPacket(WorldPacket* data)
*data << uint32(ammoInventoryType);
}
+/// Writes miss and hit targets for a SMSG_SPELL_GO packet
void Spell::WriteSpellGoTargets(WorldPacket* data)
{
// This function also fill data for channeled spells:
// m_needAliveTargetMask req for stop channelig if one target die
- uint32 hit = m_UniqueGOTargetInfo.size(); // Always hits on GO
- uint32 miss = 0;
for (std::list<TargetInfo>::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
{
if ((*ihit).effectMask == 0) // No effect apply - all immuned add state
- {
// possibly SPELL_MISS_IMMUNE2 for this??
ihit->missCondition = SPELL_MISS_IMMUNE2;
- ++miss;
- }
- else if ((*ihit).missCondition == SPELL_MISS_NONE)
- ++hit;
- else
- ++miss;
}
- *data << (uint8)hit;
- for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+ // Hit and miss target counts are both uint8, that limits us to 255 targets for each
+ // sending more than 255 targets crashes the client (since count sent would be wrong)
+ // Spells like 40647 (with a huge radius) can easily reach this limit (spell might need
+ // target conditions but we still need to limit the number of targets sent and keeping
+ // correct count for both hit and miss).
+
+ uint32 hit = 0;
+ size_t hitPos = data->wpos();
+ *data << (uint8)0; // placeholder
+ for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && hit <= 255; ++ihit)
{
if ((*ihit).missCondition == SPELL_MISS_NONE) // Add only hits
{
*data << uint64(ihit->targetGUID);
m_channelTargetEffectMask |=ihit->effectMask;
+ ++hit;
}
}
- for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end(); ++ighit)
+ for (std::list<GOTargetInfo>::const_iterator ighit = m_UniqueGOTargetInfo.begin(); ighit != m_UniqueGOTargetInfo.end() && hit <= 255; ++ighit)
+ {
*data << uint64(ighit->targetGUID); // Always hits
+ ++hit;
+ }
- *data << (uint8)miss;
- for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit)
+ uint32 miss = 0;
+ size_t missPos = data->wpos();
+ *data << (uint8)0; // placeholder
+ for (std::list<TargetInfo>::const_iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end() && miss <= 255; ++ihit)
{
if (ihit->missCondition != SPELL_MISS_NONE) // Add only miss
{
@@ -4125,11 +4131,15 @@ void Spell::WriteSpellGoTargets(WorldPacket* data)
*data << uint8(ihit->missCondition);
if (ihit->missCondition == SPELL_MISS_REFLECT)
*data << uint8(ihit->reflectResult);
+ ++miss;
}
}
// Reset m_needAliveTargetMask for non channeled spell
if (!m_spellInfo->IsChanneled())
m_channelTargetEffectMask = 0;
+
+ data->put<uint8>(hitPos, (uint8)hit);
+ data->put<uint8>(missPos, (uint8)miss);
}
void Spell::SendLogExecute()
@@ -6915,12 +6925,6 @@ void Spell::InitEffectExecuteData(uint8 effIndex)
}
}
-void Spell::CleanupEffectExecuteData()
-{
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- m_effectExecuteData[i] = NULL;
-}
-
void Spell::CheckEffectExecuteData()
{
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
@@ -6936,6 +6940,7 @@ void Spell::LoadScripts()
{
std::list<SpellScript*>::iterator bitr = itr;
++itr;
+ delete (*bitr);
m_loadedScripts.erase(bitr);
continue;
}
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 1376b0fbd40..8be6e7241d6 100755
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -616,7 +616,6 @@ class Spell
// spell execution log
void InitEffectExecuteData(uint8 effIndex);
- void CleanupEffectExecuteData();
void CheckEffectExecuteData();
// Scripting system
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 7b3f9a1bef9..d37ff1465bd 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -361,7 +361,7 @@ bool SpellEffectInfo::IsAura() const
bool SpellEffectInfo::IsAura(AuraType aura) const
{
- return IsAura() && ApplyAuraName == aura;
+ return IsAura() && ApplyAuraName == uint32(aura);
}
bool SpellEffectInfo::IsTargetingArea() const
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index fa4b0ce3957..fea96cc80f3 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
+
#include "Chat.h"
#include "ScriptMgr.h"
#include "AccountMgr.h"
@@ -29,12 +29,12 @@
#include "TargetedMovementGenerator.h"
#include "WeatherMgr.h"
#include "ace/INET_Addr.h"
-
+
class misc_commandscript : public CommandScript
{
public:
misc_commandscript() : CommandScript("misc_commandscript") { }
-
+
ChatCommand* GetCommands() const
{
static ChatCommand groupCommandTable[] =
@@ -117,7 +117,7 @@ public:
};
return commandTable;
}
-
+
static bool HandleDevCommand(ChatHandler* handler, char const* args)
{
if (!*args)
@@ -128,28 +128,28 @@ public:
handler->GetSession()->SendNotification(LANG_DEV_OFF);
return true;
}
-
+
std::string argstr = (char*)args;
-
+
if (argstr == "on")
{
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
handler->GetSession()->SendNotification(LANG_DEV_ON);
return true;
}
-
+
if (argstr == "off")
{
handler->GetSession()->GetPlayer()->RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_DEVELOPER);
handler->GetSession()->SendNotification(LANG_DEV_OFF);
return true;
}
-
+
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
-
+
static bool HandleGPSCommand(ChatHandler* handler, char const* args)
{
WorldObject* object = NULL;
@@ -158,7 +158,7 @@ public:
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
object = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT | TYPEMASK_GAMEOBJECT);
-
+
if (!object)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
@@ -169,7 +169,7 @@ public:
else
{
object = handler->getSelectedUnit();
-
+
if (!object)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
@@ -177,35 +177,35 @@ public:
return false;
}
}
-
+
CellCoord cellCoord = Trinity::ComputeCellCoord(object->GetPositionX(), object->GetPositionY());
Cell cell(cellCoord);
-
+
uint32 zoneId, areaId;
object->GetZoneAndAreaId(zoneId, areaId);
-
+
MapEntry const* mapEntry = sMapStore.LookupEntry(object->GetMapId());
AreaTableEntry const* zoneEntry = GetAreaEntryByAreaID(zoneId);
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(areaId);
-
+
float zoneX = object->GetPositionX();
float zoneY = object->GetPositionY();
-
+
Map2ZoneCoordinates(zoneX, zoneY, zoneId);
-
+
Map const* map = object->GetMap();
float groundZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), MAX_HEIGHT);
float floorZ = map->GetHeight(object->GetPhaseMask(), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ());
-
+
GridCoord gridCoord = Trinity::ComputeGridCoord(object->GetPositionX(), object->GetPositionY());
-
+
// 63? WHY?
int gridX = 63 - gridCoord.x_coord;
int gridY = 63 - gridCoord.y_coord;
-
+
uint32 haveMap = Map::ExistMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
uint32 haveVMap = Map::ExistVMap(object->GetMapId(), gridX, gridY) ? 1 : 0;
-
+
if (haveVMap)
{
if (map->IsOutdoors(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ()))
@@ -215,7 +215,7 @@ public:
}
else
handler->PSendSysMessage("no VMAP available for area info");
-
+
handler->PSendSysMessage(LANG_MAP_POSITION,
object->GetMapId(), (mapEntry ? mapEntry->name[handler->GetSessionDbcLocale()] : "<unknown>"),
zoneId, (zoneEntry ? zoneEntry->area_name[handler->GetSessionDbcLocale()] : "<unknown>"),
@@ -224,16 +224,16 @@ public:
object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation(),
cell.GridX(), cell.GridY(), cell.CellX(), cell.CellY(), object->GetInstanceId(),
zoneX, zoneY, groundZ, floorZ, haveMap, haveVMap);
-
+
LiquidData liquidStatus;
ZLiquidStatus status = map->getLiquidStatus(object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), MAP_ALL_LIQUIDS, &liquidStatus);
-
+
if (status)
handler->PSendSysMessage(LANG_LIQUID_STATUS, liquidStatus.level, liquidStatus.depth_level, liquidStatus.entry, liquidStatus.type_flags, status);
-
+
return true;
}
-
+
static bool HandleAuraCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
@@ -243,16 +243,16 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
+
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId))
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, target, target);
-
+
return true;
}
-
+
static bool HandleUnAuraCommand(ChatHandler* handler, char const* args)
{
Unit* target = handler->getSelectedUnit();
@@ -262,21 +262,21 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
std::string argstr = args;
if (argstr == "all")
{
target->RemoveAllAuras();
return true;
}
-
+
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
if (!spellId)
return false;
-
+
target->RemoveAurasDueToSpell(spellId);
-
+
return true;
}
// Teleport to Player
@@ -287,7 +287,7 @@ public:
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
-
+
Player* _player = handler->GetSession()->GetPlayer();
if (target == _player || targetGuid == _player->GetGUID())
{
@@ -295,15 +295,15 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
std::string chrNameLink = handler->playerLink(targetName);
-
+
Map* map = target->GetMap();
if (map->IsBattlegroundOrArena())
{
@@ -317,7 +317,7 @@ public:
// if both players are in different bgs
else if (_player->GetBattlegroundId() && _player->GetBattlegroundId() != target->GetBattlegroundId())
_player->LeaveBattleground(false); // Note: should be changed so _player gets no Deserter debuff
-
+
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
_player->SetBattlegroundId(target->GetBattlegroundId(), target->GetBattlegroundTypeId());
@@ -350,7 +350,7 @@ public:
return false;
}
}
-
+
// if the player or the player's group is bound to another instance
// the player will not be bound to another one
InstancePlayerBind* bind = _player->GetBoundInstance(target->GetMapId(), target->GetDifficulty(map->IsRaid()));
@@ -363,15 +363,15 @@ public:
if (InstanceSave* save = sInstanceSaveMgr->GetInstanceSave(target->GetInstanceId()))
_player->BindToInstance(save, !save->CanReset());
}
-
+
if (map->IsRaid())
_player->SetRaidDifficulty(target->GetRaidDifficulty());
else
_player->SetDungeonDifficulty(target->GetDungeonDifficulty());
}
-
+
handler->PSendSysMessage(LANG_APPEARING_AT, chrNameLink.c_str());
-
+
// stop flight if need
if (_player->isInFlight())
{
@@ -381,11 +381,11 @@ public:
// save only in non-flight case
else
_player->SaveRecallPosition();
-
+
// to point to see at target with same orientation
float x, y, z;
target->GetContactPoint(_player, x, y, z);
-
+
_player->TeleportTo(target->GetMapId(), x, y, z, _player->GetAngle(target), TELE_TO_GM_MODE);
_player->SetPhaseMask(target->GetPhaseMask(), true);
}
@@ -394,18 +394,18 @@ public:
// check offline security
if (handler->HasLowerSecurity(NULL, targetGuid))
return false;
-
+
std::string nameLink = handler->playerLink(targetName);
-
+
handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str());
-
+
// to point where player stay (if loaded)
float x, y, z, o;
uint32 map;
bool in_flight;
if (!Player::LoadPositionFromDB(map, x, y, z, o, in_flight, targetGuid))
return false;
-
+
// stop flight if need
if (_player->isInFlight())
{
@@ -415,10 +415,10 @@ public:
// save only in non-flight case
else
_player->SaveRecallPosition();
-
+
_player->TeleportTo(map, x, y, z, _player->GetOrientation());
}
-
+
return true;
}
// Summon Player
@@ -429,7 +429,7 @@ public:
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
-
+
Player* _player = handler->GetSession()->GetPlayer();
if (target == _player || targetGuid == _player->GetGUID())
{
@@ -437,23 +437,23 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (target)
{
std::string nameLink = handler->playerLink(targetName);
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
if (target->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
-
+
Map* map = handler->GetSession()->GetPlayer()->GetMap();
-
+
if (map->IsBattlegroundOrArena())
{
// only allow if gm mode is on
@@ -466,7 +466,7 @@ public:
// if both players are in different bgs
else if (target->GetBattlegroundId() && handler->GetSession()->GetPlayer()->GetBattlegroundId() != target->GetBattlegroundId())
target->LeaveBattleground(false); // Note: should be changed so target gets no Deserter debuff
-
+
// all's well, set bg id
// when porting out from the bg, it will be reset to 0
target->SetBattlegroundId(handler->GetSession()->GetPlayer()->GetBattlegroundId(), handler->GetSession()->GetPlayer()->GetBattlegroundTypeId());
@@ -477,10 +477,10 @@ public:
else if (map->IsDungeon())
{
Map* map = target->GetMap();
-
+
if (map->Instanceable() && map->GetInstanceId() != map->GetInstanceId())
target->UnbindInstance(map->GetInstanceId(), target->GetDungeonDifficulty(), true);
-
+
// we are in instance, and can summon only player in our group with us as lead
if (!handler->GetSession()->GetPlayer()->GetGroup() || !target->GetGroup() ||
(target->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
@@ -492,11 +492,11 @@ public:
return false;
}
}
-
+
handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), "");
if (handler->needReportToTarget(target))
ChatHandler(target).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
-
+
// stop flight if need
if (target->isInFlight())
{
@@ -506,7 +506,7 @@ public:
// save only in non-flight case
else
target->SaveRecallPosition();
-
+
// before GM
float x, y, z;
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, target->GetObjectSize());
@@ -518,11 +518,11 @@ public:
// check offline security
if (handler->HasLowerSecurity(NULL, targetGuid))
return false;
-
+
std::string nameLink = handler->playerLink(targetName);
-
+
handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetTrinityString(LANG_OFFLINE));
-
+
// in point where GM stay
Player::SavePositionInDB(handler->GetSession()->GetPlayer()->GetMapId(),
handler->GetSession()->GetPlayer()->GetPositionX(),
@@ -532,7 +532,7 @@ public:
handler->GetSession()->GetPlayer()->GetZoneId(),
targetGuid);
}
-
+
return true;
}
// Summon group of player
@@ -541,25 +541,25 @@ public:
Player* target;
if (!handler->extractPlayerTarget((char*)args, &target))
return false;
-
+
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
Group* group = target->GetGroup();
-
+
std::string nameLink = handler->GetNameLink(target);
-
+
if (!group)
{
handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
-
+
Map* gmMap = handler->GetSession()->GetPlayer()->GetMap();
bool toInstance = gmMap->Instanceable();
-
+
// we are in instance, and can summon only player in our group with us as lead
if (toInstance && (
!handler->GetSession()->GetPlayer()->GetGroup() || (group->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID()) ||
@@ -570,31 +570,31 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
{
Player* player = itr->getSource();
-
+
if (!player || player == handler->GetSession()->GetPlayer() || !player->GetSession())
continue;
-
+
// check online security
if (handler->HasLowerSecurity(player, 0))
return false;
-
+
std::string plNameLink = handler->GetNameLink(player);
-
+
if (player->IsBeingTeleported() == true)
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (toInstance)
{
Map* playerMap = player->GetMap();
-
+
if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId())
{
// cannot summon from instance to instance
@@ -603,11 +603,11 @@ public:
return false;
}
}
-
+
handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), "");
if (handler->needReportToTarget(player))
ChatHandler(player).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str());
-
+
// stop flight if need
if (player->isInFlight())
{
@@ -617,39 +617,39 @@ public:
// save only in non-flight case
else
player->SaveRecallPosition();
-
+
// before GM
float x, y, z;
handler->GetSession()->GetPlayer()->GetClosePoint(x, y, z, player->GetObjectSize());
player->TeleportTo(handler->GetSession()->GetPlayer()->GetMapId(), x, y, z, player->GetOrientation());
}
-
+
return true;
}
-
+
static bool HandleCommandsCommand(ChatHandler* handler, char const* /*args*/)
{
handler->ShowHelpForCommand(handler->getCommandTable(), "");
return true;
}
-
+
static bool HandleDieCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* target = handler->getSelectedUnit();
-
+
if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (target->GetTypeId() == TYPEID_PLAYER)
{
if (handler->HasLowerSecurity((Player*)target, 0, false))
return false;
}
-
+
if (target->isAlive())
{
if (sWorld->getBoolConfig(CONFIG_DIE_COMMAND_MODE))
@@ -657,17 +657,17 @@ public:
else
handler->GetSession()->GetPlayer()->DealDamage(target, target->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
}
-
+
return true;
}
-
+
static bool HandleReviveCommand(ChatHandler* handler, char const* args)
{
Player* target;
uint64 targetGuid;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid))
return false;
-
+
if (target)
{
target->ResurrectPlayer(!AccountMgr::IsPlayerAccount(target->GetSession()->GetSecurity()) ? 1.0f : 0.5f);
@@ -677,14 +677,14 @@ public:
else
// will resurrected at login without corpse
sObjectAccessor->ConvertCorpseForPlayer(targetGuid);
-
+
return true;
}
-
+
static bool HandleDismountCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
-
+
// If player is not mounted, so go out :)
if (!player->IsMounted())
{
@@ -692,34 +692,34 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (player->isInFlight())
{
handler->SendSysMessage(LANG_YOU_IN_FLIGHT);
handler->SetSentErrorMessage(true);
return false;
}
-
+
player->Dismount();
player->RemoveAurasByType(SPELL_AURA_MOUNTED);
return true;
}
-
+
static bool HandleGUIDCommand(ChatHandler* handler, char const* /*args*/)
{
uint64 guid = handler->GetSession()->GetPlayer()->GetSelection();
-
+
if (guid == 0)
{
handler->SendSysMessage(LANG_NO_SELECTION);
handler->SetSentErrorMessage(true);
return false;
}
-
+
handler->PSendSysMessage(LANG_OBJECT_GUID, GUID_LOPART(guid), GUID_HIPART(guid));
return true;
}
-
+
static bool HandleHelpCommand(ChatHandler* handler, char const* args)
{
char const* cmd = strtok((char*)args, " ");
@@ -733,7 +733,7 @@ public:
if (!handler->ShowHelpForCommand(handler->getCommandTable(), cmd))
handler->SendSysMessage(LANG_NO_HELP_CMD);
}
-
+
return true;
}
// move item to other slot
@@ -741,35 +741,35 @@ public:
{
if (!*args)
return false;
-
+
char const* param1 = strtok((char*)args, " ");
if (!param1)
return false;
-
+
char const* param2 = strtok(NULL, " ");
if (!param2)
return false;
-
+
uint8 srcSlot = uint8(atoi(param1));
uint8 dstSlot = uint8(atoi(param2));
-
+
if (srcSlot == dstSlot)
return true;
-
+
if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, srcSlot, true))
return false;
-
+
if (!handler->GetSession()->GetPlayer()->IsValidPos(INVENTORY_SLOT_BAG_0, dstSlot, false))
return false;
-
+
uint16 src = ((INVENTORY_SLOT_BAG_0 << 8) | srcSlot);
uint16 dst = ((INVENTORY_SLOT_BAG_0 << 8) | dstSlot);
-
+
handler->GetSession()->GetPlayer()->SwapItem(src, dst);
-
+
return true;
}
-
+
static bool HandleCooldownCommand(ChatHandler* handler, char const* args)
{
Player* target = handler->getSelectedPlayer();
@@ -779,9 +779,9 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
std::string nameLink = handler->GetNameLink(target);
-
+
if (!*args)
{
target->RemoveAllSpellCooldown();
@@ -793,30 +793,30 @@ public:
uint32 spellIid = handler->extractSpellIdFromLink((char*)args);
if (!spellIid)
return false;
-
+
if (!sSpellMgr->GetSpellInfo(spellIid))
{
handler->PSendSysMessage(LANG_UNKNOWN_SPELL, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
handler->SetSentErrorMessage(true);
return false;
}
-
+
target->RemoveSpellCooldown(spellIid, true);
handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spellIid, target == handler->GetSession()->GetPlayer() ? handler->GetTrinityString(LANG_YOU) : nameLink.c_str());
}
return true;
}
-
+
static bool HandleGetDistanceCommand(ChatHandler* handler, char const* args)
{
WorldObject* obj = NULL;
-
+
if (*args)
{
uint64 guid = handler->extractGuidFromLink((char*)args);
if (guid)
obj = (WorldObject*)ObjectAccessor::GetObjectByTypeMask(*handler->GetSession()->GetPlayer(), guid, TYPEMASK_UNIT|TYPEMASK_GAMEOBJECT);
-
+
if (!obj)
{
handler->SendSysMessage(LANG_PLAYER_NOT_FOUND);
@@ -827,7 +827,7 @@ public:
else
{
obj = handler->getSelectedUnit();
-
+
if (!obj)
{
handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
@@ -835,7 +835,7 @@ public:
return false;
}
}
-
+
handler->PSendSysMessage(LANG_DISTANCE, handler->GetSession()->GetPlayer()->GetDistance(obj), handler->GetSession()->GetPlayer()->GetDistance2d(obj), handler->GetSession()->GetPlayer()->GetExactDist(obj), handler->GetSession()->GetPlayer()->GetExactDist2d(obj));
return true;
}
@@ -845,33 +845,33 @@ public:
Player* target;
if (!handler->extractPlayerTarget((char*)args, &target))
return false;
-
+
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
if (target->IsBeingTeleported())
{
handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->GetNameLink(target).c_str());
handler->SetSentErrorMessage(true);
return false;
}
-
+
// stop flight if need
if (target->isInFlight())
{
target->GetMotionMaster()->MovementExpired();
target->CleanupAfterTaxiFlight();
}
-
+
target->TeleportTo(target->m_recallMap, target->m_recallX, target->m_recallY, target->m_recallZ, target->m_recallO);
return true;
}
-
+
static bool HandleSaveCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
-
+
// save GM account without delay and output message
if (!AccountMgr::IsPlayerAccount(handler->GetSession()->GetSecurity()))
{
@@ -882,15 +882,15 @@ public:
handler->SendSysMessage(LANG_PLAYER_SAVED);
return true;
}
-
+
// save if the player has last been saved over 20 seconds ago
uint32 saveInterval = sWorld->getIntConfig(CONFIG_INTERVAL_SAVE);
if (saveInterval == 0 || (saveInterval > 20 * IN_MILLISECONDS && player->GetSaveTimer() <= saveInterval - 20 * IN_MILLISECONDS))
player->SaveToDB();
-
+
return true;
}
-
+
// Save all players in the world
static bool HandleSaveAllCommand(ChatHandler* handler, char const* /*args*/)
{
@@ -898,7 +898,7 @@ public:
handler->SendSysMessage(LANG_PLAYERS_SAVED);
return true;
}
-
+
// kick player
static bool HandleKickPlayerCommand(ChatHandler* handler, char const* args)
{
@@ -906,73 +906,73 @@ public:
std::string playerName;
if (!handler->extractPlayerTarget((char*)args, &target, NULL, &playerName))
return false;
-
+
if (handler->GetSession() && target == handler->GetSession()->GetPlayer())
{
handler->SendSysMessage(LANG_COMMAND_KICKSELF);
handler->SetSentErrorMessage(true);
return false;
}
-
+
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
else
handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
-
+
target->GetSession()->KickPlayer();
-
+
return true;
}
-
+
static bool HandleStartCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
-
+
if (player->isInFlight())
{
handler->SendSysMessage(LANG_YOU_IN_FLIGHT);
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (player->isInCombat())
{
handler->SendSysMessage(LANG_YOU_IN_COMBAT);
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (player->isDead() || player->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
{
// if player is dead and stuck, send ghost to graveyard
player->RepopAtGraveyard();
return true;
}
-
+
// cast spell Stuck
player->CastSpell(player, 7355, false);
return true;
}
-
+
static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
char* px = strtok((char*)args, " ");
if (!px)
return false;
-
+
uint32 graveyardId = uint32(atoi(px));
-
+
uint32 team;
-
+
char* px2 = strtok(NULL, " ");
-
+
if (!px2)
team = 0;
else if (strncmp(px2, "horde", 6) == 0)
@@ -981,20 +981,20 @@ public:
team = ALLIANCE;
else
return false;
-
+
WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(graveyardId);
-
+
if (!graveyard)
{
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
handler->SetSentErrorMessage(true);
return false;
}
-
+
Player* player = handler->GetSession()->GetPlayer();
-
+
uint32 zoneId = player->GetZoneId();
-
+
AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(zoneId);
if (!areaEntry || areaEntry->zone !=0)
{
@@ -1002,21 +1002,21 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (sObjectMgr->AddGraveYardLink(graveyardId, zoneId, team))
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId);
else
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId);
-
+
return true;
}
-
+
static bool HandleNearGraveCommand(ChatHandler* handler, char const* args)
{
uint32 team;
-
+
size_t argStr = strlen(args);
-
+
if (!*args)
team = 0;
else if (strncmp((char*)args, "horde", argStr) == 0)
@@ -1025,17 +1025,17 @@ public:
team = ALLIANCE;
else
return false;
-
+
Player* player = handler->GetSession()->GetPlayer();
uint32 zone_id = player->GetZoneId();
-
+
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveYard(
player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), team);
-
+
if (graveyard)
{
uint32 graveyardId = graveyard->ID;
-
+
GraveYardData const* data = sObjectMgr->FindGraveYardData(graveyardId, zone_id);
if (!data)
{
@@ -1043,45 +1043,45 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
team = data->team;
-
+
std::string team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_NOTEAM);
-
+
if (team == 0)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
else if (team == HORDE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
else if (team == ALLIANCE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
-
+
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id);
}
else
{
std::string team_name;
-
+
if (team == 0)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ANY);
else if (team == HORDE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_HORDE);
else if (team == ALLIANCE)
team_name = handler->GetTrinityString(LANG_COMMAND_GRAVEYARD_ALLIANCE);
-
+
if (team == ~uint32(0))
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAVEYARDS, zone_id);
else
handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str());
}
-
+
return true;
}
-
+
static bool HandleShowAreaCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
{
@@ -1089,30 +1089,30 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
int32 area = GetAreaFlagByAreaID(atoi((char*)args));
int32 offset = area / 32;
uint32 val = uint32((1 << (area % 32)));
-
+
if (area<0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields | val)));
-
+
handler->SendSysMessage(LANG_EXPLORE_AREA);
return true;
}
-
+
static bool HandleHideAreaCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
{
@@ -1120,45 +1120,45 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
int32 area = GetAreaFlagByAreaID(atoi((char*)args));
int32 offset = area / 32;
uint32 val = uint32((1 << (area % 32)));
-
+
if (area < 0 || offset >= PLAYER_EXPLORED_ZONES_SIZE)
{
handler->SendSysMessage(LANG_BAD_VALUE);
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint32 currFields = playerTarget->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset);
playerTarget->SetUInt32Value(PLAYER_EXPLORED_ZONES_1 + offset, uint32((currFields ^ val)));
-
+
handler->SendSysMessage(LANG_UNEXPLORE_AREA);
return true;
}
-
+
static bool HandleAddItemCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
uint32 itemId = 0;
-
+
if (args[0] == '[') // [name] manual form
{
char const* itemNameStr = strtok((char*)args, "]");
-
+
if (itemNameStr && itemNameStr[0])
{
std::string itemName = itemNameStr+1;
WorldDatabase.EscapeString(itemName);
-
+
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_ITEM_TEMPLATE_BY_NAME);
stmt->setString(0, itemName);
PreparedQueryResult result = WorldDatabase.Query(stmt);
-
+
if (!result)
{
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, itemNameStr+1);
@@ -1177,24 +1177,24 @@ public:
return false;
itemId = uint32(atol(id));
}
-
+
char const* ccount = strtok(NULL, " ");
-
+
int32 count = 1;
-
+
if (ccount)
count = strtol(ccount, NULL, 10);
-
+
if (count == 0)
count = 1;
-
+
Player* player = handler->GetSession()->GetPlayer();
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
playerTarget = player;
-
+
sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEM), itemId, count);
-
+
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemId);
if (!itemTemplate)
{
@@ -1202,7 +1202,7 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
// Subtract
if (count < 0)
{
@@ -1210,55 +1210,55 @@ public:
handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str());
return true;
}
-
+
// Adding items
uint32 noSpaceForCount = 0;
-
+
// check space and find places
ItemPosCountVec dest;
InventoryResult msg = playerTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
-
+
if (count == 0 || dest.empty()) // can't add any
{
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
handler->SetSentErrorMessage(true);
return false;
}
-
+
Item* item = playerTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
-
+
// remove binding (let GM give it to another player later)
if (player == playerTarget)
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
if (Item* item1 = player->GetItemByPos(itr->pos))
item1->SetBinding(false);
-
+
if (count > 0 && item)
{
player->SendNewItem(item, count, false, true);
if (player != playerTarget)
playerTarget->SendNewItem(item, count, true, false);
}
-
+
if (noSpaceForCount > 0)
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
-
+
return true;
}
-
+
static bool HandleAddItemSetCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
char const* id = handler->extractKeyFromLink((char*)args, "Hitemset"); // number or [name] Shift-click form |color|Hitemset:itemset_id|h[name]|h|r
if (!id)
return false;
-
+
uint32 itemSetId = atol(id);
-
+
// prevent generation all items with itemset field value '0'
if (itemSetId == 0)
{
@@ -1266,14 +1266,14 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
Player* player = handler->GetSession()->GetPlayer();
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
playerTarget = player;
-
+
sLog->outDebug(LOG_FILTER_GENERAL, handler->GetTrinityString(LANG_ADDITEMSET), itemSetId);
-
+
bool found = false;
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
@@ -1286,11 +1286,11 @@ public:
if (msg == EQUIP_ERR_OK)
{
Item* item = playerTarget->StoreNewItem(dest, itr->second.ItemId, true);
-
+
// remove binding (let GM give it to another player later)
if (player == playerTarget)
item->SetBinding(false);
-
+
player->SendNewItem(item, 1, false, true);
if (player != playerTarget)
playerTarget->SendNewItem(item, 1, true, false);
@@ -1302,28 +1302,28 @@ public:
}
}
}
-
+
if (!found)
{
handler->PSendSysMessage(LANG_NO_ITEMS_FROM_ITEMSET_FOUND, itemSetId);
handler->SetSentErrorMessage(true);
return false;
}
-
+
return true;
}
-
+
static bool HandleBankCommand(ChatHandler* handler, char const* /*args*/)
{
handler->GetSession()->SendShowBank(handler->GetSession()->GetPlayer()->GetGUID());
return true;
}
-
+
static bool HandleChangeWeather(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
// Weather is OFF
if (!sWorld->getBoolConfig(CONFIG_WEATHER))
{
@@ -1331,22 +1331,22 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
// *Change the weather of a cell
char const* px = strtok((char*)args, " ");
char const* py = strtok(NULL, " ");
-
+
if (!px || !py)
return false;
-
+
uint32 type = uint32(atoi(px)); //0 to 3, 0: fine, 1: rain, 2: snow, 3: sand
float grade = float(atof(py)); //0 to 1, sending -1 is instand good weather
-
+
Player* player = handler->GetSession()->GetPlayer();
uint32 zoneid = player->GetZoneId();
-
+
Weather* weather = WeatherMgr::FindWeather(zoneid);
-
+
if (!weather)
weather = WeatherMgr::AddWeather(zoneid);
if (!weather)
@@ -1355,12 +1355,12 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
weather->SetWeather(WeatherType(type), grade);
-
+
return true;
}
-
+
static bool HandleMaxSkillCommand(ChatHandler* handler, char const* /*args*/)
{
@@ -1371,25 +1371,25 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
// each skills that have max skill value dependent from level seted to current level max skill value
SelectedPlayer->UpdateSkillsToMaxSkillsForLevel();
return true;
}
-
+
static bool HandleSetSkillCommand(ChatHandler* handler, char const* args)
{
// number or [name] Shift-click form |color|Hskill:skill_id|h[name]|h|r
char const* skillStr = handler->extractKeyFromLink((char*)args, "Hskill");
if (!skillStr)
return false;
-
+
char const* levelStr = strtok(NULL, " ");
if (!levelStr)
return false;
-
+
char const* maxPureSkill = strtok(NULL, " ");
-
+
int32 skill = atoi(skillStr);
if (skill <= 0)
{
@@ -1397,9 +1397,9 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
int32 level = uint32(atol(levelStr));
-
+
Player* target = handler->getSelectedPlayer();
if (!target)
{
@@ -1407,7 +1407,7 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
SkillLineEntry const* skillLine = sSkillLineStore.LookupEntry(skill);
if (!skillLine)
{
@@ -1415,24 +1415,24 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
std::string tNameLink = handler->GetNameLink(target);
-
+
if (!target->GetSkillValue(skill))
{
handler->PSendSysMessage(LANG_SET_SKILL_ERROR, tNameLink.c_str(), skill, skillLine->name[handler->GetSessionDbcLocale()]);
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint16 max = maxPureSkill ? atol (maxPureSkill) : target->GetPureMaxSkillValue(skill);
-
+
if (level <= 0 || level > max || max <= 0)
return false;
-
+
target->SetSkill(skill, target->GetSkillStep(skill), level, max);
handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->name[handler->GetSessionDbcLocale()], tNameLink.c_str(), level, max);
-
+
return true;
}
// show info of player
@@ -1441,9 +1441,9 @@ public:
Player* target;
uint64 targetGuid;
std::string targetName;
-
+
uint32 parseGUID = MAKE_NEW_GUID(atol((char*)args), 0, HIGHGUID_PLAYER);
-
+
if (sObjectMgr->GetPlayerNameByGUID(parseGUID, targetName))
{
target = sObjectMgr->GetPlayerByLowGUID(parseGUID);
@@ -1451,7 +1451,7 @@ public:
}
else if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
-
+
uint32 accId = 0;
uint32 money = 0;
uint32 totalPlayerTime = 0;
@@ -1464,14 +1464,14 @@ public:
uint32 mapId;
uint32 areaId;
uint32 phase = 0;
-
+
// get additional information from Player object
if (target)
{
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
accId = target->GetSession()->GetAccountId();
money = target->GetMoney();
totalPlayerTime = target->GetTotalPlayedTime();
@@ -1490,14 +1490,14 @@ public:
// check offline security
if (handler->HasLowerSecurity(NULL, targetGuid))
return false;
-
+
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO);
stmt->setUInt32(0, GUID_LOPART(targetGuid));
PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
+
if (!result)
return false;
-
+
Field* fields = result->Fetch();
totalPlayerTime = fields[0].GetUInt32();
level = fields[1].GetUInt8();
@@ -1508,18 +1508,18 @@ public:
mapId = fields[6].GetUInt16();
areaId = fields[7].GetUInt16();
}
-
+
std::string userName = handler->GetTrinityString(LANG_ERROR);
std::string eMail = handler->GetTrinityString(LANG_ERROR);
std::string lastIp = handler->GetTrinityString(LANG_ERROR);
uint32 security = 0;
std::string lastLogin = handler->GetTrinityString(LANG_ERROR);
-
+
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO);
stmt->setInt32(0, int32(realmID));
stmt->setUInt32(1, accId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
-
+
if (result)
{
Field* fields = result->Fetch();
@@ -1527,26 +1527,26 @@ public:
security = fields[1].GetUInt8();
eMail = fields[2].GetString();
muteTime = fields[5].GetUInt64();
-
+
if (eMail.empty())
eMail = "-";
-
+
if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security))
{
lastIp = fields[3].GetString();
lastLogin = fields[4].GetString();
-
+
uint32 ip = inet_addr(lastIp.c_str());
#if TRINITY_ENDIAN == BIGENDIAN
EndianConvertReverse(ip);
#endif
-
+
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_IP2NATION_COUNTRY);
-
+
stmt->setUInt32(0, ip);
-
+
PreparedQueryResult result2 = WorldDatabase.Query(stmt);
-
+
if (result2)
{
Field* fields2 = result2->Fetch();
@@ -1561,14 +1561,14 @@ public:
lastLogin = "-";
}
}
-
+
std::string nameLink = handler->playerLink(targetName);
-
+
handler->PSendSysMessage(LANG_PINFO_ACCOUNT, (target ? "" : handler->GetTrinityString(LANG_OFFLINE)), nameLink.c_str(), GUID_LOPART(targetGuid), userName.c_str(), accId, eMail.c_str(), security, lastIp.c_str(), lastLogin.c_str(), latency);
-
+
std::string bannedby = "unknown";
std::string banreason = "";
-
+
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS);
stmt->setUInt32(0, accId);
PreparedQueryResult result2 = LoginDatabase.Query(stmt);
@@ -1578,7 +1578,7 @@ public:
stmt->setUInt32(0, GUID_LOPART(targetGuid));
result2 = CharacterDatabase.Query(stmt);
}
-
+
if (result2)
{
Field* fields = result2->Fetch();
@@ -1586,13 +1586,13 @@ public:
bannedby = fields[2].GetString();
banreason = fields[3].GetString();
}
-
+
if (muteTime > 0)
handler->PSendSysMessage(LANG_PINFO_MUTE, secsToTimeString(muteTime - time(NULL), true).c_str());
-
+
if (banTime >= 0)
handler->PSendSysMessage(LANG_PINFO_BAN, banTime > 0 ? secsToTimeString(banTime - time(NULL), true).c_str() : "permanently", bannedby.c_str(), banreason.c_str());
-
+
std::string raceStr, ClassStr;
switch (race)
{
@@ -1627,7 +1627,7 @@ public:
raceStr = "Draenei";
break;
}
-
+
switch (Class)
{
case CLASS_WARRIOR:
@@ -1661,30 +1661,30 @@ public:
ClassStr = "Druid";
break;
}
-
+
std::string timeStr = secsToTimeString(totalPlayerTime, true, true);
uint32 gold = money /GOLD;
uint32 silv = (money % GOLD) / SILVER;
uint32 copp = (money % GOLD) % SILVER;
handler->PSendSysMessage(LANG_PINFO_LEVEL, raceStr.c_str(), ClassStr.c_str(), timeStr.c_str(), level, gold, silv, copp);
-
+
// Add map, zone, subzone and phase to output
int locale = handler->GetSessionDbcLocale();
std::string areaName = "<unknown>";
std::string zoneName = "";
-
+
MapEntry const* map = sMapStore.LookupEntry(mapId);
-
+
AreaTableEntry const* area = GetAreaEntryByAreaID(areaId);
if (area)
{
areaName = area->area_name[locale];
-
+
AreaTableEntry const* zone = GetAreaEntryByAreaID(area->zone);
if (zone)
zoneName = zone->area_name[locale];
}
-
+
if (target)
{
if (!zoneName.empty())
@@ -1694,14 +1694,14 @@ public:
}
else
handler->PSendSysMessage(LANG_PINFO_MAP_OFFLINE, map->name[locale], areaName.c_str());
-
+
return true;
}
-
+
static bool HandleRespawnCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
-
+
// accept only explicitly selected target (not implicitly self targeting case)
Unit* target = handler->getSelectedUnit();
if (player->GetSelection() && target)
@@ -1712,22 +1712,22 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (target->isDead())
target->ToCreature()->Respawn();
return true;
}
-
+
CellCoord p(Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY()));
Cell cell(p);
cell.SetNoCreate();
-
+
Trinity::RespawnDo u_do;
Trinity::WorldObjectWorker<Trinity::RespawnDo> worker(player, u_do);
-
+
TypeContainerVisitor<Trinity::WorldObjectWorker<Trinity::RespawnDo>, GridTypeMapContainer > obj_worker(worker);
cell.Visit(p, obj_worker, *player->GetMap(), *player, player->GetGridActivationRange());
-
+
return true;
}
// mute player for some times
@@ -1738,33 +1738,33 @@ public:
handler->extractOptFirstArg((char*)args, &nameStr, &delayStr);
if (!delayStr)
return false;
-
+
char const* muteReason = strtok(NULL, "\r");
std::string muteReasonStr = "No reason";
if (muteReason != NULL)
muteReasonStr = muteReason;
-
+
Player* target;
uint64 targetGuid;
std::string targetName;
if (!handler->extractPlayerTarget(nameStr, &target, &targetGuid, &targetName))
return false;
-
+
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
-
+
// find only player from same account if any
if (!target)
if (WorldSession* session = sWorld->FindSession(accountId))
target = session->GetPlayer();
-
+
uint32 notSpeakTime = uint32(atoi(delayStr));
-
+
// must have strong lesser security level
if (handler->HasLowerSecurity (target, targetGuid, true))
return false;
-
+
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
-
+
if (target)
{
// Target is online, mute will be in effect right away.
@@ -1779,16 +1779,16 @@ public:
int32 muteTime = -int32(notSpeakTime * MINUTE);
stmt->setInt64(0, muteTime);
}
-
+
stmt->setUInt32(1, accountId);
LoginDatabase.Execute(stmt);
std::string nameLink = handler->playerLink(targetName);
-
+
handler->PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, nameLink.c_str(), notSpeakTime, muteReasonStr.c_str());
-
+
return true;
}
-
+
// unmute player
static bool HandleUnmuteCommand(ChatHandler* handler, char const* args)
{
@@ -1797,18 +1797,18 @@ public:
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
-
+
uint32 accountId = target ? target->GetSession()->GetAccountId() : sObjectMgr->GetPlayerAccountIdByGUID(targetGuid);
-
+
// find only player from same account if any
if (!target)
if (WorldSession* session = sWorld->FindSession(accountId))
target = session->GetPlayer();
-
+
// must have strong lesser security level
if (handler->HasLowerSecurity (target, targetGuid, true))
return false;
-
+
if (target)
{
if (target->CanSpeak())
@@ -1817,25 +1817,25 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
target->GetSession()->m_muteTime = 0;
}
-
+
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
stmt->setInt64(0, 0);
stmt->setUInt32(1, accountId);
LoginDatabase.Execute(stmt);
-
+
if (target)
ChatHandler(target).PSendSysMessage(LANG_YOUR_CHAT_ENABLED);
-
+
std::string nameLink = handler->playerLink(targetName);
-
+
handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, nameLink.c_str());
-
+
return true;
}
-
+
static bool HandleMovegensCommand(ChatHandler* handler, char const* /*args*/)
{
@@ -1846,13 +1846,13 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUIDLow());
-
+
MotionMaster* motionMaster = unit->GetMotionMaster();
float x, y, z;
motionMaster->GetDestination(x, y, z);
-
+
for (uint8 i = 0; i < MAX_MOTION_SLOT; ++i)
{
MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(i);
@@ -1861,7 +1861,7 @@ public:
handler->SendSysMessage("Empty");
continue;
}
-
+
switch (movementGenerator->GetMovementGeneratorType())
{
case IDLE_MOTION_TYPE:
@@ -1886,7 +1886,7 @@ public:
target = static_cast<ChaseMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
else
target = static_cast<ChaseMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
-
+
if (!target)
handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
else if (target->GetTypeId() == TYPEID_PLAYER)
@@ -1902,7 +1902,7 @@ public:
target = static_cast<FollowMovementGenerator<Player> const*>(movementGenerator)->GetTarget();
else
target = static_cast<FollowMovementGenerator<Creature> const*>(movementGenerator)->GetTarget();
-
+
if (!target)
handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
else if (target->GetTypeId() == TYPEID_PLAYER)
@@ -1953,7 +1953,7 @@ public:
char const* newFlagStr = strtok((char*)args, " ");
if (!newFlagStr)
return false;
-
+
Creature* caster = handler->getSelectedCreature();
if (!caster)
{
@@ -1961,19 +1961,19 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
Player* player = handler->GetSession()->GetPlayer();
-
+
caster->GetMotionMaster()->MovePoint(0, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
-
+
return true;
}
-
+
static bool HandleDamageCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
Unit* target = handler->getSelectedUnit();
if (!target || !handler->GetSession()->GetPlayer()->GetSelection())
{
@@ -1981,28 +1981,28 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (target->GetTypeId() == TYPEID_PLAYER)
{
if (handler->HasLowerSecurity((Player*)target, 0, false))
return false;
}
-
+
if (!target->isAlive())
return true;
-
+
char* damageStr = strtok((char*)args, " ");
if (!damageStr)
return false;
-
+
int32 damage_int = atoi((char*)damageStr);
if (damage_int <= 0)
return true;
-
+
uint32 damage = damage_int;
-
+
char* schoolStr = strtok((char*)NULL, " ");
-
+
// flat melee damage without resistence/etc reduction
if (!schoolStr)
{
@@ -2011,52 +2011,52 @@ public:
handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, SPELL_SCHOOL_MASK_NORMAL, damage, 0, 0, VICTIMSTATE_HIT, 0);
return true;
}
-
+
uint32 school = schoolStr ? atoi((char*)schoolStr) : SPELL_SCHOOL_NORMAL;
if (school >= MAX_SPELL_SCHOOL)
return false;
-
+
SpellSchoolMask schoolmask = SpellSchoolMask(1 << school);
-
+
if (Unit::IsDamageReducedByArmor(schoolmask))
damage = handler->GetSession()->GetPlayer()->CalcArmorReducedDamage(target, damage, NULL, BASE_ATTACK);
-
+
char* spellStr = strtok((char*)NULL, " ");
-
+
// melee damage by specific school
if (!spellStr)
{
uint32 absorb = 0;
uint32 resist = 0;
-
+
handler->GetSession()->GetPlayer()->CalcAbsorbResist(target, schoolmask, SPELL_DIRECT_DAMAGE, damage, &absorb, &resist);
-
+
if (damage <= absorb + resist)
return true;
-
+
damage -= absorb + resist;
-
+
handler->GetSession()->GetPlayer()->DealDamageMods(target, damage, &absorb);
handler->GetSession()->GetPlayer()->DealDamage(target, damage, NULL, DIRECT_DAMAGE, schoolmask, NULL, false);
handler->GetSession()->GetPlayer()->SendAttackStateUpdate (HITINFO_AFFECTS_VICTIM, target, 1, schoolmask, damage, absorb, resist, VICTIMSTATE_HIT, 0);
return true;
}
-
+
// non-melee damage
-
+
// number or [name] Shift-click form |color|Hspell:spell_id|h[name]|h|r or Htalent form
uint32 spellid = handler->extractSpellIdFromLink((char*)args);
if (!spellid || !sSpellMgr->GetSpellInfo(spellid))
return false;
-
+
handler->GetSession()->GetPlayer()->SpellNonMeleeDamageLog(target, spellid, damage);
return true;
}
-
+
static bool HandleCombatStopCommand(ChatHandler* handler, char const* args)
{
Player* target = NULL;
-
+
if (args && strlen(args) > 0)
{
target = sObjectAccessor->FindPlayerByName(args);
@@ -2067,48 +2067,48 @@ public:
return false;
}
}
-
+
if (!target)
{
if (!handler->extractPlayerTarget((char*)args, &target))
return false;
}
-
+
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
target->CombatStop();
target->getHostileRefManager().deleteReferences();
return true;
}
-
+
static bool HandleFlushArenaPointsCommand(ChatHandler* /*handler*/, char const* /*args*/)
{
sArenaTeamMgr->DistributeArenaPoints();
return true;
}
-
+
static bool HandleRepairitemsCommand(ChatHandler* handler, char const* args)
{
Player* target;
if (!handler->extractPlayerTarget((char*)args, &target))
return false;
-
+
// check online security
if (handler->HasLowerSecurity(target, 0))
return false;
-
+
// Repair items
target->DurabilityRepairAll(false, 0, false);
-
+
handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, handler->GetNameLink(target).c_str());
if (handler->needReportToTarget(target))
ChatHandler(target).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, handler->GetNameLink().c_str());
-
+
return true;
}
-
+
// Send mail by command
static bool HandleSendMailCommand(ChatHandler* handler, char const* args)
{
@@ -2118,37 +2118,37 @@ public:
std::string targetName;
if (!handler->extractPlayerTarget((char*)args, &target, &targetGuid, &targetName))
return false;
-
+
char* tail1 = strtok(NULL, "");
if (!tail1)
return false;
-
+
char const* msgSubject = handler->extractQuotedArg(tail1);
if (!msgSubject)
return false;
-
+
char* tail2 = strtok(NULL, "");
if (!tail2)
return false;
-
+
char const* msgText = handler->extractQuotedArg(tail2);
if (!msgText)
return false;
-
+
// msgSubject, msgText isn't NUL after prev. check
std::string subject = msgSubject;
std::string text = msgText;
-
+
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
+
//- TODO: Fix poor design
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft(subject, text)
.SendMailTo(trans, MailReceiver(target, GUID_LOPART(targetGuid)), sender);
-
+
CharacterDatabase.CommitTransaction(trans);
-
+
std::string nameLink = handler->playerLink(targetName);
handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
return true;
@@ -2162,49 +2162,49 @@ public:
std::string receiverName;
if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
return false;
-
+
char* tail1 = strtok(NULL, "");
if (!tail1)
return false;
-
+
char const* msgSubject = handler->extractQuotedArg(tail1);
if (!msgSubject)
return false;
-
+
char* tail2 = strtok(NULL, "");
if (!tail2)
return false;
-
+
char const* msgText = handler->extractQuotedArg(tail2);
if (!msgText)
return false;
-
+
// msgSubject, msgText isn't NUL after prev. check
std::string subject = msgSubject;
std::string text = msgText;
-
+
// extract items
typedef std::pair<uint32, uint32> ItemPair;
typedef std::list< ItemPair > ItemPairs;
ItemPairs items;
-
+
// get all tail string
char* tail = strtok(NULL, "");
-
+
// get from tail next item str
while (char* itemStr = strtok(tail, " "))
{
// and get new tail
tail = strtok(NULL, "");
-
+
// parse item str
char const* itemIdStr = strtok(itemStr, ":");
char const* itemCountStr = strtok(NULL, " ");
-
+
uint32 itemId = atoi(itemIdStr);
if (!itemId)
return false;
-
+
ItemTemplate const* item_proto = sObjectMgr->GetItemTemplate(itemId);
if (!item_proto)
{
@@ -2212,7 +2212,7 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint32 itemCount = itemCountStr ? atoi(itemCountStr) : 1;
if (itemCount < 1 || (item_proto->MaxCount > 0 && itemCount > uint32(item_proto->MaxCount)))
{
@@ -2220,15 +2220,15 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
while (itemCount > item_proto->GetMaxStackSize())
{
items.push_back(ItemPair(itemId, item_proto->GetMaxStackSize()));
itemCount -= item_proto->GetMaxStackSize();
}
-
+
items.push_back(ItemPair(itemId, itemCount));
-
+
if (items.size() > MAX_MAIL_ITEMS)
{
handler->PSendSysMessage(LANG_COMMAND_MAIL_ITEMS_LIMIT, MAX_MAIL_ITEMS);
@@ -2236,15 +2236,15 @@ public:
return false;
}
}
-
+
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
+
// fill mail
MailDraft draft(subject, text);
-
+
SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
+
for (ItemPairs::const_iterator itr = items.begin(); itr != items.end(); ++itr)
{
if (Item* item = Item::CreateItem(itr->first, itr->second, handler->GetSession() ? handler->GetSession()->GetPlayer() : 0))
@@ -2253,10 +2253,10 @@ public:
draft.AddItem(item);
}
}
-
+
draft.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
CharacterDatabase.CommitTransaction(trans);
-
+
std::string nameLink = handler->playerLink(receiverName);
handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
return true;
@@ -2265,49 +2265,49 @@ public:
static bool HandleSendMoneyCommand(ChatHandler* handler, char const* args)
{
/// format: name "subject text" "mail text" money
-
+
Player* receiver;
uint64 receiverGuid;
std::string receiverName;
if (!handler->extractPlayerTarget((char*)args, &receiver, &receiverGuid, &receiverName))
return false;
-
+
char* tail1 = strtok(NULL, "");
if (!tail1)
return false;
-
+
char* msgSubject = handler->extractQuotedArg(tail1);
if (!msgSubject)
return false;
-
+
char* tail2 = strtok(NULL, "");
if (!tail2)
return false;
-
+
char* msgText = handler->extractQuotedArg(tail2);
if (!msgText)
return false;
-
+
char* moneyStr = strtok(NULL, "");
int32 money = moneyStr ? atoi(moneyStr) : 0;
if (money <= 0)
return false;
-
+
// msgSubject, msgText isn't NUL after prev. check
std::string subject = msgSubject;
std::string text = msgText;
-
+
// from console show not existed sender
MailSender sender(MAIL_NORMAL, handler->GetSession() ? handler->GetSession()->GetPlayer()->GetGUIDLow() : 0, MAIL_STATIONERY_GM);
-
+
SQLTransaction trans = CharacterDatabase.BeginTransaction();
-
+
MailDraft(subject, text)
.AddMoney(money)
.SendMailTo(trans, MailReceiver(receiver, GUID_LOPART(receiverGuid)), sender);
-
+
CharacterDatabase.CommitTransaction(trans);
-
+
std::string nameLink = handler->playerLink(receiverName);
handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str());
return true;
@@ -2319,11 +2319,11 @@ public:
Player* player;
if (!handler->extractPlayerTarget((char*)args, &player))
return false;
-
+
char* msgStr = strtok(NULL, "");
if (!msgStr)
return false;
-
+
///- Check that he is not logging out.
if (player->GetSession()->isLogingOut())
{
@@ -2331,31 +2331,31 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
/// - Send the message
// Use SendAreaTriggerMessage for fastest delivery.
player->GetSession()->SendAreaTriggerMessage("%s", msgStr);
player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r");
-
+
// Confirmation message
std::string nameLink = handler->GetNameLink(player);
handler->PSendSysMessage(LANG_SENDMESSAGE, nameLink.c_str(), msgStr);
-
+
return true;
}
-
+
static bool HandleCreatePetCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
Creature* creatureTarget = handler->getSelectedCreature();
-
+
if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
{
handler->PSendSysMessage(LANG_SELECT_CREATURE);
handler->SetSentErrorMessage(true);
return false;
}
-
+
CreatureTemplate const* creatrueTemplate = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
// Creatures with family 0 crashes the server
if (!creatrueTemplate->family)
@@ -2364,14 +2364,14 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
if (player->GetPetGUID())
{
handler->PSendSysMessage("You already have a pet");
handler->SetSentErrorMessage(true);
return false;
}
-
+
// Everything looks OK, create new pet
Pet* pet = new Pet(player, HUNTER_PET);
if (!pet->CreateBaseAtCreature(creatureTarget))
@@ -2380,14 +2380,14 @@ public:
handler->PSendSysMessage("Error 1");
return false;
}
-
+
creatureTarget->setDeathState(JUST_DIED);
creatureTarget->RemoveCorpse();
creatureTarget->SetHealth(0); // just for nice GM-mode view
-
+
pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
-
+
if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
{
sLog->outError(LOG_FILTER_GENERAL, "InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
@@ -2395,47 +2395,47 @@ public:
delete pet;
return false;
}
-
+
// prepare visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);
-
+
pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
pet->InitPetCreateSpells();
pet->SetFullHealth();
-
+
pet->GetMap()->AddToMap(pet->ToCreature());
-
+
// visual effect for levelup
pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());
-
+
player->SetMinion(pet, true);
pet->SavePetToDB(PET_SAVE_AS_CURRENT);
player->PetSpellInitialize();
-
+
return true;
}
-
+
static bool HandlePetLearnCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
Player* player = handler->GetSession()->GetPlayer();
Pet* pet = player->GetPet();
-
+
if (!pet)
{
handler->PSendSysMessage("You have no pet");
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
+
if (!spellId || !sSpellMgr->GetSpellInfo(spellId))
return false;
-
+
// Check if pet already has it
if (pet->HasSpell(spellId))
{
@@ -2443,7 +2443,7 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
// Check if spell is valid
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo || !SpellMgr::IsSpellValid(spellInfo))
@@ -2452,18 +2452,18 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
pet->learnSpell(spellId);
-
+
handler->PSendSysMessage("Pet has learned spell %u", spellId);
return true;
}
-
+
static bool HandlePetUnlearnCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
Player* player = handler->GetSession()->GetPlayer();
Pet* pet = player->GetPet();
if (!pet)
@@ -2472,17 +2472,17 @@ public:
handler->SetSentErrorMessage(true);
return false;
}
-
+
uint32 spellId = handler->extractSpellIdFromLink((char*)args);
-
+
if (pet->HasSpell(spellId))
pet->removeSpell(spellId, false);
else
handler->PSendSysMessage("Pet doesn't have that spell");
-
+
return true;
}
-
+
static bool HandleFreezeCommand(ChatHandler* handler, char const* args)
{
std::string name;
@@ -2503,31 +2503,31 @@ public:
normalizePlayerName(name);
player = sObjectAccessor->FindPlayerByName(name.c_str());
}
-
+
if (!player)
{
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
return true;
}
-
+
if (player == handler->GetSession()->GetPlayer())
{
handler->SendSysMessage(LANG_COMMAND_FREEZE_ERROR);
return true;
}
-
+
// effect
if (player && (player != handler->GetSession()->GetPlayer()))
{
handler->PSendSysMessage(LANG_COMMAND_FREEZE, name.c_str());
-
+
// stop combat + make player unattackable + duel stop + stop some spells
player->setFaction(35);
player->CombatStop();
if (player->IsNonMeleeSpellCasted(true))
player->InterruptNonMeleeSpells(true);
player->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-
+
// if player class = hunter || warlock remove pet if alive
if ((player->getClass() == CLASS_HUNTER) || (player->getClass() == CLASS_WARLOCK))
{
@@ -2539,23 +2539,23 @@ public:
player->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
}
}
-
+
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(9454))
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player);
-
+
// save player
player->SaveToDB();
}
-
+
return true;
}
-
+
static bool HandleUnFreezeCommand(ChatHandler* handler, char const*args)
{
std::string name;
Player* player;
char* targetName = strtok((char*)args, " "); // Get entered name
-
+
if (targetName)
{
name = targetName;
@@ -2568,18 +2568,18 @@ public:
if (player)
name = player->GetName();
}
-
+
if (player)
{
handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
-
+
// Reset player faction + allow combat + allow duels
player->setFactionForRace(player->getRace());
player->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
-
+
// Remove Freeze spell (allowing movement and spells)
player->RemoveAurasDueToSpell(9454);
-
+
// Save player
player->SaveToDB();
}
@@ -2591,21 +2591,21 @@ public:
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_BY_NAME);
stmt->setString(0, name);
PreparedQueryResult result = CharacterDatabase.Query(stmt);
-
+
if (!result)
{
handler->SendSysMessage(LANG_COMMAND_FREEZE_WRONG);
return true;
}
-
+
// If player found: delete his freeze aura
Field* fields = result->Fetch();
uint32 lowGuid = fields[0].GetUInt32();
-
+
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN);
stmt->setUInt32(0, lowGuid);
CharacterDatabase.Execute(stmt);
-
+
handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, name.c_str());
return true;
}
@@ -2615,10 +2615,10 @@ public:
return true;
}
}
-
+
return true;
}
-
+
static bool HandleListFreezeCommand(ChatHandler* handler, char const* /*args*/)
{
// Get names from DB
@@ -2629,10 +2629,10 @@ public:
handler->SendSysMessage(LANG_COMMAND_NO_FROZEN_PLAYERS);
return true;
}
-
+
// Header of the names
handler->PSendSysMessage(LANG_COMMAND_LIST_FREEZE);
-
+
// Output of the results
do
{
@@ -2641,120 +2641,120 @@ public:
handler->PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str());
}
while (result->NextRow());
-
+
return true;
}
-
+
static bool HandleGroupLeaderCommand(ChatHandler* handler, char const* args)
{
Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* nameStr = strtok((char*)args, " ");
-
+
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
if (group && group->GetLeaderGUID() != guid)
{
group->ChangeLeader(guid);
group->SendUpdate();
}
-
+
return true;
}
-
+
static bool HandleGroupDisbandCommand(ChatHandler* handler, char const* args)
{
Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* nameStr = strtok((char*)args, " ");
-
+
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid))
if (group)
group->Disband();
-
+
return true;
}
-
+
static bool HandleGroupRemoveCommand(ChatHandler* handler, char const* args)
{
Player* player = NULL;
Group* group = NULL;
uint64 guid = 0;
char* nameStr = strtok((char*)args, " ");
-
+
if (handler->GetPlayerGroupAndGUIDByName(nameStr, player, group, guid, true))
if (group)
group->RemoveMember(guid);
-
+
return true;
}
-
+
static bool HandlePlayAllCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
-
+
uint32 soundId = atoi((char*)args);
-
+
if (!sSoundEntriesStore.LookupEntry(soundId))
{
handler->PSendSysMessage(LANG_SOUND_NOT_EXIST, soundId);
handler->SetSentErrorMessage(true);
return false;
}
-
+
WorldPacket data(SMSG_PLAY_SOUND, 4);
data << uint32(soundId) << handler->GetSession()->GetPlayer()->GetGUID();
sWorld->SendGlobalMessage(&data);
-
+
handler->PSendSysMessage(LANG_COMMAND_PLAYED_TO_ALL, soundId);
return true;
}
-
+
static bool HandlePossessCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* unit = handler->getSelectedUnit();
if (!unit)
return false;
-
+
handler->GetSession()->GetPlayer()->CastSpell(unit, 530, true);
return true;
}
-
+
static bool HandleUnPossessCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* unit = handler->getSelectedUnit();
if (!unit)
unit = handler->GetSession()->GetPlayer();
-
+
unit->RemoveCharmAuras();
-
+
return true;
}
-
+
static bool HandleBindSightCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* unit = handler->getSelectedUnit();
if (!unit)
return false;
-
+
handler->GetSession()->GetPlayer()->CastSpell(unit, 6277, true);
return true;
}
-
+
static bool HandleUnbindSightCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
-
+
if (player->isPossessing())
return false;
-
+
player->StopCastingBindSight();
return true;
}
};
-
+
void AddSC_misc_commandscript()
{
new misc_commandscript();
diff --git a/src/server/scripts/Northrend/dragonblight.cpp b/src/server/scripts/Northrend/dragonblight.cpp
index 1f1d24453ee..a26ee4e9270 100644
--- a/src/server/scripts/Northrend/dragonblight.cpp
+++ b/src/server/scripts/Northrend/dragonblight.cpp
@@ -190,7 +190,7 @@ class npc_wyrmrest_defender : public CreatureScript
npc_wyrmrest_defender() : CreatureScript("npc_wyrmrest_defender") { }
bool OnGossipHello(Player* player, Creature* creature)
- {
+ {
if (player->GetQuestStatus(QUEST_DEFENDING_WYRMREST_TEMPLE) == QUEST_STATUS_INCOMPLETE)
{
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_ITEM_1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
diff --git a/src/server/scripts/Northrend/storm_peaks.cpp b/src/server/scripts/Northrend/storm_peaks.cpp
index 60c289dc8de..976a6e5dba5 100644
--- a/src/server/scripts/Northrend/storm_peaks.cpp
+++ b/src/server/scripts/Northrend/storm_peaks.cpp
@@ -20,6 +20,7 @@
#include "ScriptedGossip.h"
#include "ScriptedEscortAI.h"
#include "Vehicle.h"
+#include "CombatAI.h"
/*######
## npc_agnetta_tyrsdottar
@@ -131,132 +132,6 @@ public:
}
};
-/*######
-## npc_thorim
-######*/
-
-#define GOSSIP_HN "Thorim?"
-#define GOSSIP_SN1 "Can you tell me what became of Sif?"
-#define GOSSIP_SN2 "He did more than that, Thorim. He controls Ulduar now."
-#define GOSSIP_SN3 "It needn't end this way."
-
-enum eThorim
-{
- QUEST_SIBLING_RIVALRY = 13064,
- NPC_THORIM = 29445,
- GOSSIP_TEXTID_THORIM1 = 13799,
- GOSSIP_TEXTID_THORIM2 = 13801,
- GOSSIP_TEXTID_THORIM3 = 13802,
- GOSSIP_TEXTID_THORIM4 = 13803
-};
-
-class npc_thorim : public CreatureScript
-{
-public:
- npc_thorim() : CreatureScript("npc_thorim") { }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (creature->isQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (player->GetQuestStatus(QUEST_SIBLING_RIVALRY) == QUEST_STATUS_INCOMPLETE) {
- player->ADD_GOSSIP_ITEM(0, GOSSIP_HN, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM1, creature->GetGUID());
- return true;
- }
- return false;
- }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(0, GOSSIP_SN1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM2, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->ADD_GOSSIP_ITEM(0, GOSSIP_SN2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM3, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->ADD_GOSSIP_ITEM(0, GOSSIP_SN3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_THORIM4, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+4:
- player->CLOSE_GOSSIP_MENU();
- player->CompleteQuest(QUEST_SIBLING_RIVALRY);
- break;
- }
- return true;
- }
-};
-
-/*######
-## npc_loklira_crone
-######*/
-
-#define GOSSIP_LOKLIRACRONE "Tell me about this proposal"
-#define GOSSIP_LOKLIRACRONE1 "What happened then?"
-#define GOSSIP_LOKLIRACRONE2 "You want me to take part in the Hyldsmeet to end the war?"
-#define GOSSIP_LOKLIRACRONE3 "Very well. I'll take part in this competition."
-
-enum eLokliraCrone
-{
- QUEST_HYLDSMEET = 12970,
-
- GOSSIP_TEXTID_LOK1 = 13778,
- GOSSIP_TEXTID_LOK2 = 13779,
- GOSSIP_TEXTID_LOK3 = 13780
-};
-
-class npc_loklira_crone : public CreatureScript
-{
-public:
- npc_loklira_crone() : CreatureScript("npc_loklira_crone") { }
-
- bool OnGossipHello(Player* player, Creature* creature)
- {
- if (creature->isQuestGiver())
- player->PrepareQuestMenu(creature->GetGUID());
-
- if (player->GetQuestStatus(QUEST_HYLDSMEET) == QUEST_STATUS_INCOMPLETE)
- {
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1);
- player->SEND_GOSSIP_MENU(player->GetGossipTextId(creature), creature->GetGUID());
- return true;
- }
- return false;
- }
-
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
- {
- player->PlayerTalkClass->ClearMenus();
- switch (action)
- {
- case GOSSIP_ACTION_INFO_DEF+1:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+2);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK1, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+2:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+3);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK2, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+3:
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, GOSSIP_LOKLIRACRONE3, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+4);
- player->SEND_GOSSIP_MENU(GOSSIP_TEXTID_LOK3, creature->GetGUID());
- break;
- case GOSSIP_ACTION_INFO_DEF+4:
- player->CLOSE_GOSSIP_MENU();
- player->CompleteQuest(QUEST_HYLDSMEET);
- break;
- }
- return true;
- }
-};
-
/////////////////////
///npc_injured_goblin
/////////////////////
@@ -409,14 +284,12 @@ public:
## npc_brunnhildar_prisoner
######*/
-enum brunhildar {
- NPC_QUEST_GIVER = 29592,
-
+enum BrunnhildarPrisoner {
SPELL_ICE_PRISON = 54894,
- SPELL_KILL_CREDIT_PRISONER = 55144,
- SPELL_KILL_CREDIT_DRAKE = 55143,
- SPELL_SUMMON_LIBERATED = 55073,
- SPELL_ICE_LANCE = 55046
+ SPELL_ICE_LANCE = 55046,
+ SPELL_FREE_PRISONER = 55048,
+ SPELL_RIDE_DRAKE = 55074,
+ SPELL_SHARD_IMPACT = 55047
};
class npc_brunnhildar_prisoner : public CreatureScript
@@ -428,129 +301,169 @@ public:
{
npc_brunnhildar_prisonerAI(Creature* creature) : ScriptedAI(creature) {}
- uint64 drakeGUID;
- uint16 enter_timer;
- bool hasEmptySeats;
+ bool freed;
void Reset()
{
+ freed = false;
me->CastSpell(me, SPELL_ICE_PRISON, true);
- enter_timer = 0;
- drakeGUID = 0;
- hasEmptySeats = false;
}
- void UpdateAI(const uint32 diff)
+ void JustRespawned()
{
- //TODO: not good script
- if (!drakeGUID)
+ Reset();
+ }
+
+ void UpdateAI(const uint32 /*diff*/)
+ {
+ if (!freed)
return;
- Creature* drake = Unit::GetCreature(*me, drakeGUID);
- if (!drake)
+ if (!me->HasUnitState(UNIT_STATE_ONVEHICLE))
{
- drakeGUID = 0;
- return;
+ me->DespawnOrUnsummon();
}
+ }
- // drake unsummoned, passengers dropped
- if (!me->IsOnVehicle(drake) && !hasEmptySeats)
- me->DespawnOrUnsummon(3000);
-
- if (enter_timer <= 0)
+ void SpellHit(Unit* caster, const SpellInfo* spell)
+ {
+ if (spell->Id != SPELL_ICE_LANCE)
return;
- if (enter_timer < diff)
+ if (caster->GetVehicleKit()->GetAvailableSeatCount() != 0)
{
- enter_timer = 0;
- if (hasEmptySeats)
- me->JumpTo(drake, 25.0f);
- else
- Reset();
+ me->CastSpell(me, SPELL_FREE_PRISONER, true);
+ me->CastSpell(caster, SPELL_RIDE_DRAKE, true);
+ me->CastSpell(me, SPELL_SHARD_IMPACT, true);
+ freed = true;
}
- else
- enter_timer -= diff;
}
+ };
+
+ CreatureAI* GetAI(Creature* creature) const
+ {
+ return new npc_brunnhildar_prisonerAI(creature);
+ }
+};
+
+/*######
+## npc_freed_protodrake
+######*/
+
+enum FreedProtoDrake
+{
+ AREA_VALLEY_OF_ANCIENT_WINTERS = 4437,
+ TEXT_EMOTE = 0,
+ SPELL_KILL_CREDIT_PRISONER = 55144,
+ SPELL_SUMMON_LIBERATED = 55073,
+ SPELL_KILL_CREDIT_DRAKE = 55143
+};
+
+const Position FreedDrakeWaypoints[16] =
+{
+ {7294.96f, -2418.733f, 823.869f, 0.0f},
+ {7315.984f, -2331.46f, 826.3972f, 0.0f},
+ {7271.826f, -2271.479f, 833.5917f, 0.0f},
+ {7186.253f, -2218.475f, 847.5632f, 0.0f},
+ {7113.195f, -2164.288f, 850.2301f, 0.0f},
+ {7078.018f, -2063.106f, 854.7581f, 0.0f},
+ {7073.221f, -1983.382f, 861.9246f, 0.0f},
+ {7061.455f, -1885.899f, 865.119f, 0.0f},
+ {7033.32f, -1826.775f, 876.2578f, 0.0f},
+ {6999.902f, -1784.012f, 897.4521f, 0.0f},
+ {6954.913f, -1747.043f, 897.4521f, 0.0f},
+ {6933.856f, -1720.698f, 882.2022f, 0.0f},
+ {6932.729f, -1687.306f, 866.1189f, 0.0f},
+ {6952.458f, -1663.802f, 849.8133f, 0.0f},
+ {7002.819f, -1651.681f, 831.397f, 0.0f},
+ {7026.531f, -1649.239f, 828.8406f, 0.0f}
+};
- void MoveInLineOfSight(Unit* who)
+
+class npc_freed_protodrake : public CreatureScript
+{
+public:
+ npc_freed_protodrake() : CreatureScript("npc_freed_protodrake") { }
+
+ struct npc_freed_protodrakeAI : public VehicleAI
+ {
+ npc_freed_protodrakeAI(Creature* creature) : VehicleAI(creature) {}
+
+ bool autoMove;
+ bool wpReached;
+ uint16 CheckTimer;
+ uint16 countWP;
+
+ void Reset()
{
- if (!who || !drakeGUID)
+ autoMove = false;
+ wpReached = false;
+ CheckTimer = 5000;
+ countWP = 0;
+ }
+
+ void MovementInform(uint32 type, uint32 id)
+ {
+ if (type != POINT_MOTION_TYPE)
return;
- Creature* drake = Unit::GetCreature(*me, drakeGUID);
- if (!drake)
+ if (id < 15)
{
- drakeGUID = 0;
- return;
+ ++countWP;
+ wpReached = true;
}
-
- if (!me->IsOnVehicle(drake) && !me->HasAura(SPELL_ICE_PRISON))
+ else
+ // drake reached village
{
- if (who->IsVehicle() && me->IsWithinDist(who, 25.0f, true) && who->ToCreature() && who->ToCreature()->GetEntry() == 29709)
+ // get player that rides drake (from seat 0)
+ Unit* player = me->GetVehicleKit()->GetPassenger(0);
+ if (player && player->GetTypeId() == TYPEID_PLAYER)
{
- uint8 seat = who->GetVehicleKit()->GetNextEmptySeat(0, true);
- if (seat <= 0)
- return;
-
- me->EnterVehicle(who, seat);
- me->SendMovementFlagUpdate();
- hasEmptySeats = false;
+ // for each prisoner on drake,give credit
+ for (uint8 i = 1; i < 4; ++i)
+ if (Unit* prisoner = me->GetVehicleKit()->GetPassenger(i))
+ {
+ if (prisoner->GetTypeId() != TYPEID_UNIT)
+ return;
+ prisoner->CastSpell(player, SPELL_KILL_CREDIT_PRISONER, true);
+ prisoner->CastSpell(prisoner, SPELL_SUMMON_LIBERATED, true);
+ prisoner->ExitVehicle();
+ }
+ me->CastSpell(me, SPELL_KILL_CREDIT_DRAKE, true);
+ player->ExitVehicle();
}
}
+ }
- if (who->ToCreature() && me->IsOnVehicle(drake))
+ void UpdateAI(const uint32 diff)
+ {
+ if (!autoMove)
{
- if (who->ToCreature()->GetEntry() == NPC_QUEST_GIVER && me->IsWithinDist(who, 15.0f, false))
+ if (CheckTimer < diff)
{
- Unit* rider = drake->GetVehicleKit()->GetPassenger(0);
- if (!rider)
- return;
-
- rider->CastSpell(rider, SPELL_KILL_CREDIT_PRISONER, true);
-
- me->ExitVehicle();
- me->CastSpell(me, SPELL_SUMMON_LIBERATED, true);
- me->DespawnOrUnsummon(500);
-
- // drake is empty now, deliver credit for drake and despawn him
- if (drake->GetVehicleKit()->HasEmptySeat(1) &&
- drake->GetVehicleKit()->HasEmptySeat(2) &&
- drake->GetVehicleKit()->HasEmptySeat(3))
+ CheckTimer = 5000;
+ if (me->GetAreaId() == AREA_VALLEY_OF_ANCIENT_WINTERS)
{
- // not working rider->CastSpell(rider, SPELL_KILL_CREDIT_DRAKE, true);
- if (rider->ToPlayer())
- rider->ToPlayer()->KilledMonsterCredit(29709, 0);
-
- drake->DespawnOrUnsummon(0);
+ Talk(TEXT_EMOTE, me->GetVehicleKit()->GetPassenger(0)->GetGUID());
+ autoMove = true;
+ wpReached = true;
}
}
+ else
+ CheckTimer -= diff;
}
- }
-
- void SpellHit(Unit* hitter, const SpellInfo* spell)
- {
- if (!hitter || !spell)
- return;
-
- if (spell->Id != SPELL_ICE_LANCE)
- return;
- me->RemoveAura(SPELL_ICE_PRISON);
- enter_timer = 500;
-
- if (hitter->IsVehicle())
- drakeGUID = hitter->GetGUID();
- else
- return;
-
- if (hitter->GetVehicleKit()->GetNextEmptySeat(0, true))
- hasEmptySeats = true;
+ if (wpReached && autoMove)
+ {
+ wpReached = false;
+ me->GetMotionMaster()->MovePoint(countWP, FreedDrakeWaypoints[countWP]);
+ }
}
};
CreatureAI* GetAI(Creature* creature) const
{
- return new npc_brunnhildar_prisonerAI(creature);
+ return new npc_freed_protodrakeAI(creature);
}
};
@@ -655,11 +568,10 @@ void AddSC_storm_peaks()
{
new npc_agnetta_tyrsdottar();
new npc_frostborn_scout();
- new npc_thorim();
- new npc_loklira_crone();
new npc_injured_goblin();
new npc_roxi_ramrocket();
new npc_brunnhildar_prisoner();
+ new npc_freed_protodrake();
new npc_icefang();
new npc_hyldsmeet_protodrake();
}
diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
index 84d292e1fe4..b42641c5171 100644
--- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/boss_broggok.cpp
@@ -160,7 +160,7 @@ class go_broggok_lever : public GameObjectScript
public:
go_broggok_lever() : GameObjectScript("go_broggok_lever") {}
- bool OnGossipHello(Player* player, GameObject* go)
+ bool OnGossipHello(Player* /*player*/, GameObject* go)
{
if (InstanceScript* instance = go->GetInstanceScript())
if (instance->GetData(TYPE_BROGGOK_EVENT) != DONE && instance->GetData(TYPE_BROGGOK_EVENT) != IN_PROGRESS)
diff --git a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp
index 893f97fe711..156581e8cd2 100644
--- a/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/BloodFurnace/instance_blood_furnace.cpp
@@ -133,7 +133,7 @@ class instance_blood_furnace : public InstanceMapScript
}
}
- void OnCreatureDeath(Creature* unit)
+ void OnUnitDeath(Unit* unit)
{
if (unit && unit->GetTypeId() == TYPEID_UNIT && unit->GetEntry() == 17398)
PrisonerDied(unit->GetGUID());
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index febc5ef3573..96a115f8057 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -409,11 +409,12 @@ void WheatyExceptionReport::printTracesForAllThreads()
CONTEXT context;
context.ContextFlags = 0xffffffff;
HANDLE threadHandle = OpenThread(THREAD_GET_CONTEXT | THREAD_QUERY_INFORMATION, false, te32.th32ThreadID);
- if (threadHandle && GetThreadContext(threadHandle, &context))
+ if (threadHandle)
{
- WriteStackDetails(&context, false, threadHandle);
+ if (GetThreadContext(threadHandle, &context))
+ WriteStackDetails(&context, false, threadHandle);
+ CloseHandle(threadHandle);
}
- CloseHandle(threadHandle);
}
} while (Thread32Next(hThreadSnap, &te32));
@@ -521,7 +522,7 @@ PEXCEPTION_POINTERS pExceptionInfo)
_tprintf(_T("Global Variables\r\n"));
SymEnumSymbols(GetCurrentProcess(),
- (DWORD64)GetModuleHandle(szFaultingModule),
+ (UINT_PTR)GetModuleHandle(szFaultingModule),
0, EnumerateSymbolsCallback, 0);
// #endif // X86 Only!
@@ -989,7 +990,7 @@ PVOID pAddress)
if (!IsBadStringPtr(*(PSTR*)pAddress, 32))
{
pszCurrBuffer += sprintf(pszCurrBuffer, " = \"%.31s\"",
- *(PDWORD)pAddress);
+ *(PSTR*)pAddress);
}
else
pszCurrBuffer += sprintf(pszCurrBuffer, " = %X",
diff --git a/src/server/shared/Logging/AppenderConsole.cpp b/src/server/shared/Logging/AppenderConsole.cpp
index 839f8512ad7..be6dc6c807f 100644
--- a/src/server/shared/Logging/AppenderConsole.cpp
+++ b/src/server/shared/Logging/AppenderConsole.cpp
@@ -59,7 +59,7 @@ void AppenderConsole::InitColors(std::string const& str)
void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color)
{
- #if PLATFORM == PLATFORWINDOWS
+ #if PLATFORM == PLATFORM_WINDOWS
static WORD WinColorFG[MaxColors] =
{
0, // BLACK
@@ -146,7 +146,7 @@ void AppenderConsole::SetColor(bool stdout_stream, ColorTypes color)
void AppenderConsole::ResetColor(bool stdout_stream)
{
- #if PLATFORM == PLATFORWINDOWS
+ #if PLATFORM == PLATFORM_WINDOWS
HANDLE hConsole = GetStdHandle(stdout_stream ? STD_OUTPUT_HANDLE : STD_ERROR_HANDLE);
SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
#else
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp
index 9917bbb5309..89942b978df 100755
--- a/src/server/shared/Utilities/Util.cpp
+++ b/src/server/shared/Utilities/Util.cpp
@@ -92,7 +92,7 @@ Tokens::Tokens(const std::string &src, const char sep, uint32 vectorReserve)
void stripLineInvisibleChars(std::string &str)
{
- static std::string invChars = " \t\7\n";
+ static std::string const invChars = " \t\7\n";
size_t wpos = 0;
diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h
index 196882dc2a0..64a89885350 100755
--- a/src/server/shared/Utilities/Util.h
+++ b/src/server/shared/Utilities/Util.h
@@ -51,7 +51,7 @@ std::string TimeToTimestampStr(time_t t);
inline uint32 secsToTimeBitFields(time_t secs)
{
tm* lt = localtime(&secs);
- return (lt->tm_year - 100) << 24 | lt->tm_mon << 20 | (lt->tm_mday - 1) << 14 | lt->tm_wday << 11 | lt->tm_hour << 6 | lt->tm_min;
+ return uint32((lt->tm_year - 100) << 24 | lt->tm_mon << 20 | (lt->tm_mday - 1) << 14 | lt->tm_wday << 11 | lt->tm_hour << 6 | lt->tm_min);
}
/* Return a random number in the range min..max; (max-min) must be smaller than 32768. */
@@ -89,22 +89,6 @@ inline bool roll_chance_i(int chance)
return chance > irand(0, 99);
}
-inline void ApplyModUInt32Var(uint32& var, int32 val, bool apply)
-{
- int32 cur = var;
- cur += (apply ? val : -val);
- if (cur < 0)
- cur = 0;
- var = cur;
-}
-
-inline void ApplyModFloatVar(float& var, float val, bool apply)
-{
- var += (apply ? val : -val);
- if (var < 0)
- var = 0;
-}
-
inline void ApplyPercentModFloatVar(float& var, float val, bool apply)
{
if (val == -100.0f) // prevent set var to zero
diff --git a/src/tools/map_extractor/CMakeLists.txt b/src/tools/map_extractor/CMakeLists.txt
index bde62c24c70..55a136f6329 100644
--- a/src/tools/map_extractor/CMakeLists.txt
+++ b/src/tools/map_extractor/CMakeLists.txt
@@ -43,5 +43,5 @@ add_dependencies(mapextractor mpq)
if( UNIX )
install(TARGETS mapextractor DESTINATION bin)
elseif( WIN32 )
- install(TARGETS mapextractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
+ install(TARGETS mapextractor DESTINATION "${CMAKE_INSTALL_PREFIX}")
endif()
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index f474925313e..d0342717324 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -9,6 +9,7 @@
#include "direct.h"
#else
#include <sys/stat.h>
+#include <unistd.h>
#endif
#include "dbcfile.h"