//// MxWoW Official Module //// Servant //// Dev: mikx //// Git: https://mxgit.ovh/MxWoW/mod_mxwow_servant //// Credits: //// based on works by gtao725 "mod-npc-buffer" https://github.com/azerothcore/mod-npc-buffer //// based on works by acidmanifesto "mod-npc-services" https://github.com/azerothcore/mod-npc-services #include "Define.h" #include "GossipDef.h" #include "Item.h" #include "Player.h" #include "ScriptedGossip.h" #include "ScriptMgr.h" #include "Spell.h" #include "Configuration/Config.h" #include "Chat.h" enum ServantString { MXW_SERVANT_ACORE_STRING_MESSAGE = 60000 }; class mxwow_servantPlayer : public PlayerScript { public: mxwow_servantPlayer() : PlayerScript("mxwow_servantPlayer") { } void OnPlayerLogin(Player* player) override { } }; class mxwow_servantCreature : public CreatureScript { public: mxwow_servantCreature() : CreatureScript("mxwow_servantCreature") { } bool OnGossipHello(Player* player, Creature* creature) override { if (!sConfigMgr->GetOption("MxWoW_Servant.Enabled", true)) return false; AddGossipItemFor(player, 10, "|TInterface/Icons/inv_hammer_08:30:30:-18|t Réparer (Tout)", GOSSIP_SENDER_MAIN, 1); AddGossipItemFor(player, 10, "|TInterface/Icons/inv_misc_enggizmos_18:30:30:-18|t Banque", GOSSIP_SENDER_MAIN, 2); AddGossipItemFor(player, 10, "|TInterface/Icons/inv_misc_enggizmos_18:30:30:-18|t Banque de Guilde", GOSSIP_SENDER_MAIN, 3); AddGossipItemFor(player, 10, "|TInterface/Icons/INV_Letter_11:30:30:-18|t Courrier", GOSSIP_SENDER_MAIN, 4); AddGossipItemFor(player, 10, "|TInterface/Icons/spell_shadow_teleport:30:30:-18|t Buff", GOSSIP_SENDER_MAIN, 5); AddGossipItemFor(player, 10, "|TInterface/Icons/Achievement_BG_AB_defendflags:30:30:-18|t Mettre fin au combat", GOSSIP_SENDER_MAIN, 6); AddGossipItemFor(player, 10, "|TInterface/Icons/inv_misc_bag_11:30:30:-18|t Marchant", GOSSIP_SENDER_MAIN, 7); AddGossipItemFor(player, 10, "|TInterface/Icons/inv_misc_coin_17:30:30:-18|t Enchère", GOSSIP_SENDER_MAIN, 8); AddGossipItemFor(player, 10, "|TInterface/Icons/Ability_paladin_beaconoflight:30:30:-18|t Transmo", GOSSIP_SENDER_MAIN, 9); AddGossipItemFor(player, 10, "|TInterface/Icons/inv_crate_01:30:30:-18|t Matériaux", GOSSIP_SENDER_MAIN, 10); AddGossipItemFor(player, 10, "|TInterface/Icons/spell_nature_polymorph:30:30:-18|t Étable", GOSSIP_SENDER_MAIN, 11); SendGossipMenuFor(player, 20000000, creature->GetGUID()); return true; } bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action) override { player->PlayerTalkClass->ClearMenus(); uint32 pLevel = player->GetLevel(); switch (action) { case 1: CloseGossipMenuFor(player); player->DurabilityRepairAll(true, 0, false); player->CastSpell(player, 31726); break; case 2: CloseGossipMenuFor(player); player->GetSession()->SendShowBank(player->GetGUID()); player->CastSpell(player, 31726); break; case 3: CloseGossipMenuFor(player); SummonTempNPC(player, 9000003, 300000); player->CastSpell(player, 31726); break; case 4: CloseGossipMenuFor(player); player->GetSession()->SendShowMailBox(player->GetGUID()); break; case 5: CloseGossipMenuFor(player); if (player->GetMap()->IsDungeon() || player->GetMap()->IsRaid()) { if (pLevel < 10) { // Dish out the buffs player->CastSpell(player, 21562, true); // Prayer of Fortitude (Rank 1) player->CastSpell(player, 1126, true); // Mark of the Wild (Rank 1) player->CastSpell(player, 27683, true); // Prayer of Shadow Protection (Rank 1) } // 1-9 else if (pLevel >= 10 && pLevel < 20) { player->CastSpell(player, 21562, true); // Prayer of Fortitude (Rank 1) player->CastSpell(player, 1126, true); // Mark of the Wild (Rank 1) player->CastSpell(player, 27683, true); // Prayer of Shadow Protection (Rank 1) } // 10-19 else if (pLevel >= 20 && pLevel < 30) { player->CastSpell(player, 21562, true); // Prayer of Fortitude (Rank 1) player->CastSpell(player, 1126, true); // Mark of the Wild (Rank 1) player->CastSpell(player, 27683, true); // Prayer of Shadow Protection (Rank 1) player->CastSpell(player, 13326, true); // Arcane Intellect (Rank 1) } // 20-29 else if (pLevel >= 30 && pLevel < 40) { player->CastSpell(player, 21562, true); // Prayer of Fortitude (Rank 1) player->CastSpell(player, 25898, true); // Greater Blessing of Kings (Rank 1) player->CastSpell(player, 1126, true); // Mark of the Wild (Rank 1) player->CastSpell(player, 27681, true); // Prayer of Spirit (Rank 1) player->CastSpell(player, 27683, true); // Prayer of Shadow Protection (Rank 1) player->CastSpell(player, 13326, true); // Arcane Intellect (Rank 1) } // 30-39 else if (pLevel >= 40 && pLevel < 50) { player->CastSpell(player, 21562, true); // Prayer of Fortitude (Rank 1) player->CastSpell(player, 48469, true); // Mark of the Wild(48469) player->CastSpell(player, 27681, true); // Prayer of Spirit (Rank 1) player->CastSpell(player, 48170, true); // Prayer of Shadow Protection(48170) player->CastSpell(player, 13326, true); // Arcane Intellect (Rank 1) } // 40-49 else if (pLevel >= 50 && pLevel < 60) { player->CastSpell(player, 48162, true); // Prayer of Fortitude(48162) player->CastSpell(player, 43223, true); // Greater Blessing of Kings(43223) player->CastSpell(player, 48469, true); // Mark of the Wild(48469) player->CastSpell(player, 48074, true); // Prayer of Spirit(48074) player->CastSpell(player, 48170, true); // Prayer of Shadow Protection(48170) player->CastSpell(player, 36880, true); // Arcane Intellect(36880) } // 50-59 else if (pLevel >= 60 && pLevel < 70) { player->CastSpell(player, 48162, true); // Prayer of Fortitude(48162) player->CastSpell(player, 43223, true); // Greater Blessing of Kings(43223) player->CastSpell(player, 48469, true); // Mark of the Wild(48469) player->CastSpell(player, 48074, true); // Prayer of Spirit(48074) player->CastSpell(player, 48170, true); // Prayer of Shadow Protection(48170) player->CastSpell(player, 36880, true); // Arcane Intellect(36880) } // 60-69 else if (pLevel >= 70 && pLevel < 80) { player->CastSpell(player, 48162, true); // Prayer of Fortitude(48162) player->CastSpell(player, 43223, true); // Greater Blessing of Kings(43223) player->CastSpell(player, 48469, true); // Mark of the Wild(48469) player->CastSpell(player, 48074, true); // Prayer of Spirit(48074) player->CastSpell(player, 48170, true); // Prayer of Shadow Protection(48170) player->CastSpell(player, 36880, true); // Arcane Intellect(36880) } // 70-79 else { player->CastSpell(player, 48162, true); // Prayer of Fortitude(48162) player->CastSpell(player, 43223, true); // Greater Blessing of Kings(43223) player->CastSpell(player, 48469, true); // Mark of the Wild(48469) player->CastSpell(player, 48074, true); // Prayer of Spirit(48074) player->CastSpell(player, 48170, true); // Prayer of Shadow Protection(48170) player->CastSpell(player, 36880, true); // Arcane Intellect(36880) } // LEVEL 80 } else { ChatHandler(player->GetSession()).SendSysMessage(MXW_SERVANT_ACORE_STRING_MESSAGE); } player->CastSpell(player, 31726); break; case 6: CloseGossipMenuFor(player); player->CombatStop(); player->CastSpell(player, 31726); break; case 7: CloseGossipMenuFor(player); player->GetSession()->SendListInventory(creature->GetGUID()); player->CastSpell(player, 31726); break; case 8: CloseGossipMenuFor(player); //SummonTempNPC(player, 8670, 300000); player->GetSession()->SendAuctionHello(creature->GetGUID(), creature); player->CastSpell(player, 31726); break; case 9: CloseGossipMenuFor(player); SummonTempNPC(player, 190010, 300000); player->CastSpell(player, 31726); break; case 10: CloseGossipMenuFor(player); SummonTempNPC(player, 290011, 300000); player->CastSpell(player, 31726); break; case 11: CloseGossipMenuFor(player); player->GetSession()->SendStablePet(creature->GetGUID()); player->CastSpell(player, 31726); break; } return true; } void SummonTempNPC(Player* player, uint32 entry, uint32 despawn) { if (!player || entry == 0) return; Creature* npc = player->SummonCreature(entry, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); npc->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); npc->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle()); npc->SetFaction(player->GetFaction()); std::ostringstream ss; ss << "Salut " << player->GetName() << "! Je suis à ton service pour 5 minutes."; npc->Whisper(ss.str().c_str(), LANG_UNIVERSAL, player, false); } }; class mxwow_servantItem : public ItemScript { public: mxwow_servantItem() : ItemScript("mxwow_servantItem") { } bool OnUse(Player* p, Item* i, SpellCastTargets const& /*targets*/) override { p->PlayerTalkClass->ClearMenus(); SummonTempNPC(p, 9000001, 120000); return true; } void SummonTempNPC(Player* player, uint32 entry, uint32 despawn) { if (!player || entry == 0) return; Creature* npc = player->SummonCreature(entry, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 120000); npc->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); npc->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle()); npc->SetFaction(player->GetFaction()); std::ostringstream ss; ss << "Salut " << player->GetName() << "! Je suis à ton service pour 2 minutes."; npc->Whisper(ss.str().c_str(), LANG_UNIVERSAL, player, false); } }; void AddMxWoWServantScripts() { new mxwow_servantPlayer(); new mxwow_servantCreature(); new mxwow_servantItem(); }