Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
IdleMovementGenerator.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 "CreatureAI.h"
9#include <G3D/g3dmath.h>
10
12
13// StopMoving is needed to make unit stop if its last movement generator expires
14// But it should not be sent otherwise there are many redundent packets
16{
17 Reset(owner);
18}
19
21{
22 if (!owner->IsStopped())
23 owner->StopMoving();
24}
25
27{
28 if (!owner->IsStopped())
29 owner->StopMoving();
30
31 if (owner->GetVictim())
32 owner->SetInFront(owner->GetVictim());
33
35 owner->AttackStop();
36}
37
39{
40 float angle = owner->GetOrientation();
41 angle += (float(diff) * static_cast<float>(M_PI * 2) / m_maxDuration) * (m_direction == ROTATE_DIRECTION_LEFT ? 1.0f : -1.0f);
42 angle = G3D::wrap(angle, 0.0f, float(G3D::twoPi()));
43
44 owner->SetOrientation(angle); // UpdateSplinePosition does not set orientation with UNIT_STATE_ROTATING
45 owner->SetFacingTo(angle); // Send spline movement to clients
46
47 if (m_duration > diff)
48 m_duration -= diff;
49 else
50 return false;
51
52 return true;
53}
54
61
66
71
73{
74 if (time_diff > m_timer)
75 return false;
76
77 m_timer -= time_diff;
78 return true;
79}
80
#define M_PI
Definition Common.h:192
std::uint32_t uint32
Definition Define.h:77
IdleMovementGenerator si_idleMovement
@ ROTATE_DIRECTION_LEFT
@ ROTATE_MOTION_TYPE
@ TYPEID_UNIT
Definition Object.h:54
@ UNIT_STATE_DISTRACTED
Definition Unit.h:524
@ UNIT_STATE_ROTATING
Definition Unit.h:532
@ REACT_AGGRESSIVE
Definition Unit.h:1158
virtual void MovementInform(uint32, uint32)
Definition CreatureAI.h:118
void SetReactState(ReactStates st)
Definition Creature.h:460
CreatureAI * AI() const
Definition Creature.h:483
bool Update(Unit *, uint32) OVERRIDE
void Initialize(Unit *) OVERRIDE
void Reset(Unit *) OVERRIDE
TypeID GetTypeId() const
Definition Object.h:131
Creature * ToCreature()
Definition Object.h:207
bool Update(Unit *, uint32) OVERRIDE
void Finalize(Unit *) OVERRIDE
void Initialize(Unit *) OVERRIDE
Definition Unit.h:1367
void ClearUnitState(uint32 f)
Definition Unit.h:1489
bool IsStopped() const
Definition Unit.h:2614
void SetFacingTo(float ori)
Definition Unit.cpp:9114
void StopMoving()
-------—End of Pet responses methods-------—
Definition Unit.cpp:5877
void AddUnitState(uint32 f)
Definition Unit.h:1481
Unit * GetVictim() const
Definition Unit.h:1468
void SetInFront(WorldObject const *target)
Definition Unit.cpp:9108
bool AttackStop()
float GetOrientation() const
Definition Object.h:331
void SetOrientation(float orientation)
Definition Object.h:323