From 9c4cf9b39c17854fac3c1323e5e3bd1d2f164e3d Mon Sep 17 00:00:00 2001 From: Gacko Date: Sun, 21 Oct 2012 14:33:20 +0200 Subject: Core/DB: Children's Week --- src/server/scripts/Events/CMakeLists.txt | 17 + src/server/scripts/Events/childrens_week.cpp | 1049 ++++++++++++++++++++++++++ src/server/scripts/Events/event.cpp | 26 + 3 files changed, 1092 insertions(+) create mode 100644 src/server/scripts/Events/CMakeLists.txt create mode 100644 src/server/scripts/Events/childrens_week.cpp create mode 100644 src/server/scripts/Events/event.cpp (limited to 'src/server/scripts/Events') diff --git a/src/server/scripts/Events/CMakeLists.txt b/src/server/scripts/Events/CMakeLists.txt new file mode 100644 index 00000000000..d8be052d645 --- /dev/null +++ b/src/server/scripts/Events/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2008-2011 TrinityCore +# +# This file is free software; as a special exception the author gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +set(scripts_STAT_SRCS + ${scripts_STAT_SRCS} + Events/childrens_week.cpp + Events/event.cpp +) + +message(" -> Prepared: Events") diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp new file mode 100644 index 00000000000..8014434cd98 --- /dev/null +++ b/src/server/scripts/Events/childrens_week.cpp @@ -0,0 +1,1049 @@ +/* +* Copyright (C) 2008-2012 TrinityCore +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along +* with this program. If not, see . +*/ + +#include "event.h" +#include "ScriptMgr.h" +#include "ScriptedCreature.h" + +enum Orphans +{ + ORPHAN_ORACLE = 33533, + ORPHAN_WOLVAR = 33532, + ORPHAN_BLOOD_ELF = 22817, + ORPHAN_DRAENEI = 22818, + ORPHAN_HUMAN = 14305, + ORPHAN_ORCISH = 14444, +}; + +enum Texts +{ + TEXT_ORACLE_ORPHAN_1 = 1, + TEXT_ORACLE_ORPHAN_2 = 2, + TEXT_ORACLE_ORPHAN_3 = 3, + TEXT_ORACLE_ORPHAN_4 = 4, + TEXT_ORACLE_ORPHAN_5 = 5, + TEXT_ORACLE_ORPHAN_6 = 6, + TEXT_ORACLE_ORPHAN_7 = 7, + TEXT_ORACLE_ORPHAN_8 = 8, + TEXT_ORACLE_ORPHAN_9 = 9, + TEXT_ORACLE_ORPHAN_10 = 10, + TEXT_ORACLE_ORPHAN_11 = 11, + TEXT_ORACLE_ORPHAN_12 = 12, + TEXT_ORACLE_ORPHAN_13 = 13, + TEXT_ORACLE_ORPHAN_14 = 14, + + TEXT_WOLVAR_ORPHAN_1 = 1, + TEXT_WOLVAR_ORPHAN_2 = 2, + TEXT_WOLVAR_ORPHAN_3 = 3, + TEXT_WOLVAR_ORPHAN_4 = 4, + TEXT_WOLVAR_ORPHAN_5 = 5, + // 6 - 9 used in Nesingwary script + TEXT_WOLVAR_ORPHAN_10 = 10, + TEXT_WOLVAR_ORPHAN_11 = 11, + TEXT_WOLVAR_ORPHAN_12 = 12, + TEXT_WOLVAR_ORPHAN_13 = 13, + + TEXT_WINTERFIN_PLAYMATE_1 = 1, + TEXT_WINTERFIN_PLAYMATE_2 = 2, + + TEXT_SNOWFALL_GLADE_PLAYMATE_1 = 1, + TEXT_SNOWFALL_GLADE_PLAYMATE_2 = 2, + + TEXT_SOO_ROO_1 = 1, + TEXT_ELDER_KEKEK_1 = 1, + + TEXT_ALEXSTRASZA_2 = 2, + TEXT_KRASUS_8 = 8, +}; + +enum Quests +{ + QUEST_PLAYMATE_WOLVAR = 13951, + QUEST_PLAYMATE_ORACLE = 13950, + QUEST_THE_BIGGEST_TREE_EVER = 13929, + QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE = 13933, + QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR = 13934, + QUEST_MEETING_A_GREAT_ONE = 13956, + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, + QUEST_DOWN_AT_THE_DOCKS = 910, + QUEST_GATEWAY_TO_THE_FRONTIER = 911, + QUEST_BOUGHT_OF_ETERNALS = 1479, + QUEST_SPOOKY_LIGHTHOUSE = 1687, + QUEST_STONEWROUGHT_DAM = 1558, + QUEST_DARK_PORTAL_H = 10951, + QUEST_DARK_PORTAL_A = 10952, + QUEST_LORDAERON_THRONE_ROOM = 1800, + QUEST_AUCHINDOUN_AND_THE_RING = 10950, + QUEST_TIME_TO_VISIT_THE_CAVERNS_H = 10963, + QUEST_TIME_TO_VISIT_THE_CAVERNS_A = 10962, + QUEST_THE_SEAT_OF_THE_NARUU = 10956, + QUEST_CALL_ON_THE_FARSEER = 10968, + QUEST_JHEEL_IS_AT_AERIS_LANDING = 10954, + QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE = 10945, + QUEST_VISIT_THE_THRONE_OF_ELEMENTS = 10953, + QUEST_NOW_WHEN_I_GROW_UP = 11975, + QUEST_HOME_OF_THE_BEAR_MEN = 13930, + QUEST_THE_DRAGON_QUEEN_ORACLE = 13954, + QUEST_THE_DRAGON_QUEEN_WOLVAR = 13955, +}; + +enum Areatriggers +{ + AT_DOWN_AT_THE_DOCKS = 3551, + AT_GATEWAY_TO_THE_FRONTIER = 3549, + AT_LORDAERON_THRONE_ROOM = 3547, + AT_BOUGHT_OF_ETERNALS = 3546, + AT_SPOOKY_LIGHTHOUSE = 3552, + AT_STONEWROUGHT_DAM = 3548, + AT_DARK_PORTAL = 4356, + + NPC_CAVERNS_OF_TIME_CW_TRIGGER = 22872, + NPC_EXODAR_01_CW_TRIGGER = 22851, + NPC_EXODAR_02_CW_TRIGGER = 22905, + NPC_AERIS_LANDING_CW_TRIGGER = 22838, + NPC_AUCHINDOUN_CW_TRIGGER = 22831, + NPC_SPOREGGAR_CW_TRIGGER = 22829, + NPC_THRONE_OF_ELEMENTS_CW_TRIGGER = 22839, + NPC_SILVERMOON_01_CW_TRIGGER = 22866, + NPC_KRASUS = 27990, +}; + +enum Misc +{ + SPELL_SNOWBALL = 21343, + SPELL_ORPHAN_OUT = 58818, + + DISPLAY_INVISIBLE = 11686, +}; + +uint64 getOrphanGUID(Player* player, uint32 orphan) +{ + if (Aura* orphanOut = player->GetAura(SPELL_ORPHAN_OUT)) + if (orphanOut->GetCaster() && orphanOut->GetCaster()->GetEntry() == orphan) + return orphanOut->GetCaster()->GetGUID(); + + return 0; +} + +/*###### +## npc_winterfin_playmate +######*/ +class npc_winterfin_playmate : public CreatureScript +{ + public: + npc_winterfin_playmate() : CreatureScript("npc_winterfin_playmate") {} + + struct npc_winterfin_playmateAI : public ScriptedAI + { + npc_winterfin_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch(phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_1); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_WINTERFIN_PLAYMATE_1); + me->HandleEmoteCommand(EMOTE_STATE_DANCE); + timer = 3000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_2); + timer = 3000; + break; + case 4: + Talk(TEXT_WINTERFIN_PLAYMATE_2); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_3); + me->HandleEmoteCommand(EMOTE_STATE_NONE); + player->GroupEventHappens(QUEST_PLAYMATE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_winterfin_playmateAI(creature); + } +}; + +/*###### +## npc_snowfall_glade_playmate +######*/ +class npc_snowfall_glade_playmate : public CreatureScript +{ + public: + npc_snowfall_glade_playmate() : CreatureScript("npc_snowfall_glade_playmate") {} + + struct npc_snowfall_glade_playmateAI : public ScriptedAI + { + npc_snowfall_glade_playmateAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_PLAYMATE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_1); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_1); + DoCast(orphan, SPELL_SNOWBALL); + timer = 5000; + break; + case 3: + Talk(TEXT_SNOWFALL_GLADE_PLAYMATE_2); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_2); + orphan->AI()->DoCast(me, SPELL_SNOWBALL); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_3); + player->GroupEventHappens(QUEST_PLAYMATE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + }; + + CreatureAI* GetAI(Creature* pCreature) const + { + return new npc_snowfall_glade_playmateAI(pCreature); + } +}; + +/*###### +## npc_the_biggest_tree +######*/ +class npc_the_biggest_tree : public CreatureScript +{ + public: + npc_the_biggest_tree() : CreatureScript("npc_the_biggest_tree") {} + + struct npc_the_biggest_treeAI : public ScriptedAI + { + npc_the_biggest_treeAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void Reset() + { + timer = 1000; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BIGGEST_TREE_EVER) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + timer = 2000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_4); + timer = 5000; + break; + case 3: + player->GroupEventHappens(QUEST_THE_BIGGEST_TREE_EVER, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + uint8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_biggest_treeAI(creature); + } +}; + +/*###### +## npc_high_oracle_soo_roo +######*/ +class npc_high_oracle_soo_roo : public CreatureScript +{ + public: + npc_high_oracle_soo_roo() : CreatureScript("npc_high_oracle_soo_roo") {} + + struct npc_high_oracle_soo_rooAI : public ScriptedAI + { + npc_high_oracle_soo_rooAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_5); + timer = 3000; + break; + case 2: + orphan->SetFacingToObject(me); + Talk(TEXT_SOO_ROO_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_6); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_high_oracle_soo_rooAI(creature); + } +}; + +/*###### +## npc_elder_kekek +######*/ +class npc_elder_kekek : public CreatureScript +{ + public: + npc_elder_kekek() : CreatureScript("npc_elder_kekek") {} + + struct npc_elder_kekekAI : public ScriptedAI + { + npc_elder_kekekAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!player || !orphan) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_4); + timer = 3000; + break; + case 2: + Talk(TEXT_ELDER_KEKEK_1); + timer = 6000; + break; + case 3: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_5); + player->GroupEventHappens(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_elder_kekekAI(creature); + } +}; + +/*###### +## npc_the_etymidian +## TODO: A red crystal as a gift for the great one should be spawned during the event. +######*/ +class npc_the_etymidian : public CreatureScript +{ + public: + npc_the_etymidian() : CreatureScript("npc_the_etymidian") {} + + struct npc_the_etymidianAI : public ScriptedAI + { + npc_the_etymidianAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) == QUEST_STATUS_INCOMPLETE) + { + playerGUID = player->GetGUID(); + if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + phase = 1; + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_7); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_8); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_9); + timer = 5000; + break; + case 4: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_10); + timer = 5000; + break; + case 5: + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + player->GroupEventHappens(QUEST_MEETING_A_GREAT_ONE, me); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + uint32 timer; + int8 phase; + uint32 GOtimer; + uint64 playerGUID; + uint64 orphanGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_the_etymidianAI(creature); + } +}; + +/*###### +## npc_cw_alexstrasza_trigger +######*/ +class npc_alexstraza_the_lifebinder : public CreatureScript +{ + public: + npc_alexstraza_the_lifebinder() : CreatureScript("npc_alexstraza_the_lifebinder") {} + + struct npc_alexstraza_the_lifebinderAI : public ScriptedAI + { + npc_alexstraza_the_lifebinderAI(Creature* creature) : ScriptedAI (creature) {} + + void Reset() + { + timer = 0; + phase = 0; + playerGUID = 0; + orphanGUID = 0; + } + + void SetData(uint32 type, uint32 data) + { + // Existing SmartAI + if (type == 0) + { + switch (data) + { + case 1: + me->SetOrientation(1.6049f); + break; + case 2: + me->SetOrientation(me->GetHomePosition().GetOrientation()); + break; + } + } + } + + void MoveInLineOfSight(Unit* who) + { + if (!phase && who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + { + if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_ORACLE) == QUEST_STATUS_INCOMPLETE) + { + if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + phase = 1; + playerGUID = player->GetGUID(); + } + else if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_WOLVAR) == QUEST_STATUS_INCOMPLETE) + { + if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + phase = 7; + playerGUID = player->GetGUID(); + } + } + } + + void UpdateAI(const uint32 diff) + { + if (!phase) + return; + + if (timer <= diff) + { + Player* player = Player::GetPlayer(*me, playerGUID); + Creature* orphan = Creature::GetCreature(*me, orphanGUID); + + if (!orphan || !player) + { + Reset(); + return; + } + + switch (phase) + { + case 1: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_11); + timer = 5000; + break; + case 2: + orphan->SetFacingToObject(me); + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_12); + timer = 5000; + break; + case 3: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_13); + timer = 5000; + break; + case 4: + Talk(TEXT_ALEXSTRASZA_2); + me->SetStandState(UNIT_STAND_STATE_KNEEL); + me->SetFacingToObject(orphan); + timer = 5000; + break; + case 5: + orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_14); + timer = 5000; + break; + case 6: + me->SetStandState(UNIT_STAND_STATE_STAND); + me->SetOrientation(me->GetHomePosition().GetOrientation()); + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_ORACLE, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + case 7: + orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5, me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_11); + timer = 5000; + break; + case 8: + if(Creature* krasus = me->FindNearestCreature(NPC_KRASUS, 10.0f)) + { + orphan->SetFacingToObject(krasus); + krasus->AI()->Talk(TEXT_KRASUS_8); + } + timer = 5000; + break; + case 9: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_12); + timer = 5000; + break; + case 10: + orphan->SetFacingToObject(me); + Talk(TEXT_ALEXSTRASZA_2); + timer = 5000; + break; + case 11: + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_13); + timer = 5000; + break; + case 12: + player->GroupEventHappens(QUEST_THE_DRAGON_QUEEN_WOLVAR, me); + orphan->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE); + Reset(); + return; + } + ++phase; + } + else + timer -= diff; + } + + private: + int8 phase; + uint32 timer; + uint64 playerGUID; + uint64 orphanGUID; + uint64 alexstraszaGUID; + + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_alexstraza_the_lifebinderAI(creature); + } +}; + +/*###### +## at_bring_your_orphan_to +######*/ + +class at_bring_your_orphan_to : public AreaTriggerScript +{ + public: + at_bring_your_orphan_to() : AreaTriggerScript("at_bring_your_orphan_to") { } + + bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) + { + if (player->isDead() || !player->HasAura(SPELL_ORPHAN_OUT)) + return false; + + uint32 questId = 0; + uint32 orphanId = 0; + + switch (trigger->id) + { + case AT_DOWN_AT_THE_DOCKS: + questId = QUEST_DOWN_AT_THE_DOCKS; + orphanId = ORPHAN_ORCISH; + break; + case AT_GATEWAY_TO_THE_FRONTIER: + questId = QUEST_GATEWAY_TO_THE_FRONTIER; + orphanId = ORPHAN_ORCISH; + break; + case AT_LORDAERON_THRONE_ROOM: + questId = QUEST_LORDAERON_THRONE_ROOM; + orphanId = ORPHAN_ORCISH; + break; + case AT_BOUGHT_OF_ETERNALS: + questId = QUEST_BOUGHT_OF_ETERNALS; + orphanId = ORPHAN_HUMAN; + break; + case AT_SPOOKY_LIGHTHOUSE: + questId = QUEST_SPOOKY_LIGHTHOUSE; + orphanId = ORPHAN_HUMAN; + break; + case AT_STONEWROUGHT_DAM: + questId = QUEST_STONEWROUGHT_DAM; + orphanId = ORPHAN_HUMAN; + break; + case AT_DARK_PORTAL: + questId = player->GetTeam() == ALLIANCE ? QUEST_DARK_PORTAL_A : QUEST_DARK_PORTAL_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + } + + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + + return true; + } +}; + +/*###### +## npc_cw_area_trigger +######*/ +class npc_cw_area_trigger : public CreatureScript +{ + public: + npc_cw_area_trigger() : CreatureScript("npc_cw_area_trigger") {} + + struct npc_cw_area_triggerAI : public ScriptedAI + { + npc_cw_area_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && me->GetDistance2d(who) < 20.0f) + if (Player* player = who->ToPlayer()) + if (player->HasAura(SPELL_ORPHAN_OUT)) + { + uint32 questId = 0; + uint32 orphanId = 0; + switch (me->GetEntry()) + { + case NPC_CAVERNS_OF_TIME_CW_TRIGGER: + questId = player->GetTeam() == ALLIANCE ? QUEST_TIME_TO_VISIT_THE_CAVERNS_A : QUEST_TIME_TO_VISIT_THE_CAVERNS_H; + orphanId = player->GetTeam() == ALLIANCE ? ORPHAN_DRAENEI : ORPHAN_BLOOD_ELF; + break; + case NPC_EXODAR_01_CW_TRIGGER: + questId = QUEST_THE_SEAT_OF_THE_NARUU; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_EXODAR_02_CW_TRIGGER: + questId = QUEST_CALL_ON_THE_FARSEER; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AERIS_LANDING_CW_TRIGGER: + questId = QUEST_JHEEL_IS_AT_AERIS_LANDING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_AUCHINDOUN_CW_TRIGGER: + questId = QUEST_AUCHINDOUN_AND_THE_RING; + orphanId = ORPHAN_DRAENEI; + break; + case NPC_SPOREGGAR_CW_TRIGGER: + questId = QUEST_HCHUU_AND_THE_MUSHROOM_PEOPLE; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_THRONE_OF_ELEMENTS_CW_TRIGGER: + questId = QUEST_VISIT_THE_THRONE_OF_ELEMENTS; + orphanId = ORPHAN_BLOOD_ELF; + break; + case NPC_SILVERMOON_01_CW_TRIGGER: + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_INCOMPLETE && getOrphanGUID(player, ORPHAN_BLOOD_ELF)) + { + player->AreaExploredOrEventHappens(QUEST_NOW_WHEN_I_GROW_UP); + if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_COMPLETE) + if (Creature* samuro = me->FindNearestCreature(25151, 20.0f)) + { + uint32 emote = 0; + switch(urand(1,5)) + { + case 1: + emote = EMOTE_ONESHOT_WAVE; + break; + case 2: + emote = EMOTE_ONESHOT_ROAR; + break; + case 3: + emote = EMOTE_ONESHOT_FLEX; + break; + case 4: + emote = EMOTE_ONESHOT_SALUTE; + break; + case 5: + emote = EMOTE_ONESHOT_DANCE; + break; + } + samuro->HandleEmoteCommand(emote); + } + } + break; + } + if (questId && orphanId && getOrphanGUID(player, orphanId) && player->GetQuestStatus(questId) == QUEST_STATUS_INCOMPLETE) + player->AreaExploredOrEventHappens(questId); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_cw_area_triggerAI(creature); + } +}; + +/*###### +## npc_grizzlemaw_cw_trigger +######*/ +class npc_grizzlemaw_cw_trigger : public CreatureScript +{ + public: + npc_grizzlemaw_cw_trigger() : CreatureScript("npc_grizzlemaw_cw_trigger") {} + + struct npc_grizzlemaw_cw_triggerAI : public ScriptedAI + { + npc_grizzlemaw_cw_triggerAI(Creature* creature) : ScriptedAI (creature) + { + me->SetDisplayId(DISPLAY_INVISIBLE); + } + + void MoveInLineOfSight(Unit* who) + { + if (who && who->GetDistance2d(me) < 10.0f) + if (Player* player = who->ToPlayer()) + if (player->GetQuestStatus(QUEST_HOME_OF_THE_BEAR_MEN) == QUEST_STATUS_INCOMPLETE) + if (Creature* orphan = Creature::GetCreature(*me, getOrphanGUID(player, ORPHAN_WOLVAR))) + { + player->AreaExploredOrEventHappens(QUEST_HOME_OF_THE_BEAR_MEN); + orphan->AI()->Talk(TEXT_WOLVAR_ORPHAN_10); + } + } + }; + + CreatureAI* GetAI(Creature* creature) const + { + return new npc_grizzlemaw_cw_triggerAI(creature); + } +}; + +void AddSC_event_childrens_week() +{ + new npc_elder_kekek(); + new npc_high_oracle_soo_roo(); + new npc_winterfin_playmate(); + new npc_snowfall_glade_playmate(); + new npc_the_etymidian(); + new npc_the_biggest_tree(); + new at_bring_your_orphan_to(); + new npc_grizzlemaw_cw_trigger(); + new npc_cw_area_trigger(); + new npc_alexstraza_the_lifebinder(); +} diff --git a/src/server/scripts/Events/event.cpp b/src/server/scripts/Events/event.cpp new file mode 100644 index 00000000000..0cb0b10bdbc --- /dev/null +++ b/src/server/scripts/Events/event.cpp @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2008-2012 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "ScriptPCH.h" +#include "event.h" + +void AddSC_event_childrens_week(); + +void AddSC_event_scripts() +{ + AddSC_event_childrens_week(); +} -- cgit v1.2.3 From cd26aa72065ad47b6d99776c5c12290360ea9502 Mon Sep 17 00:00:00 2001 From: Gacko Date: Thu, 25 Oct 2012 16:16:01 +0200 Subject: Core: Children's Week - Remove event.h include --- src/server/scripts/Events/event.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/server/scripts/Events') diff --git a/src/server/scripts/Events/event.cpp b/src/server/scripts/Events/event.cpp index 0cb0b10bdbc..22334f8d365 100644 --- a/src/server/scripts/Events/event.cpp +++ b/src/server/scripts/Events/event.cpp @@ -16,7 +16,6 @@ */ #include "ScriptPCH.h" -#include "event.h" void AddSC_event_childrens_week(); -- cgit v1.2.3 From ead804df92cf43693b45393dfdbd2b1f75f9a93e Mon Sep 17 00:00:00 2001 From: Gacko Date: Thu, 25 Oct 2012 22:08:10 +0200 Subject: Core: Fix compile warnings --- src/server/scripts/Events/childrens_week.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/server/scripts/Events') diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp index 8014434cd98..d09d82130de 100644 --- a/src/server/scripts/Events/childrens_week.cpp +++ b/src/server/scripts/Events/childrens_week.cpp @@ -15,7 +15,6 @@ * with this program. If not, see . */ -#include "event.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" @@ -166,7 +165,7 @@ class npc_winterfin_playmate : public CreatureScript if (player->GetQuestStatus(QUEST_PLAYMATE_ORACLE) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) phase = 1; } } @@ -263,7 +262,7 @@ class npc_snowfall_glade_playmate : public CreatureScript if (player->GetQuestStatus(QUEST_PLAYMATE_WOLVAR) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) phase = 1; } } @@ -362,7 +361,7 @@ class npc_the_biggest_tree : public CreatureScript if (player->GetQuestStatus(QUEST_THE_BIGGEST_TREE_EVER) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) phase = 1; } } @@ -447,7 +446,7 @@ class npc_high_oracle_soo_roo : public CreatureScript if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) phase = 1; } } @@ -534,7 +533,7 @@ class npc_elder_kekek : public CreatureScript if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) phase = 1; } } @@ -621,7 +620,7 @@ class npc_the_etymidian : public CreatureScript if (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) == QUEST_STATUS_INCOMPLETE) { playerGUID = player->GetGUID(); - if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) phase = 1; } } @@ -733,13 +732,13 @@ class npc_alexstraza_the_lifebinder : public CreatureScript { if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_ORACLE) == QUEST_STATUS_INCOMPLETE) { - if (orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_ORACLE))) phase = 1; playerGUID = player->GetGUID(); } else if (player->GetQuestStatus(QUEST_THE_DRAGON_QUEEN_WOLVAR) == QUEST_STATUS_INCOMPLETE) { - if (orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR)) + if ((orphanGUID = getOrphanGUID(player, ORPHAN_WOLVAR))) phase = 7; playerGUID = player->GetGUID(); } -- cgit v1.2.3 From d2ba73d97f12da64b76895b7335500d1fc993a37 Mon Sep 17 00:00:00 2001 From: Spp Date: Mon, 29 Oct 2012 12:28:12 +0100 Subject: Core/Misc: Proper fix for previous commit (c5c8e38 - check race change before perfoming faction-change actions) Core/Misc: tab to spaces and remove trailing whitespaces --- src/server/game/DungeonFinding/LFGMgr.cpp | 4 +- src/server/game/Entities/Player/Player.cpp | 6 +- src/server/game/Entities/Unit/Unit.cpp | 2 +- src/server/game/Handlers/CharacterHandler.cpp | 614 ++++++++++----------- src/server/scripts/Events/childrens_week.cpp | 48 +- .../ChamberOfAspects/RubySanctum/boss_halion.cpp | 4 +- src/server/scripts/Northrend/sholazar_basin.cpp | 4 +- src/server/scripts/World/areatrigger_scripts.cpp | 2 +- 8 files changed, 342 insertions(+), 342 deletions(-) (limited to 'src/server/scripts/Events') diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 2001ddd07b2..a04638a8d47 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -1395,9 +1395,9 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* { sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s not in group/lfggroup or dungeon not found!", player->GetName().c_str()); - player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION)); + player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION)); return; - } + } if (out) { diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 973eba5da25..d409b507561 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -1577,7 +1577,7 @@ void Player::Update(uint32 p_time) // check every second if (now > m_Last_tick + 1) UpdateSoulboundTradeItems(); - + // If mute expired, remove it from the DB if (GetSession()->m_muteTime && GetSession()->m_muteTime < now) { @@ -15714,7 +15714,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) } uint32 zone = 0, area = 0; - + SpellAreaForQuestMapBounds saBounds = sSpellMgr->GetSpellAreaForQuestMapBounds(quest_id); if (saBounds.first != saBounds.second) { @@ -15725,7 +15725,7 @@ void Player::SetQuestStatus(uint32 quest_id, QuestStatus status) if (!HasAura(itr->second->spellId)) CastSpell(this, itr->second->spellId, true); } - + saBounds = sSpellMgr->GetSpellAreaForQuestEndMapBounds(quest_id); if (saBounds.first != saBounds.second) { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 743d622e8c9..f8de93afc6d 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -6672,7 +6672,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere victim->CastCustomSpell(beaconTarget, triggered_spell_id, &basepoints0, NULL, NULL, true, 0, triggeredByAura); return true; } - + return false; } // Judgements of the Wise diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index f14e9cc8e8d..967ddd9c75b 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -1648,7 +1648,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) uint32 used_loginFlag = ((recv_data.GetOpcode() == CMSG_CHAR_RACE_CHANGE) ? AT_LOGIN_CHANGE_RACE : AT_LOGIN_CHANGE_FACTION); if (!sObjectMgr->GetPlayerInfo(race, playerClass)) - { + {ops.. WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); data << uint8(CHAR_CREATE_ERROR); SendPacket(&data); @@ -1731,387 +1731,387 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) sWorld->UpdateCharacterNameData(GUID_LOPART(guid), newname, gender, race); - if (oldRace == race) - return; - - TeamId team = TEAM_ALLIANCE; - - // Search each faction is targeted - switch (race) + if (oldRace != race) { - case RACE_ORC: - case RACE_TAUREN: - case RACE_UNDEAD_PLAYER: - case RACE_TROLL: - case RACE_BLOODELF: - team = TEAM_HORDE; - break; - default: - break; - } - - // Switch Languages - // delete all languages first - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); - - // Now add them back - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); - - // Faction specific languages - if (team == TEAM_HORDE) - stmt->setUInt16(1, 109); - else - stmt->setUInt16(1, 98); - - trans->Append(stmt); - - // Race specific languages - if (race != RACE_ORC && race != RACE_HUMAN) - { - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); - stmt->setUInt32(0, lowGuid); + TeamId team = TEAM_ALLIANCE; + // Search each faction is targeted switch (race) { - case RACE_DWARF: - stmt->setUInt16(1, 111); - break; - case RACE_DRAENEI: - stmt->setUInt16(1, 759); - break; - case RACE_GNOME: - stmt->setUInt16(1, 313); - break; - case RACE_NIGHTELF: - stmt->setUInt16(1, 113); - break; - case RACE_UNDEAD_PLAYER: - stmt->setUInt16(1, 673); - break; + case RACE_ORC: case RACE_TAUREN: - stmt->setUInt16(1, 115); - break; + case RACE_UNDEAD_PLAYER: case RACE_TROLL: - stmt->setUInt16(1, 315); - break; case RACE_BLOODELF: - stmt->setUInt16(1, 137); + team = TEAM_HORDE; + break; + default: break; } + // Switch Languages + // delete all languages first + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - if (recv_data.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) - { - // Delete all Flypaths - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + // Now add them back + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); stmt->setUInt32(0, lowGuid); + + // Faction specific languages + if (team == TEAM_HORDE) + stmt->setUInt16(1, 109); + else + stmt->setUInt16(1, 98); + trans->Append(stmt); - if (level > 7) + // Race specific languages + if (race != RACE_ORC && race != RACE_HUMAN) { - // Update Taxi path - // this doesn't seem to be 100% blizzlike... but it can't really be helped. - std::ostringstream taximaskstream; - uint32 numFullTaximasks = level / 7; - if (numFullTaximasks > 11) - numFullTaximasks = 11; - if (team == TEAM_ALLIANCE) - { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } - } - else + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE); + stmt->setUInt32(0, lowGuid); + + switch (race) { - if (playerClass != CLASS_DEATH_KNIGHT) - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; - } - else - { - for (uint8 i = 0; i < numFullTaximasks; ++i) - taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; - } + case RACE_DWARF: + stmt->setUInt16(1, 111); + break; + case RACE_DRAENEI: + stmt->setUInt16(1, 759); + break; + case RACE_GNOME: + stmt->setUInt16(1, 313); + break; + case RACE_NIGHTELF: + stmt->setUInt16(1, 113); + break; + case RACE_UNDEAD_PLAYER: + stmt->setUInt16(1, 673); + break; + case RACE_TAUREN: + stmt->setUInt16(1, 115); + break; + case RACE_TROLL: + stmt->setUInt16(1, 315); + break; + case RACE_BLOODELF: + stmt->setUInt16(1, 137); + break; } - uint32 numEmptyTaximasks = 11 - numFullTaximasks; - for (uint8 i = 0; i < numEmptyTaximasks; ++i) - taximaskstream << "0 "; - taximaskstream << '0'; - std::string taximask = taximaskstream.str(); - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); - stmt->setString(0, taximask); - stmt->setUInt32(1, lowGuid); trans->Append(stmt); } - // Delete all current quests - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); - stmt->setUInt32(0, GUID_LOPART(guid)); - trans->Append(stmt); - - // Delete record of the faction old completed quests + if (recv_data.GetOpcode() == CMSG_CHAR_FACTION_CHANGE) { - std::ostringstream quests; - ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); - for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + // Delete all Flypaths + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + + if (level > 7) { - Quest *qinfo = iter->second; - uint32 requiredRaces = qinfo->GetRequiredRaces(); + // Update Taxi path + // this doesn't seem to be 100% blizzlike... but it can't really be helped. + std::ostringstream taximaskstream; + uint32 numFullTaximasks = level / 7; + if (numFullTaximasks > 11) + numFullTaximasks = 11; if (team == TEAM_ALLIANCE) { - if (requiredRaces & RACEMASK_ALLIANCE) + if (playerClass != CLASS_DEATH_KNIGHT) { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i]) << ' '; + } + else + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sAllianceTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - else // if (team == TEAM_HORDE) + else { - if (requiredRaces & RACEMASK_HORDE) + if (playerClass != CLASS_DEATH_KNIGHT) { - quests << uint32(qinfo->GetQuestId()); - quests << ','; + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i]) << ' '; + } + else + { + for (uint8 i = 0; i < numFullTaximasks; ++i) + taximaskstream << uint32(sHordeTaxiNodesMask[i] | sDeathKnightTaxiNodesMask[i]) << ' '; } } - } - std::string questsStr = quests.str(); - questsStr = questsStr.substr(0, questsStr.length() - 1); + uint32 numEmptyTaximasks = 11 - numFullTaximasks; + for (uint8 i = 0; i < numEmptyTaximasks; ++i) + taximaskstream << "0 "; + taximaskstream << '0'; + std::string taximask = taximaskstream.str(); - if (!questsStr.empty()) - trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); - } + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK); + stmt->setString(0, taximask); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + } - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) - { - // Reset guild - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); + // Delete all current quests + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS); + stmt->setUInt32(0, GUID_LOPART(guid)); + trans->Append(stmt); - stmt->setUInt32(0, lowGuid); + // Delete record of the faction old completed quests + { + std::ostringstream quests; + ObjectMgr::QuestMap const& qTemplates = sObjectMgr->GetQuestTemplates(); + for (ObjectMgr::QuestMap::const_iterator iter = qTemplates.begin(); iter != qTemplates.end(); ++iter) + { + Quest *qinfo = iter->second; + uint32 requiredRaces = qinfo->GetRequiredRaces(); + if (team == TEAM_ALLIANCE) + { + if (requiredRaces & RACEMASK_ALLIANCE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + else // if (team == TEAM_HORDE) + { + if (requiredRaces & RACEMASK_HORDE) + { + quests << uint32(qinfo->GetQuestId()); + quests << ','; + } + } + } - PreparedQueryResult result = CharacterDatabase.Query(stmt); - if (result) - if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) - guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); - } + std::string questsStr = quests.str(); + questsStr = questsStr.substr(0, questsStr.length() - 1); - if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) - { - // Delete Friend List - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!questsStr.empty()) + trans->PAppend("DELETE FROM `character_queststatus_rewarded` WHERE guid='%u' AND quest IN (%s)", lowGuid, questsStr.c_str()); + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD)) + { + // Reset guild + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER); - } + stmt->setUInt32(0, lowGuid); - // Leave Arena Teams - Player::LeaveAllArenaTeams(guid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); + if (result) + if (Guild* guild = sGuildMgr->GetGuildById((result->Fetch()[0]).GetUInt32())) + guild->DeleteMember(MAKE_NEW_GUID(lowGuid, 0, HIGHGUID_PLAYER)); + } - // Reset homebind and position - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + if (!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_ADD_FRIEND)) + { + // Delete Friend List + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); - stmt->setUInt32(0, lowGuid); - if (team == TEAM_ALLIANCE) - { - stmt->setUInt16(1, 0); - stmt->setUInt16(2, 1519); - stmt->setFloat (3, -8867.68f); - stmt->setFloat (4, 673.373f); - stmt->setFloat (5, 97.9034f); - Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); - } - else - { - stmt->setUInt16(1, 1); - stmt->setUInt16(2, 1637); - stmt->setFloat (3, 1633.33f); - stmt->setFloat (4, -4439.11f); - stmt->setFloat (5, 15.7588f); - Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); - } - trans->Append(stmt); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); - // Achievement conversion - for (std::map::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) - { - uint32 achiev_alliance = it->first; - uint32 achiev_horde = it->second; + } - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + // Leave Arena Teams + Player::LeaveAllArenaTeams(guid); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); - stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); - stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); - stmt->setUInt32(2, lowGuid); + // Reset homebind and position + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); trans->Append(stmt); - } - // Item conversion - for (std::map::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) - { - uint32 item_alliance = it->first; - uint32 item_horde = it->second; - - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); - stmt->setUInt32(2, guid); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND); + stmt->setUInt32(0, lowGuid); + if (team == TEAM_ALLIANCE) + { + stmt->setUInt16(1, 0); + stmt->setUInt16(2, 1519); + stmt->setFloat (3, -8867.68f); + stmt->setFloat (4, 673.373f); + stmt->setFloat (5, 97.9034f); + Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid); + } + else + { + stmt->setUInt16(1, 1); + stmt->setUInt16(2, 1637); + stmt->setFloat (3, 1633.33f); + stmt->setFloat (4, -4439.11f); + stmt->setFloat (5, 15.7588f); + Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid); + } trans->Append(stmt); - } - // Spell conversion - for (std::map::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) - { - uint32 spell_alliance = it->first; - uint32 spell_horde = it->second; + // Achievement conversion + for (std::map::const_iterator it = sObjectMgr->FactionChange_Achievements.begin(); it != sObjectMgr->FactionChange_Achievements.end(); ++it) + { + uint32 achiev_alliance = it->first; + uint32 achiev_horde = it->second; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); - stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); - stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); - stmt->setUInt32(2, lowGuid); - trans->Append(stmt); - } + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT); + stmt->setUInt16(0, uint16(team == TEAM_ALLIANCE ? achiev_alliance : achiev_horde)); + stmt->setUInt16(1, uint16(team == TEAM_ALLIANCE ? achiev_horde : achiev_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // Reputation conversion - for (std::map::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) - { - uint32 reputation_alliance = it->first; - uint32 reputation_horde = it->second; - uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; - uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; - - // select old standing set in db - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, oldReputation); - stmt->setUInt32(1, lowGuid); - PreparedQueryResult result = CharacterDatabase.Query(stmt); - - if (!result) + // Item conversion + for (std::map::const_iterator it = sObjectMgr->FactionChange_Items.begin(); it != sObjectMgr->FactionChange_Items.end(); ++it) { - WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); - data << uint8(CHAR_CREATE_ERROR); - SendPacket(&data); - return; + uint32 item_alliance = it->first; + uint32 item_horde = it->second; + + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? item_alliance : item_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? item_horde : item_alliance)); + stmt->setUInt32(2, guid); + trans->Append(stmt); } - Field* fields = result->Fetch(); - int32 oldDBRep = fields[0].GetInt32(); - FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); + // Spell conversion + for (std::map::const_iterator it = sObjectMgr->FactionChange_Spells.begin(); it != sObjectMgr->FactionChange_Spells.end(); ++it) + { + uint32 spell_alliance = it->first; + uint32 spell_horde = it->second; - // old base reputation - int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // new base reputation - int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE); + stmt->setUInt32(0, (team == TEAM_ALLIANCE ? spell_alliance : spell_horde)); + stmt->setUInt32(1, (team == TEAM_ALLIANCE ? spell_horde : spell_alliance)); + stmt->setUInt32(2, lowGuid); + trans->Append(stmt); + } - // final reputation shouldnt change - int32 FinalRep = oldDBRep + oldBaseRep; - int32 newDBRep = FinalRep - newBaseRep; + // Reputation conversion + for (std::map::const_iterator it = sObjectMgr->FactionChange_Reputation.begin(); it != sObjectMgr->FactionChange_Reputation.end(); ++it) + { + uint32 reputation_alliance = it->first; + uint32 reputation_horde = it->second; + uint32 newReputation = (team == TEAM_ALLIANCE) ? reputation_alliance : reputation_horde; + uint32 oldReputation = (team == TEAM_ALLIANCE) ? reputation_horde : reputation_alliance; + + // select old standing set in db + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, oldReputation); + stmt->setUInt32(1, lowGuid); + PreparedQueryResult result = CharacterDatabase.Query(stmt); - stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, newReputation); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + if (!result) + { + WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1); + data << uint8(CHAR_CREATE_ERROR); + SendPacket(&data); + return; + } - stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); - stmt->setUInt16(0, uint16(newReputation)); - stmt->setInt32(1, newDBRep); - stmt->setUInt16(2, uint16(oldReputation)); - stmt->setUInt32(3, lowGuid); - trans->Append(stmt); - } + Field* fields = result->Fetch(); + int32 oldDBRep = fields[0].GetInt32(); + FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation); - // Title conversion - if (knownTitlesStr) - { - const uint32 ktcount = KNOWN_TITLES_SIZE * 2; - uint32 knownTitles[ktcount]; - Tokenizer tokens(knownTitlesStr, ' ', ktcount); + // old base reputation + int32 oldBaseRep = sObjectMgr->GetBaseReputationOff(factionEntry, oldRace, playerClass); - if (tokens.size() != ktcount) - return; + // new base reputation + int32 newBaseRep = sObjectMgr->GetBaseReputationOff(sFactionStore.LookupEntry(newReputation), race, playerClass); - for (uint32 index = 0; index < ktcount; ++index) - knownTitles[index] = atol(tokens[index]); + // final reputation shouldnt change + int32 FinalRep = oldDBRep + oldBaseRep; + int32 newDBRep = FinalRep - newBaseRep; - for (std::map::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) + stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION); + stmt->setUInt32(0, newReputation); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); + + stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); + stmt->setUInt16(0, uint16(newReputation)); + stmt->setInt32(1, newDBRep); + stmt->setUInt16(2, uint16(oldReputation)); + stmt->setUInt32(3, lowGuid); + trans->Append(stmt); + } + + // Title conversion + if (knownTitlesStr) { - uint32 title_alliance = it->first; - uint32 title_horde = it->second; + const uint32 ktcount = KNOWN_TITLES_SIZE * 2; + uint32 knownTitles[ktcount]; + Tokenizer tokens(knownTitlesStr, ' ', ktcount); - CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); - CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); - // new team - if (team == TEAM_ALLIANCE) + if (tokens.size() != ktcount) + return; + + for (uint32 index = 0; index < ktcount; ++index) + knownTitles[index] = atol(tokens[index]); + + for (std::map::const_iterator it = sObjectMgr->FactionChange_Titles.begin(); it != sObjectMgr->FactionChange_Titles.end(); ++it) { - uint32 bitIndex = htitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (atitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + uint32 title_alliance = it->first; + uint32 title_horde = it->second; + + CharTitlesEntry const* atitleInfo = sCharTitlesStore.LookupEntry(title_alliance); + CharTitlesEntry const* htitleInfo = sCharTitlesStore.LookupEntry(title_horde); + // new team + if (team == TEAM_ALLIANCE) { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[atitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = htitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (atitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[atitleInfo->bit_index / 32] |= new_flag; + } } - } - else - { - uint32 bitIndex = atitleInfo->bit_index; - uint32 index = bitIndex / 32; - uint32 old_flag = 1 << (bitIndex % 32); - uint32 new_flag = 1 << (htitleInfo->bit_index % 32); - if (knownTitles[index] & old_flag) + else { - knownTitles[index] &= ~old_flag; - // use index of the new title - knownTitles[htitleInfo->bit_index / 32] |= new_flag; + uint32 bitIndex = atitleInfo->bit_index; + uint32 index = bitIndex / 32; + uint32 old_flag = 1 << (bitIndex % 32); + uint32 new_flag = 1 << (htitleInfo->bit_index % 32); + if (knownTitles[index] & old_flag) + { + knownTitles[index] &= ~old_flag; + // use index of the new title + knownTitles[htitleInfo->bit_index / 32] |= new_flag; + } } - } - std::ostringstream ss; - for (uint32 index = 0; index < ktcount; ++index) - ss << knownTitles[index] << ' '; + std::ostringstream ss; + for (uint32 index = 0; index < ktcount; ++index) + ss << knownTitles[index] << ' '; - PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); - stmt->setString(0, ss.str().c_str()); - stmt->setUInt32(1, lowGuid); - trans->Append(stmt); + PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE); + stmt->setString(0, ss.str().c_str()); + stmt->setUInt32(1, lowGuid); + trans->Append(stmt); - // unset any currently chosen title - stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); - stmt->setUInt32(0, lowGuid); - trans->Append(stmt); + // unset any currently chosen title + stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE); + stmt->setUInt32(0, lowGuid); + trans->Append(stmt); + } } } } @@ -2119,7 +2119,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data) CharacterDatabase.CommitTransaction(trans); std::string IP_str = GetRemoteAddress(); - sLog->outDebug(LOG_FILTER_UNITS, "Account: %d (IP: %s), Character guid: %u Change Race/Faction to: %s", GetAccountId(), IP_str.c_str(), lowGuid, newname.c_str()); + sLog->outDebug(LOG_FILTER_PLAYER, "%s (IP: %s) changed race from %u to %u", GetPlayerInfo().c_str(), IP_str.c_str(), oldRace, race); WorldPacket data(SMSG_CHAR_FACTION_CHANGE, 1 + 8 + (newname.size() + 1) + 1 + 1 + 1 + 1 + 1 + 1 + 1); data << uint8(RESPONSE_SUCCESS); diff --git a/src/server/scripts/Events/childrens_week.cpp b/src/server/scripts/Events/childrens_week.cpp index d09d82130de..c4d3650868d 100644 --- a/src/server/scripts/Events/childrens_week.cpp +++ b/src/server/scripts/Events/childrens_week.cpp @@ -85,7 +85,7 @@ enum Quests QUEST_STONEWROUGHT_DAM = 1558, QUEST_DARK_PORTAL_H = 10951, QUEST_DARK_PORTAL_A = 10952, - QUEST_LORDAERON_THRONE_ROOM = 1800, + QUEST_LORDAERON_THRONE_ROOM = 1800, QUEST_AUCHINDOUN_AND_THE_RING = 10950, QUEST_TIME_TO_VISIT_THE_CAVERNS_H = 10963, QUEST_TIME_TO_VISIT_THE_CAVERNS_A = 10962, @@ -114,7 +114,7 @@ enum Areatriggers NPC_EXODAR_01_CW_TRIGGER = 22851, NPC_EXODAR_02_CW_TRIGGER = 22905, NPC_AERIS_LANDING_CW_TRIGGER = 22838, - NPC_AUCHINDOUN_CW_TRIGGER = 22831, + NPC_AUCHINDOUN_CW_TRIGGER = 22831, NPC_SPOREGGAR_CW_TRIGGER = 22829, NPC_THRONE_OF_ELEMENTS_CW_TRIGGER = 22839, NPC_SILVERMOON_01_CW_TRIGGER = 22866, @@ -159,7 +159,7 @@ class npc_winterfin_playmate : public CreatureScript } void MoveInLineOfSight(Unit* who) - { + { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_PLAYMATE_ORACLE) == QUEST_STATUS_INCOMPLETE) @@ -188,7 +188,7 @@ class npc_winterfin_playmate : public CreatureScript switch(phase) { - case 1: + case 1: orphan->GetMotionMaster()->MovePoint(0, me->GetPositionX() + cos(me->GetOrientation()) * 5,me->GetPositionY() + sin(me->GetOrientation()) * 5, me->GetPositionZ()); orphan->AI()->Talk(TEXT_ORACLE_ORPHAN_1); timer = 3000; @@ -256,7 +256,7 @@ class npc_snowfall_glade_playmate : public CreatureScript } void MoveInLineOfSight(Unit* who) - { + { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_PLAYMATE_WOLVAR) == QUEST_STATUS_INCOMPLETE) @@ -273,7 +273,7 @@ class npc_snowfall_glade_playmate : public CreatureScript return; if (timer <= diff) - { + { Player* player = Player::GetPlayer(*me, playerGUID); Creature* orphan = Creature::GetCreature(*me, orphanGUID); @@ -401,7 +401,7 @@ class npc_the_biggest_tree : public CreatureScript } ++phase; } - else + else timer -= diff; } @@ -440,7 +440,7 @@ class npc_high_oracle_soo_roo : public CreatureScript } void MoveInLineOfSight(Unit* who) - { + { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_ORACLE) == QUEST_STATUS_INCOMPLETE) @@ -527,7 +527,7 @@ class npc_elder_kekek : public CreatureScript } void MoveInLineOfSight(Unit* who) - { + { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_THE_BRONZE_DRAGONSHRINE_WOLVAR) == QUEST_STATUS_INCOMPLETE) @@ -577,7 +577,7 @@ class npc_elder_kekek : public CreatureScript else timer -= diff; } - + private: uint32 timer; int8 phase; @@ -594,7 +594,7 @@ class npc_elder_kekek : public CreatureScript /*###### ## npc_the_etymidian -## TODO: A red crystal as a gift for the great one should be spawned during the event. +## TODO: A red crystal as a gift for the great one should be spawned during the event. ######*/ class npc_the_etymidian : public CreatureScript { @@ -614,7 +614,7 @@ class npc_the_etymidian : public CreatureScript } void MoveInLineOfSight(Unit* who) - { + { if (!phase && who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) == QUEST_STATUS_INCOMPLETE) @@ -936,7 +936,7 @@ class npc_cw_area_trigger : public CreatureScript questId = QUEST_THE_SEAT_OF_THE_NARUU; orphanId = ORPHAN_DRAENEI; break; - case NPC_EXODAR_02_CW_TRIGGER: + case NPC_EXODAR_02_CW_TRIGGER: questId = QUEST_CALL_ON_THE_FARSEER; orphanId = ORPHAN_DRAENEI; break; @@ -959,27 +959,27 @@ class npc_cw_area_trigger : public CreatureScript case NPC_SILVERMOON_01_CW_TRIGGER: if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_INCOMPLETE && getOrphanGUID(player, ORPHAN_BLOOD_ELF)) { - player->AreaExploredOrEventHappens(QUEST_NOW_WHEN_I_GROW_UP); + player->AreaExploredOrEventHappens(QUEST_NOW_WHEN_I_GROW_UP); if (player->GetQuestStatus(QUEST_NOW_WHEN_I_GROW_UP) == QUEST_STATUS_COMPLETE) if (Creature* samuro = me->FindNearestCreature(25151, 20.0f)) { uint32 emote = 0; switch(urand(1,5)) { - case 1: - emote = EMOTE_ONESHOT_WAVE; + case 1: + emote = EMOTE_ONESHOT_WAVE; break; case 2: - emote = EMOTE_ONESHOT_ROAR; + emote = EMOTE_ONESHOT_ROAR; break; - case 3: - emote = EMOTE_ONESHOT_FLEX; + case 3: + emote = EMOTE_ONESHOT_FLEX; break; case 4: - emote = EMOTE_ONESHOT_SALUTE; + emote = EMOTE_ONESHOT_SALUTE; break; - case 5: - emote = EMOTE_ONESHOT_DANCE; + case 5: + emote = EMOTE_ONESHOT_DANCE; break; } samuro->HandleEmoteCommand(emote); @@ -1009,13 +1009,13 @@ class npc_grizzlemaw_cw_trigger : public CreatureScript struct npc_grizzlemaw_cw_triggerAI : public ScriptedAI { - npc_grizzlemaw_cw_triggerAI(Creature* creature) : ScriptedAI (creature) + npc_grizzlemaw_cw_triggerAI(Creature* creature) : ScriptedAI (creature) { me->SetDisplayId(DISPLAY_INVISIBLE); } void MoveInLineOfSight(Unit* who) - { + { if (who && who->GetDistance2d(me) < 10.0f) if (Player* player = who->ToPlayer()) if (player->GetQuestStatus(QUEST_HOME_OF_THE_BEAR_MEN) == QUEST_STATUS_INCOMPLETE) diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index 059f513f12c..82739c0026a 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -369,7 +369,7 @@ class boss_halion : public CreatureScript { events.SetPhase(PHASE_TWO); Talk(SAY_PHASE_TWO); - + me->CastStop(); me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE); DoCast(me, SPELL_TWILIGHT_PHASING); @@ -1741,7 +1741,7 @@ void AddSC_boss_halion() { new boss_halion(); new boss_twilight_halion(); - + new npc_halion_controller(); new npc_meteor_strike_initial(); new npc_meteor_strike(); diff --git a/src/server/scripts/Northrend/sholazar_basin.cpp b/src/server/scripts/Northrend/sholazar_basin.cpp index d734b4b4e58..14319d26cf5 100644 --- a/src/server/scripts/Northrend/sholazar_basin.cpp +++ b/src/server/scripts/Northrend/sholazar_basin.cpp @@ -480,7 +480,7 @@ enum utils enum NesingwaryChildrensWeek { SPELL_ORPHAN_OUT = 58818, - + QUEST_THE_MIGHTY_HEMET_NESINGWARY = 13957, ORPHAN_WOLVAR = 33532, @@ -680,7 +680,7 @@ public: uint32 timer; int8 phase; uint64 playerGUID; - uint64 orphanGUID; + uint64 orphanGUID; }; CreatureAI* GetAI(Creature* creature) const diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index db35e84b930..67aeda314bf 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -246,7 +246,7 @@ class AreaTrigger_at_sholazar_waygate : public AreaTriggerScript bool OnTrigger(Player* player, AreaTriggerEntry const* trigger) { - if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE || + if (!player->isDead() && (player->GetQuestStatus(QUEST_MEETING_A_GREAT_ONE) != QUEST_STATUS_NONE || (player->GetQuestStatus(QUEST_THE_MAKERS_OVERLOOK) == QUEST_STATUS_REWARDED && player->GetQuestStatus(QUEST_THE_MAKERS_PERCH) == QUEST_STATUS_REWARDED))) { switch (trigger->id) -- cgit v1.2.3