Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
pet_hunter.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
/*
7
* Ordered alphabetically using scriptname.
8
* Scriptnames of files in this file should be prefixed with "npc_pet_hun_".
9
*/
10
11
#include "
ScriptMgr.h
"
12
#include "
ScriptedCreature.h
"
13
14
enum
HunterSpells
15
{
16
SPELL_HUNTER_CRIPPLING_POISON
= 30981,
// Viper
17
SPELL_HUNTER_DEADLY_POISON
= 34655,
// Venomous Snake
18
SPELL_HUNTER_MIND_NUMBING_POISON
= 25810
// Viper
19
};
20
21
enum
HunterCreatures
22
{
23
NPC_HUNTER_VIPER
= 19921
24
};
25
26
class
npc_pet_hunter_snake_trap
:
public
CreatureScript
27
{
28
public
:
29
npc_pet_hunter_snake_trap
() :
CreatureScript
(
"npc_pet_hunter_snake_trap"
) { }
30
31
struct
npc_pet_hunter_snake_trapAI
:
public
ScriptedAI
32
{
33
npc_pet_hunter_snake_trapAI
(
Creature
* creature) :
ScriptedAI
(creature) { }
34
35
void
EnterCombat
(
Unit
*
/*who*/
)
OVERRIDE
{ }
36
37
void
Reset
()
OVERRIDE
38
{
39
_spellTimer
= 0;
40
41
CreatureTemplate
const
* Info =
me
->GetCreatureTemplate();
42
43
_isViper
= Info->
Entry
==
NPC_HUNTER_VIPER
? true :
false
;
44
45
me
->SetMaxHealth(
uint32
(107 * (
me
->getLevel() - 40) * 0.025f));
46
// Add delta to make them not all hit the same time
47
uint32
delta = (rand() % 7) * 100;
48
me
->SetStatFloatValue(
UNIT_FIELD_ATTACK_ROUND_BASE_TIME
,
float
(Info->
baseattacktime
+ delta));
49
me
->SetStatFloatValue(
UNIT_FIELD_RANGED_ATTACK_POWER
,
float
(Info->
attackpower
));
50
51
// Start attacking attacker of owner on first ai update after spawn - move in line of sight may choose better target
52
if
(!
me
->GetVictim() &&
me
->IsSummon())
53
if
(
Unit
* Owner =
me
->ToTempSummon()->GetSummoner())
54
if
(Owner->getAttackerForHelper())
55
AttackStart
(Owner->getAttackerForHelper());
56
}
57
58
// Redefined for random target selection:
59
void
MoveInLineOfSight
(
Unit
* who)
OVERRIDE
60
{
61
if
(!
me
->GetVictim() &&
me
->CanCreatureAttack(who))
62
{
63
if
(
me
->GetDistanceZ(who) >
CREATURE_Z_ATTACK_RANGE
)
64
return
;
65
66
float
attackRadius =
me
->GetAttackDistance(who);
67
if
(
me
->IsWithinDistInMap(who, attackRadius) &&
me
->IsWithinLOSInMap(who))
68
{
69
if
(!(rand() % 5))
70
{
71
me
->setAttackTimer(
WeaponAttackType::BASE_ATTACK
, (rand() % 10) * 100);
72
_spellTimer
= (rand() % 10) * 100;
73
AttackStart
(who);
74
}
75
}
76
}
77
}
78
79
void
UpdateAI
(
uint32
diff)
OVERRIDE
80
{
81
if
(!
UpdateVictim
())
82
return
;
83
84
if
(
me
->GetVictim()->HasBreakableByDamageCrowdControlAura(
me
))
85
{
86
me
->InterruptNonMeleeSpells(
false
);
87
return
;
88
}
89
90
if
(
_spellTimer
<= diff)
91
{
92
if
(
_isViper
)
// Viper
93
{
94
if
((std::rand() % 2) == 0)
//33% chance to cast
95
{
96
uint32
spell;
97
if
((std::rand() % 1) == 0)
98
spell =
SPELL_HUNTER_MIND_NUMBING_POISON
;
99
else
100
spell =
SPELL_HUNTER_CRIPPLING_POISON
;
101
102
DoCastVictim
(spell);
103
}
104
105
_spellTimer
= 3000;
106
}
107
else
// Venomous Snake
108
{
109
if
((std::rand() % 2) == 0)
// 33% chance to cast
110
DoCastVictim
(
SPELL_HUNTER_DEADLY_POISON
);
111
_spellTimer
= 1500 + (rand() % 5) * 100;
112
}
113
}
114
else
115
_spellTimer
-= diff;
116
117
DoMeleeAttackIfReady
();
118
}
119
120
private
:
121
bool
_isViper
;
122
uint32
_spellTimer
;
123
};
124
125
CreatureAI
*
GetAI
(
Creature
* creature)
const
OVERRIDE
126
{
127
return
new
npc_pet_hunter_snake_trapAI
(creature);
128
}
129
};
130
131
void
AddSC_hunter_pet_scripts
()
132
{
133
new
npc_pet_hunter_snake_trap
();
134
}
CREATURE_Z_ATTACK_RANGE
#define CREATURE_Z_ATTACK_RANGE
Definition
Creature.h:422
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
ScriptMgr.h
ScriptedCreature.h
WeaponAttackType::BASE_ATTACK
@ BASE_ATTACK
Definition
Unit.h:573
UNIT_FIELD_ATTACK_ROUND_BASE_TIME
@ UNIT_FIELD_ATTACK_ROUND_BASE_TIME
Definition
UpdateFields.h:85
UNIT_FIELD_RANGED_ATTACK_POWER
@ UNIT_FIELD_RANGED_ATTACK_POWER
Definition
UpdateFields.h:122
HunterSpells
HunterSpells
Definition
boss_priestess_delrissa.cpp:982
CreatureAI
Definition
CreatureAI.h:54
CreatureAI::UpdateVictim
bool UpdateVictim()
Definition
CreatureAI.cpp:192
Creature
Definition
Creature.h:427
CreatureScript::CreatureScript
CreatureScript(const char *name)
Definition
ScriptMgr.cpp:1436
UnitAI::DoMeleeAttackIfReady
void DoMeleeAttackIfReady()
Definition
UnitAI.cpp:28
UnitAI::DoCastVictim
void DoCastVictim(uint32 spellId, bool triggered=false)
Definition
UnitAI.cpp:168
Unit
Definition
Unit.h:1367
npc_pet_hunter_snake_trap
Definition
pet_hunter.cpp:27
npc_pet_hunter_snake_trap::GetAI
CreatureAI * GetAI(Creature *creature) const OVERRIDE
Definition
pet_hunter.cpp:125
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trap
npc_pet_hunter_snake_trap()
Definition
pet_hunter.cpp:29
SPELL_HUNTER_CRIPPLING_POISON
@ SPELL_HUNTER_CRIPPLING_POISON
Definition
pet_hunter.cpp:16
SPELL_HUNTER_DEADLY_POISON
@ SPELL_HUNTER_DEADLY_POISON
Definition
pet_hunter.cpp:17
SPELL_HUNTER_MIND_NUMBING_POISON
@ SPELL_HUNTER_MIND_NUMBING_POISON
Definition
pet_hunter.cpp:18
HunterCreatures
HunterCreatures
Definition
pet_hunter.cpp:22
NPC_HUNTER_VIPER
@ NPC_HUNTER_VIPER
Definition
pet_hunter.cpp:23
AddSC_hunter_pet_scripts
void AddSC_hunter_pet_scripts()
Definition
pet_hunter.cpp:131
CreatureTemplate
Definition
Creature.h:63
CreatureTemplate::Entry
uint32 Entry
Definition
Creature.h:64
CreatureTemplate::attackpower
uint32 attackpower
Definition
Creature.h:89
CreatureTemplate::baseattacktime
uint32 baseattacktime
Definition
Creature.h:91
ScriptedAI::me
Creature * me
Definition
ScriptedCreature.h:182
ScriptedAI::ScriptedAI
ScriptedAI(Creature *creature)
Definition
ScriptedCreature.cpp:85
ScriptedAI::AttackStart
void AttackStart(Unit *) OVERRIDE
Definition
ScriptedCreature.cpp:118
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI
Definition
pet_hunter.cpp:32
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::_isViper
bool _isViper
Definition
pet_hunter.cpp:121
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::Reset
void Reset() OVERRIDE
Definition
pet_hunter.cpp:37
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::MoveInLineOfSight
void MoveInLineOfSight(Unit *who) OVERRIDE
Definition
pet_hunter.cpp:59
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
pet_hunter.cpp:79
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::_spellTimer
uint32 _spellTimer
Definition
pet_hunter.cpp:122
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::EnterCombat
void EnterCombat(Unit *) OVERRIDE
Definition
pet_hunter.cpp:35
npc_pet_hunter_snake_trap::npc_pet_hunter_snake_trapAI::npc_pet_hunter_snake_trapAI
npc_pet_hunter_snake_trapAI(Creature *creature)
Definition
pet_hunter.cpp:33
src
server
scripts
Pet
pet_hunter.cpp
Generated on
for Project SkyFire Core by
1.17.0