TrinityCore
Loading...
Searching...
No Matches
drustvar_chapter_3_an_airtight_alibi.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
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#include "CreatureAI.h"
19#include "CreatureAIImpl.h"
20#include "MotionMaster.h"
21#include "ObjectAccessor.h"
22#include "Player.h"
23#include "ScriptMgr.h"
24#include "ScriptedCreature.h"
25#include "SpellInfo.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28
30{
31 // Creature
33
34 // Text
36
37 // Path
39
40 // Spells
42};
43
44// 126159 - Frightend Woodsman
46{
48
49 void SpellHit(WorldObject* caster, SpellInfo const* spellInfo) override
50 {
51 if (spellInfo->Id == SPELL_DRUSTVAR_WOODSMAN_RALLYING)
52 {
53 Player* player = caster->ToPlayer();
54 if (!player)
55 return;
56
58 if (Creature* woodsmanObject = player->FindNearestCreatureWithOptions(10.0f, { .CreatureId = NPC_FRIGHTEND_WOODSMAN, .IgnorePhases = true }))
59 woodsmanObject->SummonPersonalClone(woodsmanObject->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
60 }
61 }
62};
63
64// 126159 - Frightend Woodsman
66{
68
70 {
71 if (me->HasStringId("CosmeticWoodmansPath0"))
73 else if (me->HasStringId("CosmeticWoodmansPath1"))
75 else if (me->HasStringId("CosmeticWoodmansPath2"))
77 else if (me->HasStringId("CosmeticWoodmansPath3"))
79 else if (me->HasStringId("CosmeticWoodmansPath4"))
81 else if (me->HasStringId("CosmeticWoodmansPath5"))
83 else if (me->HasStringId("CosmeticWoodmansPath6"))
85 else if (me->HasStringId("CosmeticWoodmansPath7"))
87 else if (me->HasStringId("CosmeticWoodmansPath8"))
89 else if (me->HasStringId("CosmeticWoodmansPath9"))
91 else if (me->HasStringId("CosmeticWoodmansPath10"))
93 return 0;
94 }
95
96 void JustAppeared() override
97 {
98 me->SetUninteractible(true);
99 me->SetImmuneToAll(true);
100
101 _scheduler.Schedule(1s, [this](TaskContext const& /*task*/)
102 {
105 });
106
107 _scheduler.Schedule(3s, [this](TaskContext const& /*task*/)
108 {
109 me->GetMotionMaster()->MovePath(GetPathId(), false);
110 });
111 }
112
113 void WaypointPathEnded(uint32 /*nodeId*/, uint32 /*pathId*/) override
114 {
116 }
117
118 void UpdateAI(uint32 diff) override
119 {
120 _scheduler.Update(diff);
121 }
122
123private:
125};
126
128{
129 if (creature->IsPrivateObject())
130 return new npc_drustvar_frightend_woodsman_private(creature);
131 return new npc_drustvar_frightend_woodsman(creature);
132}
133
135{
136 // AISelector
137 new FactoryCreatureScript<CreatureAI, &FrightendWoodsmanAISelector>("npc_drustvar_frightend_woodsman_private");
138}
uint32_t uint32
Definition Define.h:154
@ TEMPSUMMON_MANUAL_DESPAWN
@ UNIT_NPC_FLAG_SPELLCLICK
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
bool HasStringId(std::string_view id) const
void SetImmuneToAll(bool apply) override
Definition Creature.h:181
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Player * ToPlayer()
Definition Object.h:126
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition Player.cpp:16679
uint32 const Id
Definition SpellInfo.h:328
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void RemoveNpcFlag(NPCFlags flags)
Definition Unit.h:998
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition Object.cpp:1526
bool IsPrivateObject() const
Definition Object.h:568
CreatureAI * FrightendWoodsmanAISelector(Creature *creature)
void AddSC_drustvar_chapter_3_an_airtight_alibi()
void SpellHit(WorldObject *caster, SpellInfo const *spellInfo) override