PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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/*
19 * Ordered alphabetically using scriptname.
20 * Scriptnames of files in this file should be prefixed with "npc_pet_gen_".
21 */
22
23#include "ScriptMgr.h"
24#include "ScriptedCreature.h"
25#include "Player.h"
26
27enum Mojo
28{
29    SAY_MOJO                = 0,
30
31    SPELL_FEELING_FROGGY    = 43906,
32    SPELL_SEDUCTION_VISUAL  = 43919
33};
34
35class npc_pet_gen_mojo : public CreatureScript
36{
37    public:
38        npc_pet_gen_mojo() : CreatureScript("npc_pet_gen_mojo") { }
39
40        struct npc_pet_gen_mojoAI : public ScriptedAI
41        {
42            npc_pet_gen_mojoAI(Creature* creature) : ScriptedAI(creature)
43            {
44            }
45
46            void Reset() override
47            {
48                _victimGUID.Clear();
49
50                if (Unit* owner = me->GetOwner())
51                    me->GetMotionMaster()->MoveFollow(owner, 0.0f, 0.0f);
52            }
53
54            void EnterCombat(Unit* /*who*/) override { }
55            void UpdateAI(uint32 /*diff*/) override { }
56
57            void ReceiveEmote(Player* player, uint32 emote) override
58            {
59                me->HandleEmoteCommand(emote);
60                Unit* owner = me->GetOwner();
61                if (emote != TEXT_EMOTE_KISS || !owner || owner->GetTypeId() != TYPEID_PLAYER ||
62                    owner->ToPlayer()->GetTeam() != player->GetTeam())
63                {
64                    return;
65                }
66
67                Talk(SAY_MOJO, player);
68
69                if (_victimGUID)
70                    if (Player* victim = ObjectAccessor::GetPlayer(*me, _victimGUID))
71                        victim->RemoveAura(SPELL_FEELING_FROGGY);
72
73                _victimGUID = player->GetGUID();
74
75                DoCast(player, SPELL_FEELING_FROGGY, true);
76                DoCast(me, SPELL_SEDUCTION_VISUAL, true);
77                me->GetMotionMaster()->MoveFollow(player, 0.0f, 0.0f);
78            }
79
80        private:
81            ObjectGuid _victimGUID;
82        };
83
84        CreatureAI* GetAI(Creature* creature) const override
85        {
86            return new npc_pet_gen_mojoAI(creature);
87        }
88};
89
90void AddSC_generic_pet_scripts()
91{
92    new npc_pet_gen_mojo();
93}