forked from EQEmu/Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathheal_rotation.h
161 lines (126 loc) · 5.2 KB
/
heal_rotation.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* EQEMu: Everquest Server Emulator
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemulator.org)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY except by those people which sell it, which
are required to give you total support for your newly bought product;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef HEAL_ROTATION_H
#define HEAL_ROTATION_H
#include "mob.h"
#define CASTING_CYCLE_MINIMUM_INTERVAL 1000
#define CASTING_CYCLE_MINIMUM_INTERVAL_S 1
#define CASTING_CYCLE_MAXIMUM_INTERVAL 30000
#define CASTING_CYCLE_MAXIMUM_INTERVAL_S 30
#define CASTING_CYCLE_DEFAULT_INTERVAL 5000
#define CASTING_CYCLE_DEFAULT_INTERVAL_S 5
#define POKE_PROPAGATION_DELAY 250
#define ADVANCE_ROTATION_MINIMUM_INTERVAL 100
#define HEALING_STATS_RESET_INTERVAL 60000
#define HEALING_STATS_RESET_INTERVAL_S 60
#define SAFE_HP_RATIO_ABS 100.0f
#define SAFE_HP_RATIO_BASE 95.0f
#define CRITICAL_HP_RATIO_ABS 0.0f
#define CRITICAL_HP_RATIO_BASE 30.0f
struct HealingStats
{
uint32 last_heal_time_ms;
uint32 heal_count;
};
// Both members and targets use a shared_ptr to keep track of their HealRotation instance
class HealRotation
{
public:
HealRotation(Bot* hr_creator, uint32 interval_ms = CASTING_CYCLE_DEFAULT_INTERVAL, bool fast_heals = false, bool adaptive_targeting = false, bool casting_override = false);
HealRotation(HealRotation* allocator_shunt) {}; // use should be limited to the shared_ptr<HealRotation> memory allocation call
void SetIntervalMS(uint32 interval_ms);
void SetIntervalS(uint32 interval_s);
void SetFastHeals(bool flag) { m_fast_heals = flag; }
void SetAdaptiveTargeting(bool flag) { m_adaptive_targeting = flag; }
void SetCastingOverride(bool flag) { m_casting_override = flag; }
bool AddMemberToPool(Bot* hr_member);
bool AddTargetToPool(Mob* hr_target);
uint32 CreationTimeMS() { return m_creation_time_ms; }
uint32 LastHealTimeMS() { return m_last_heal_time_ms; }
uint32 IntervalMS() { return m_interval_ms; }
uint32 IntervalS() { return (m_interval_ms / 1000); }
bool FastHeals() { return m_fast_heals; }
bool AdaptiveTargeting() { return m_adaptive_targeting; }
bool CastingOverride() { return m_casting_override; }
bool RemoveMemberFromPool(Bot* hr_member);
bool RemoveTargetFromPool(Mob* hr_target);
bool ClearMemberPool();
bool ClearTargetPool();
Mob* HOTTarget() { return m_hot_target; }
bool SetHOTTarget(Mob* hot_target);
bool ClearHOTTarget();
bool Start();
bool Stop();
bool IsActive() { return m_is_active; }
bool IsHOTActive() { return m_hot_active; }
bool CastingReady() { return (Timer::GetCurrentTime() >= m_next_cast_time_ms); }
Bot* CastingMember();
bool PokeCastingTarget();
Mob* CastingTarget();
bool AdvanceRotation(bool use_interval = true);
std::list<Bot*>* MemberList() { return &m_member_pool; }
std::list<Bot*>* CycleList() { return &m_cycle_pool; }
std::list<Mob*>* TargetList() { return &m_target_pool; }
bool IsMemberInPool(Bot* hr_member);
bool IsTargetInPool(Mob* hr_target);
bool IsHOTTarget(Mob* hot_target);
void SetMemberIsCasting(Bot* hr_member, bool flag = true);
bool MemberIsCasting(Bot* hr_member);
void UpdateTargetHealingStats(Mob* hr_target);
void StartNewTargetHealingStatsCycle(uint32 current_time);
uint32 HealCount(Mob* hr_target);
uint32 ExtendedHealCount(Mob* hr_target);
float HealFrequency(Mob* hr_target);
float ExtendedHealFrequency(Mob* hr_target);
HealingStats* TargetHealingStats1(Mob* hr_target);
HealingStats* TargetHealingStats2(Mob* hr_target);
bool SetArmorTypeSafeHPRatio(uint8 armor_type, float hp_ratio);
bool SetArmorTypeCriticalHPRatio(uint8 armor_type, float hp_ratio);
float ArmorTypeSafeHPRatio(uint8 armor_type);
float ArmorTypeCriticalHPRatio(uint8 armor_type);
void ResetArmorTypeHPLimits();
private:
bool valid_state();
void cycle_refresh();
bool healable_target(bool use_class_at = true, bool critical_only = false);
void bias_targets();
void validate_hot();
uint32 m_creation_time_ms;
uint32 m_last_heal_time_ms;
uint32 m_interval_ms;
uint32 m_next_cast_time_ms;
uint32 m_next_poke_time_ms;
uint32 m_healing_stats_begin_ms;
bool m_fast_heals;
bool m_adaptive_targeting;
bool m_casting_override;
bool m_casting_target_poke;
bool m_active_heal_target;
bool m_is_active;
bool m_consumed;
Mob* m_hot_target;
bool m_hot_active;
std::list<Bot*> m_member_pool;
std::list<Bot*> m_cycle_pool;
std::list<Mob*> m_target_pool;
std::map<Bot*, bool> m_member_is_casting;
std::map<Mob*, HealingStats> m_target_healing_stats_1;
std::map<Mob*, HealingStats> m_target_healing_stats_2;
float m_safe_hp_ratio[ARMOR_TYPE_COUNT];
float m_critical_hp_ratio[ARMOR_TYPE_COUNT];
};
bool IsHealRotationMemberClass(uint8 class_id);
bool IsHealRotationTargetMobType(Mob* target_mob);
#endif