Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
TotemAI.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
#include "
Creature.h
"
7
#include "
DBCStores.h
"
8
#include "
ObjectAccessor.h
"
9
#include "
SpellMgr.h
"
10
#include "
Totem.h
"
11
#include "
TotemAI.h
"
12
13
#include "
CellImpl.h
"
14
#include "
GridNotifiers.h
"
15
#include "
GridNotifiersImpl.h
"
16
17
int
TotemAI::Permissible
(
Creature
const
* creature)
18
{
19
if
(creature->
IsTotem
())
20
return
PERMIT_BASE_PROACTIVE
;
21
22
return
PERMIT_BASE_NO
;
23
}
24
25
TotemAI::TotemAI
(
Creature
* c) :
CreatureAI
(c),
i_victimGuid
(0)
26
{
27
ASSERT
(c->
IsTotem
());
28
}
29
30
void
TotemAI::MoveInLineOfSight
(
Unit
*
/*who*/
) { }
31
32
void
TotemAI::EnterEvadeMode
()
33
{
34
me
->CombatStop(
true
);
35
}
36
37
void
TotemAI::UpdateAI
(
uint32
/*diff*/
)
38
{
39
if
(
me
->ToTotem()->GetTotemType() !=
TOTEM_ACTIVE
)
40
return
;
41
42
if
(!
me
->IsAlive() ||
me
->IsNonMeleeSpellCasted(
false
))
43
return
;
44
45
// Search spell
46
SpellInfo
const
* spellInfo =
sSpellMgr
->GetSpellInfo(
me
->ToTotem()->GetSpell());
47
if
(!spellInfo)
48
return
;
49
50
// Get spell range
51
float
max_range = spellInfo->
GetMaxRange
(
false
);
52
53
// SPELLMOD_RANGE not applied in this place just because not existence range mods for attacking totems
54
55
// pointer to appropriate target if found any
56
Unit
* victim =
i_victimGuid
?
ObjectAccessor::GetUnit
(*
me
,
i_victimGuid
) : NULL;
57
58
// Search victim if no, not attackable, or out of range, or friendly (possible in case duel end)
59
if
(!victim ||
60
!victim->
isTargetableForAttack
() || !
me
->IsWithinDistInMap(victim, max_range) ||
61
me
->IsFriendlyTo(victim) || !
me
->CanSeeOrDetect(victim))
62
{
63
victim = NULL;
64
Skyfire::NearestAttackableUnitInObjectRangeCheck
u_check(
me
,
me
, max_range);
65
Skyfire::UnitLastSearcher<Skyfire::NearestAttackableUnitInObjectRangeCheck>
checker(
me
, victim, u_check);
66
me
->VisitNearbyObject(max_range, checker);
67
}
68
69
// If have target
70
if
(victim)
71
{
72
// remember
73
i_victimGuid
= victim->
GetGUID
();
74
75
// attack
76
me
->SetInFront(victim);
// client change orientation by self
77
me
->CastSpell(victim,
me
->ToTotem()->GetSpell(),
false
);
78
}
79
else
80
i_victimGuid
= 0;
81
}
82
83
void
TotemAI::AttackStart
(
Unit
*
/*victim*/
)
84
{
85
}
CellImpl.h
Creature.h
PERMIT_BASE_PROACTIVE
@ PERMIT_BASE_PROACTIVE
Definition
CreatureAI.h:183
PERMIT_BASE_NO
@ PERMIT_BASE_NO
Definition
CreatureAI.h:180
DBCStores.h
uint32
std::uint32_t uint32
Definition
Define.h:77
ASSERT
#define ASSERT
Definition
Errors.h:29
GridNotifiers.h
GridNotifiersImpl.h
ObjectAccessor.h
SpellMgr.h
sSpellMgr
#define sSpellMgr
Definition
SpellMgr.h:744
Totem.h
TOTEM_ACTIVE
@ TOTEM_ACTIVE
Definition
Totem.h:14
TotemAI.h
CreatureAI::CreatureAI
CreatureAI(Creature *creature)
Definition
CreatureAI.h:69
CreatureAI::me
Creature *const me
Definition
CreatureAI.h:56
Creature
Definition
Creature.h:427
ObjectAccessor::GetUnit
static Unit * GetUnit(WorldObject const &, uint64 guid)
Definition
ObjectAccessor.cpp:204
Object::GetGUID
uint64 GetGUID() const
Definition
Object.h:119
Skyfire::NearestAttackableUnitInObjectRangeCheck
Definition
GridNotifiers.h:933
SpellInfo
Definition
SpellInfo.h:158
SpellInfo::GetMaxRange
float GetMaxRange(bool positive=false, Unit *caster=NULL, Spell *spell=NULL) const
Definition
SpellInfo.cpp:1953
TotemAI::EnterEvadeMode
void EnterEvadeMode() OVERRIDE
Definition
TotemAI.cpp:32
TotemAI::UpdateAI
void UpdateAI(uint32 diff) OVERRIDE
== Triggered Actions Requested ==================
Definition
TotemAI.cpp:37
TotemAI::Permissible
static int Permissible(Creature const *creature)
Definition
TotemAI.cpp:17
TotemAI::AttackStart
void AttackStart(Unit *victim) OVERRIDE
Definition
TotemAI.cpp:83
TotemAI::TotemAI
TotemAI(Creature *c)
Definition
TotemAI.cpp:25
TotemAI::MoveInLineOfSight
void MoveInLineOfSight(Unit *who) OVERRIDE
Definition
TotemAI.cpp:30
TotemAI::i_victimGuid
uint64 i_victimGuid
Definition
TotemAI.h:28
Unit
Definition
Unit.h:1367
Unit::isTargetableForAttack
bool isTargetableForAttack(bool checkFakeDeath=true) const
Definition
Unit.cpp:3795
Unit::IsTotem
bool IsTotem() const
Definition
Unit.h:1519
Skyfire::UnitLastSearcher
Definition
GridNotifiers.h:380
src
server
game
AI
CoreAI
TotemAI.cpp
Generated on
for Project SkyFire Core by
1.17.0