/src/server/scripts/Pet/pet_generic.cpp

https://gitlab.com/tkrokli/TrinityCore_434 · C++ · 93 lines · 56 code · 17 blank · 20 comment · 9 complexity · 7793ff51f2a7f11310156e5ee359cc99 MD5 · raw file

  1. /*
  2. * Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /*
  18. * Ordered alphabetically using scriptname.
  19. * Scriptnames of files in this file should be prefixed with "npc_pet_gen_".
  20. */
  21. #include "ScriptMgr.h"
  22. #include "ScriptedCreature.h"
  23. #include "Player.h"
  24. enum Mojo
  25. {
  26. SAY_MOJO = 0,
  27. SPELL_FEELING_FROGGY = 43906,
  28. SPELL_SEDUCTION_VISUAL = 43919
  29. };
  30. class npc_pet_gen_mojo : public CreatureScript
  31. {
  32. public:
  33. npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { }
  34. struct npc_pet_gen_mojoAI : public ScriptedAI
  35. {
  36. npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature)
  37. {
  38. }
  39. void Reset() override
  40. {
  41. _victimGUID.Clear();
  42. if (Unit* owner = me->GetOwner())
  43. me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
  44. }
  45. void EnterCombat(Unit* /*who*/) override { }
  46. void UpdateAI(uint32 /*diff*/) override { }
  47. void ReceiveEmote(Player* player, uint32 emote) override
  48. {
  49. me->HandleEmoteCommand(emote);
  50. Unit* owner = me->GetOwner();
  51. if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
  52. owner->ToPlayer()->GetTeam() != player->GetTeam())
  53. {
  54. return;
  55. }
  56. Talk(SAY_MOJO, player);
  57. if (_victimGUID)
  58. if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
  59. victim->RemoveAura(SPELL_FEELING_FROGGY);
  60. _victimGUID = player->GetGUID();
  61. DoCast(player, SPELL_FEELING_FROGGY, true);
  62. DoCast(me, SPELL_SEDUCTION_VISUAL, true);
  63. me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
  64. }
  65. private:
  66. ObjectGuid _victimGUID;
  67. };
  68. CreatureAI* GetAI(Creature* creature) const override
  69. {
  70. return new npc_pet_gen_mojoAI(creature);
  71. }
  72. };
  73. void AddSC_generic_pet_scripts()
  74. {
  75. new npc_pet_gen_mojo();
  76. }