Horizon Official Technical Documentation
Combat.hpp
Go to the documentation of this file.
1/***************************************************
2 * _ _ _ *
3 * | | | | (_) *
4 * | |_| | ___ _ __ _ _______ _ __ *
5 * | _ |/ _ \| '__| |_ / _ \| '_ \ *
6 * | | | | (_) | | | |/ / (_) | | | | *
7 * \_| |_/\___/|_| |_/___\___/|_| |_| *
8 ***************************************************
9 * This file is part of Horizon (c).
10 *
11 * Copyright (c) 2019 Sagun K. (sagunxp@gmail.com).
12 * Copyright (c) 2019 Horizon Dev Team.
13 *
14 * Base Author - Sagun K. (sagunxp@gmail.com)
15 *
16 * This library is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License
27 * along with this library. If not, see <http://www.gnu.org/licenses/>.
28 **************************************************/
29
30#ifndef HORIZON_ZONE_GAME_ENTITIES_BATTLE_COMBAT_HPP
31#define HORIZON_ZONE_GAME_ENTITIES_BATTLE_COMBAT_HPP
32
38
39namespace Horizon
40{
41namespace Zone
42{
43
45{
46
47};
48
49class Damage;
50
52{
53public:
54 DamageHitType(Damage *damage, combat_damage_hit_type hit_type) : _damage(damage), _hit_type{hit_type} { }
55 ~DamageHitType() = default;
56
57 void set_hit_type(combat_damage_hit_type hit_type) { _hit_type = hit_type; }
59
60private:
61 Damage *_damage{nullptr};
63};
64
66{
67public:
68 DamageMultiAttackCount(Damage *damage, int16_t multi_attack_count) : _damage(damage), _multi_attack_count{multi_attack_count} { }
70
71 void set_multi_attack_count(int16_t multi_attack_count) { _multi_attack_count = multi_attack_count; }
73private:
74 Damage *_damage{nullptr};
76};
77
79{
80public:
81 DamageKnockBackCellCount(Damage *damage, int16_t knockback_cell_count) : _damage(damage), _knockback_cell_count{knockback_cell_count} { }
83
84 void set_knockback_cell_count(int16_t knockback_cell_count) { _knockback_cell_count = knockback_cell_count; }
86private:
87 Damage *_damage{nullptr};
89};
90
92{
93public:
95 ~DamageCritical() = default;
96
98 bool is_critical() { return _is_critical; }
99private:
100 Damage *_damage{nullptr};
101 bool _is_critical{false};
102};
104{
105public:
106 Damage(combat_damage_type_mask damage_type, std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, int32_t skill_id = 0, int32_t skill_lv = 0)
107 { }
108 ~Damage() = default;
109
110 void add_right_damage(int64_t damage) { _right_damage += damage; }
111 void sub_right_damage(int64_t damage) { _right_damage -= damage; }
112 int64_t get_right_damage() { return _right_damage; }
113 void set_right_damage(int64_t right_damage) { _right_damage = right_damage; }
114
115 void add_left_damage(int64_t damage) { _left_damage += damage; }
116 void sub_left_damage(int64_t damage) { _left_damage -= damage; }
117 int64_t get_left_damage() { return _left_damage; }
118 void set_left_damage(int64_t left_damage) { _left_damage = left_damage; }
119
120 void add_defense(int64_t defense) { _defense += defense; }
121 void sub_defense(int64_t defense) { _defense -= defense; }
122 int64_t get_defense() { return _defense; }
123 void set_defense(int64_t defense) { _defense = defense; }
124
125 void set_hit_type(combat_damage_hit_type hit_type) { _hit_type = hit_type; }
127
128 int64_t total() const { return calculate(); }
129
130 int64_t calculate() const { return _right_damage + _left_damage - _defense; }
131
132 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
133 TT operator + (TT right) { return total() + right; }
134 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
135 TT operator / (TT right) { return total() / right; }
136 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
137 TT operator * (TT right) { return total() * right; }
138 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
139 TT operator - (TT right) { return total() - right; }
140
141 int operator + (Damage const &right) const { return right.total() + total(); }
142 double operator / (Damage const &right) { return right.total() / total(); }
143 double operator * (Damage const &right) { return right.total() * total(); }
144 int operator - (Damage const &right) { return right.total() - total(); }
145
146 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
147 bool operator == (TT right) { return total() == right; }
148 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
149 bool operator != (TT right) { return total() != right; }
150 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
151 bool operator > (TT right) { return total() > right; }
152 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
153 bool operator >= (TT right) { return total() >= right; }
154 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
155 bool operator < (TT right) { return total() < right; }
156 template <typename TT, typename std::enable_if<std::is_integral<TT>::value>::type* = nullptr>
157 bool operator <= (TT right) { return total() <= right; }
158
159private:
162 std::weak_ptr<Unit> _source;
163 std::weak_ptr<Unit> _target;
164 int32_t _skill_id{0};
165 int32_t _skill_lv{0};
166 int64_t _right_damage{0};
167 int64_t _left_damage{0};
168 int64_t _defense{0};
169};
170
172{
173public:
175 {
181 };
182
184 {
185 public:
188 : _type(type) { }
189 virtual ~CombatOperationValue() = default;
190
192
194 {
195 _type = value._type;
196 }
197 private:
199 };
200
202 {
203 public:
205
206 explicit CombatValueInteger(int value)
208
210
211 int get_value() { return _value; }
212 private:
213 int _value{ 0 };
214 };
215
217 {
218 public:
223
225
226 private:
228 };
229
231 {
232 public:
236
238
240
241 private:
243 };
244
246 {
247 public:
249 {
257 };
258 virtual ~CombatOperand() = default;
259
260 virtual combat_operand_type get_type() { return _type; }
261
262 std::shared_ptr<Unit> get_source() { return _source; }
263 std::shared_ptr<Unit> get_target() { return _target; }
264
265 void set_source(std::shared_ptr<Unit> source) { _source = source; }
266 void set_target(std::shared_ptr<Unit> target) { _target = target; }
267
268protected:
269 CombatOperand() = delete;
270 CombatOperand(CombatOperand &operand) = delete;
271 CombatOperand(CombatOperand &&operand) = delete;
272
273 explicit CombatOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, combat_operand_type type)
274 : _source(source), _target(target), _type(type) { }
275
276 void operator=(const CombatOperand &operand) = delete;
277 void operator=(CombatOperand &&operand) = delete;
278
279 private:
281 std::shared_ptr<Unit> _source, _target;
282 };
283
285 {
286 public:
288 {
297 };
298
299 CombatOperation() = delete;
300 CombatOperation(const CombatOperation &right) = delete;
302
303 explicit CombatOperation(CombatOperand *operand, int operation_type, int operation_sub_type, CombatOperationValue *value)
304 : _operand(operand), _operation_type(operation_type), _operation_sub_type(operation_sub_type), _operation_value(value) { }
305
306 explicit CombatOperation(CombatOperand *operand, int operation_type, int operation_sub_type)
307 : _operand(operand), _operation_type(operation_type), _operation_sub_type(operation_sub_type) { }
308
310 {
311 if (_operand != nullptr)
312 delete _operand;
313 if (_operation_value != nullptr)
314 delete _operation_value;
315 }
316
317 virtual CombatOperand *get_operand() const { return _operand; }
318 int get_operation_type() const { return _operation_type; }
321
322 int get_priority() { return _priority; }
323 void set_priority(int priority) { _priority = priority; }
324
325 virtual void execute() const = 0;
326
327 void operator=(const CombatOperation &operation) = delete;
328
329 protected:
334 int _priority{ 0 };
335 };
336
338 {
339 public:
341 {
348 };
350 {
351 public:
353 explicit AttributeOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, std::shared_ptr<Traits::Attribute> attribute)
354 : _attribute(attribute), CombatOperand(source, target, COMBAT_OPERAND_ATTRIBUTE) { }
356
357 std::shared_ptr<Traits::Attribute> get_attribute() { return _attribute; }
358
359 void operator=(const AttributeOperand &operand)
360 {
361 _attribute = operand._attribute;
362 }
363 private:
364 std::shared_ptr<Traits::Attribute> _attribute;
365 };
366
368 : CombatOperation(operand, COMBAT_OPERATION_ATTRIBUTE, (int) operation_type, value) { }
370
371 void execute() const override;
372 };
373
375 {
376 public:
378 {
381 };
382
384 {
385 public:
387 {
389 };
390 StatusOperand() = delete;
391 StatusOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, s_combat_status_operation_config config)
392 : CombatOperand(source, target, COMBAT_OPERAND_STATUS), _config(config) { }
394
396
397 void operator=(const StatusOperand &operand)
398 {
399 _config = operand._config;
400 }
401 private:
403 };
404
405 StatusOperation() = delete;
406
408 : CombatOperation(operand, COMBAT_OPERATION_STATUS, (int) operation_type) { }
409
411
412 void execute() const override;
413 };
414
416 {
417 public:
419 {
423 };
424
426 {
427 public:
429 {
430 int skill_id{ 0 }, skill_lv{ 0 };
431 int16_t pos_x{ 0 };
432 int16_t pos_y{ 0 };
433 std::string contents{ "" };
434 std::shared_ptr<const skill_config_data> skd{nullptr};
435 std::shared_ptr<SkillExecution> skill_execution{nullptr};
438 sol::function cast_end_function;
439 sol::table skill_cast_data;
440
442 {
443 skill_id = config.skill_id;
444 skill_lv = config.skill_lv;
445 pos_x = config.pos_x;
446 pos_y = config.pos_y;
447 contents = config.contents;
448 skd = config.skd;
450 element = config.element;
451 cast_time = config.cast_time;
454 }
455 };
457 SkillExecutionOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, s_skill_execution_operation_config config)
458 : CombatOperand(source, target, COMBAT_OPERAND_SKILL_EXECUTION), _config(config) { }
460
462
463 void operator=(const SkillExecutionOperand &operand)
464 {
465 _config = operand._config;
466 }
467 private:
469 };
473 {}
474
476
477 void execute() const override;
478 };
479
481 {
482 public:
484 {
487 };
488
490 {
491 public:
493 {
494 int skill_id{ 0 }, skill_lv{ 0 };
495 int16_t pos_x;
496 int16_t pos_y;
497 std::string contents;
498 std::shared_ptr<const skill_config_data> skd;
502 };
504 SkillResultOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, s_skill_result_operation_config config)
505 : CombatOperand(source, target, COMBAT_OPERAND_SKILL_RESULT), _config(config) { }
507
509 private:
511 };
512
515 : CombatOperation(operand, COMBAT_OPERATION_SKILL_RESULT, (int) type, value)
516 {}
517
519 : CombatOperation(operand, COMBAT_OPERATION_SKILL_RESULT, (int) type, value)
520 {}
521
523
524 void execute() const override;
525 };
526
528 {
529 public:
531 {
533 };
534
536 {
537 public:
539 {
540 bool continuous{ false };
541 };
543 MeleeExecutionOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, s_melee_execution_operation_config config)
544 : CombatOperand(source, target, COMBAT_OPERAND_MELEE_EXECUTION), _config(config) { }
546
548 private:
550 };
551
553 : CombatOperation(operand, COMBAT_OPERATION_MELEE_EXECUTION, (int) type) { }
554
556
557 void execute() const override;
558 };
559
561 {
562 public:
564 {
567 };
568
570 {
571 public:
573 MeleeResultOperand(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target)
574 : CombatOperand(source, target, COMBAT_OPERAND_MELEE_RESULT) { }
576 };
577
579
581 : CombatOperation(operand, COMBAT_OPERATION_MELEE_RESULT, (int) type, value) { }
582
584 : CombatOperation(operand, COMBAT_OPERATION_MELEE_RESULT, (int) type, value) { }
585
587
588 void execute() const override;
589 };
590
591 // Define a comparison function for the priority queue
594 return op1->get_priority() < op2->get_priority();
595 }
596 };
597
599 {
600 public:
601 CombatStage(int priority) : _priority(priority) { }
603
604 void add_operation(CombatOperation *operation) { _operation_queue.push(operation); }
605
606 AttributeOperation *push_attribute_operation(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, std::shared_ptr<Traits::Attribute> attribute, CombatRegistry::AttributeOperation::attribute_operation_type operation_type, int value);
613 MeleeResultOperation *push_melee_result_damage_operation(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, combat_damage value_config);
614 MeleeResultOperation *push_melee_result_healing_operation(std::shared_ptr<Unit> source, std::shared_ptr<Unit> target, combat_healing value_config);
615
616 int get_priority() { return _priority; }
617 void set_priority(int priority) { _priority = priority; }
618
619 bool has_operations() { return !_operation_queue.empty(); }
621
623 void pop_queue() { _operation_queue.pop(); }
624 private:
625 int _priority{ 0 };
626 std::priority_queue<CombatOperation *, std::vector<CombatOperation *>, CompareCombatOperation> _operation_queue;
627 };
628
629 // Define a comparison function for the priority queue
632 return op1->get_priority() < op2->get_priority();
633 }
634 };
635
636 CombatRegistry(std::shared_ptr<Unit> unit);
638
639 std::shared_ptr<Unit> get_unit() { return _unit.lock(); }
640
641 CombatStage *create_combat_stage(int priority) { return new CombatStage(priority); }
642
644
645 void process_queue();
646
647private:
648 std::weak_ptr<Unit> _unit;
649 std::priority_queue<CombatStage *, std::vector<CombatStage *>, CompareCombatStage> _combat_stage_queue;
650};
652{
653public:
654 explicit Combat(std::shared_ptr<Unit> unit, std::shared_ptr<Unit> target);
655 ~Combat();
656
657 std::shared_ptr<Unit> unit() const { return _unit.lock(); }
658 std::shared_ptr<Unit> target() const { return _target.lock(); }
659
660
662 int64_t calculate_weapon_defense(int64_t damage);
663 int64_t calculate_magic_defense(int64_t damage);
667 int64_t deduce_weapon_element_attack(int64_t damage, element_type def_ele, item_equip_location_index loc);
668 int64_t deduce_damage_size_modifier(int64_t damage, item_equip_location_index loc);
669private:
670 time_t _start_time{0};
671 std::weak_ptr<Unit> _unit, _target;
672};
673}
674}
675
676#endif /* HORIZON_ZONE_GAME_ENTITIES_BATTLE_COMBAT_HPP */
zc_notify_act_3_action_types
0 = damage [ damage: total damage, div: amount of hits, damage2: assassin dual-wield damage ] 1 = pic...
Definition: ClientDefinitions.hpp:120
combat_damage_hit_type
Values used by (struct Damage).type, as well as clif->damage(type) and clif->skill_damage(type)
Definition: CombatDefinitions.hpp:83
@ CBT_DMG_HIT_NORMAL
Definition: CombatDefinitions.hpp:84
combat_damage_type_mask
Definition: CombatDefinitions.hpp:35
@ CBT_DMGMASK_NONE
Definition: CombatDefinitions.hpp:37
combat_retaliate_type
Definition: CombatDefinitions.hpp:51
item_equip_location_index
Definition: ItemDefinitions.hpp:204
element_type
Definition: UnitDefinitions.hpp:970
@ ELE_NEUTRAL
Definition: UnitDefinitions.hpp:971
AttributeOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, std::shared_ptr< Traits::Attribute > attribute)
Definition: Combat.hpp:353
std::shared_ptr< Traits::Attribute > _attribute
Definition: Combat.hpp:364
void operator=(const AttributeOperand &operand)
Definition: Combat.hpp:359
std::shared_ptr< Traits::Attribute > get_attribute()
Definition: Combat.hpp:357
~AttributeOperation()
Definition: Combat.hpp:369
attribute_operation_type
Definition: Combat.hpp:341
@ ATTRIBUTE_OPERATION_ADD_TO_BASE
Definition: Combat.hpp:342
@ ATTRIBUTE_OPERATION_SUBTRACT_FROM_BASE
Definition: Combat.hpp:343
@ ATTRIBUTE_OPERATION_ADD_TO_STATUS
Definition: Combat.hpp:346
@ ATTRIBUTE_OPERATION_SUBTRACT_FROM_EQUIP
Definition: Combat.hpp:345
@ ATTRIBUTE_OPERATION_ADD_TO_EQUIP
Definition: Combat.hpp:344
@ ATTRIBUTE_OPERATION_SUBTRACT_FROM_STATUS
Definition: Combat.hpp:347
void execute() const override
Definition: Combat.cpp:383
AttributeOperation(AttributeOperand *operand, attribute_operation_type operation_type, CombatValueInteger *value)
Definition: Combat.hpp:367
combat_operand_type
Definition: Combat.hpp:249
@ COMBAT_OPERAND_STATUS
Definition: Combat.hpp:252
@ COMBAT_OPERAND_ATTRIBUTE
Definition: Combat.hpp:250
@ COMBAT_OPERAND_MELEE_RESULT
Definition: Combat.hpp:256
@ COMBAT_OPERAND_APPEARANCE
Definition: Combat.hpp:251
@ COMBAT_OPERAND_MELEE_EXECUTION
Definition: Combat.hpp:254
@ COMBAT_OPERAND_SKILL_RESULT
Definition: Combat.hpp:255
@ COMBAT_OPERAND_SKILL_EXECUTION
Definition: Combat.hpp:253
combat_operand_type _type
Definition: Combat.hpp:280
CombatOperand(CombatOperand &&operand)=delete
void set_source(std::shared_ptr< Unit > source)
Definition: Combat.hpp:265
void set_target(std::shared_ptr< Unit > target)
Definition: Combat.hpp:266
virtual combat_operand_type get_type()
Definition: Combat.hpp:260
void operator=(const CombatOperand &operand)=delete
void operator=(CombatOperand &&operand)=delete
std::shared_ptr< Unit > get_target()
Definition: Combat.hpp:263
std::shared_ptr< Unit > _source
Definition: Combat.hpp:281
CombatOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, combat_operand_type type)
Definition: Combat.hpp:273
std::shared_ptr< Unit > _target
Definition: Combat.hpp:281
std::shared_ptr< Unit > get_source()
Definition: Combat.hpp:262
CombatOperand(CombatOperand &operand)=delete
combat_operation_value_type _type
Definition: Combat.hpp:198
CombatOperationValue(combat_operation_value_type type)
Definition: Combat.hpp:187
virtual combat_operation_value_type get_type()
Definition: Combat.hpp:191
void operator=(const CombatOperationValue &value)
Definition: Combat.hpp:193
int _operation_type
Definition: Combat.hpp:331
CombatOperand * _operand
Definition: Combat.hpp:330
virtual ~CombatOperation()
Definition: Combat.hpp:309
CombatOperationValue * _operation_value
Definition: Combat.hpp:333
int get_operation_sub_type() const
Definition: Combat.hpp:319
int _operation_sub_type
Definition: Combat.hpp:332
CombatOperation(CombatOperand *operand, int operation_type, int operation_sub_type, CombatOperationValue *value)
Definition: Combat.hpp:303
virtual CombatOperationValue * get_operation_value() const
Definition: Combat.hpp:320
combat_operation_type
Definition: Combat.hpp:288
@ COMBAT_OPERATION_MAX
Definition: Combat.hpp:296
@ COMBAT_OPERATION_MELEE_EXECUTION
Definition: Combat.hpp:293
@ COMBAT_OPERATION_APPEARANCE
Definition: Combat.hpp:290
@ COMBAT_OPERATION_SKILL_RESULT
Definition: Combat.hpp:294
@ COMBAT_OPERATION_ATTRIBUTE
Definition: Combat.hpp:289
@ COMBAT_OPERATION_MELEE_RESULT
Definition: Combat.hpp:295
@ COMBAT_OPERATION_STATUS
Definition: Combat.hpp:291
@ COMBAT_OPERATION_SKILL_EXECUTION
Definition: Combat.hpp:292
virtual CombatOperand * get_operand() const
Definition: Combat.hpp:317
void operator=(const CombatOperation &operation)=delete
CombatOperation(const CombatOperation &right)=delete
CombatOperation(CombatOperand *operand, int operation_type, int operation_sub_type)
Definition: Combat.hpp:306
void set_priority(int priority)
Definition: Combat.hpp:323
CombatOperation(CombatOperation &&right)=delete
int _priority
Definition: Combat.hpp:334
int get_operation_type() const
Definition: Combat.hpp:318
int get_priority()
Definition: Combat.hpp:322
MeleeResultOperation * push_melee_result_healing_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, combat_healing value_config)
Definition: Combat.cpp:374
StatusOperation * push_status_add_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::StatusOperation::StatusOperand::s_combat_status_operation_config config)
Definition: Combat.cpp:315
const CombatOperation * get_next_operation()
Definition: Combat.hpp:622
bool has_next_operation()
Definition: Combat.hpp:620
SkillResultOperation * push_skill_result_healing_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::SkillResultOperation::SkillResultOperand::s_skill_result_operation_config config, combat_healing value_config)
Definition: Combat.cpp:348
CombatStage(int priority)
Definition: Combat.hpp:601
void set_priority(int priority)
Definition: Combat.hpp:617
std::priority_queue< CombatOperation *, std::vector< CombatOperation * >, CompareCombatOperation > _operation_queue
Definition: Combat.hpp:626
SkillResultOperation * push_skill_result_damage_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::SkillResultOperation::SkillResultOperand::s_skill_result_operation_config config, combat_damage value_config)
Definition: Combat.cpp:339
int _priority
Definition: Combat.hpp:625
int get_priority()
Definition: Combat.hpp:616
~CombatStage()
Definition: Combat.hpp:602
bool has_operations()
Definition: Combat.hpp:619
MeleeResultOperation * push_melee_result_damage_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, combat_damage value_config)
Definition: Combat.cpp:365
void pop_queue()
Definition: Combat.hpp:623
void add_operation(CombatOperation *operation)
Definition: Combat.hpp:604
SkillExecutionOperation * push_skill_execution_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::SkillExecutionOperation::SkillExecutionOperand::s_skill_execution_operation_config config, CombatRegistry::SkillExecutionOperation::skill_execution_operation_type operation_type)
Definition: Combat.cpp:331
AttributeOperation * push_attribute_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, std::shared_ptr< Traits::Attribute > attribute, CombatRegistry::AttributeOperation::attribute_operation_type operation_type, int value)
Definition: Combat.cpp:306
MeleeExecutionOperation * push_melee_execution_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::MeleeExecutionOperation::MeleeExecutionOperand::s_melee_execution_operation_config config, CombatRegistry::MeleeExecutionOperation::melee_execution_operation_type operation_type)
Definition: Combat.cpp:357
StatusOperation * push_status_remove_operation(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, CombatRegistry::StatusOperation::StatusOperand::s_combat_status_operation_config config)
Definition: Combat.cpp:323
CombatValueDamage(combat_damage damage)
Definition: Combat.hpp:220
combat_damage _damage
Definition: Combat.hpp:227
combat_damage get_damage()
Definition: Combat.hpp:224
~CombatValueDamage()
Definition: Combat.hpp:222
combat_healing _healing
Definition: Combat.hpp:242
CombatValueHealing(combat_healing healing)
Definition: Combat.hpp:234
combat_healing get_healing()
Definition: Combat.hpp:239
~CombatValueHealing()
Definition: Combat.hpp:237
~CombatValueInteger()
Definition: Combat.hpp:209
CombatValueInteger(int value)
Definition: Combat.hpp:206
int get_value()
Definition: Combat.hpp:211
MeleeExecutionOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, s_melee_execution_operation_config config)
Definition: Combat.hpp:543
s_melee_execution_operation_config get_config()
Definition: Combat.hpp:547
s_melee_execution_operation_config _config
Definition: Combat.hpp:549
MeleeExecutionOperation(MeleeExecutionOperand *operand, melee_execution_operation_type type)
Definition: Combat.hpp:552
@ MELEE_EXECUTION_OPERATION_TARGET
Definition: Combat.hpp:532
void execute() const override
Definition: Combat.cpp:550
MeleeResultOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target)
Definition: Combat.hpp:573
@ MELEE_RESULT_OPERATION_HEALING
Definition: Combat.hpp:566
@ MELEE_RESULT_OPERATION_DAMAGE
Definition: Combat.hpp:565
MeleeResultOperation(MeleeResultOperand *operand, melee_result_operation_type type, CombatValueDamage *value)
Definition: Combat.hpp:580
MeleeResultOperation(MeleeResultOperand *operand, melee_result_operation_type type, CombatValueHealing *value)
Definition: Combat.hpp:583
void execute() const override
Definition: Combat.cpp:567
s_skill_execution_operation_config & get_config()
Definition: Combat.hpp:461
SkillExecutionOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, s_skill_execution_operation_config config)
Definition: Combat.hpp:457
void operator=(const SkillExecutionOperand &operand)
Definition: Combat.hpp:463
s_skill_execution_operation_config _config
Definition: Combat.hpp:468
SkillExecutionOperation(SkillExecutionOperand *operand, skill_execution_operation_type type)
Definition: Combat.hpp:471
@ SKILL_EXECUTION_OPERATION_TARGET
Definition: Combat.hpp:421
@ SKILL_EXECUTION_OPERATION_CAST
Definition: Combat.hpp:420
@ SKILL_EXECUTION_OPERATION_GROUND
Definition: Combat.hpp:422
void execute() const override
Definition: Combat.cpp:447
s_skill_result_operation_config get_config()
Definition: Combat.hpp:508
SkillResultOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, s_skill_result_operation_config config)
Definition: Combat.hpp:504
s_skill_result_operation_config _config
Definition: Combat.hpp:510
@ SKILL_RESULT_OPERATION_DAMAGE
Definition: Combat.hpp:485
@ SKILL_RESULT_OPERATION_HEALING
Definition: Combat.hpp:486
SkillResultOperation(SkillResultOperand *operand, skill_result_operation_type type, CombatValueHealing *value)
Definition: Combat.hpp:518
void execute() const override
Definition: Combat.cpp:501
SkillResultOperation(SkillResultOperand *operand, skill_result_operation_type type, CombatValueDamage *value)
Definition: Combat.hpp:514
s_combat_status_operation_config get_config()
Definition: Combat.hpp:395
s_combat_status_operation_config _config
Definition: Combat.hpp:402
StatusOperand(std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, s_combat_status_operation_config config)
Definition: Combat.hpp:391
void operator=(const StatusOperand &operand)
Definition: Combat.hpp:397
~StatusOperation()
Definition: Combat.hpp:410
void execute() const override
Definition: Combat.cpp:435
StatusOperation(StatusOperand *operand, status_operation_type operation_type)
Definition: Combat.hpp:407
status_operation_type
Definition: Combat.hpp:378
@ STATUS_OPERATION_REMOVE
Definition: Combat.hpp:380
@ STATUS_OPERATION_ADD
Definition: Combat.hpp:379
Definition: Combat.hpp:172
std::weak_ptr< Unit > _unit
Definition: Combat.hpp:648
CombatRegistry(std::shared_ptr< Unit > unit)
Definition: Combat.cpp:45
~CombatRegistry()
Definition: Combat.cpp:51
std::priority_queue< CombatStage *, std::vector< CombatStage * >, CompareCombatStage > _combat_stage_queue
Definition: Combat.hpp:649
combat_operation_value_type
Definition: Combat.hpp:175
@ COMBAT_OPERATION_VALUE_INTEGER
Definition: Combat.hpp:176
@ COMBAT_OPERATION_VALUE_DAMAGE
Definition: Combat.hpp:177
@ COMBAT_OPERATION_VALUE_HEALING
Definition: Combat.hpp:178
@ COMBAT_OPERATION_VALUE_STATUS
Definition: Combat.hpp:179
@ COMBAT_OPERATION_VALUE_NONE
Definition: Combat.hpp:180
void process_queue()
Definition: Combat.cpp:600
CombatStage * create_combat_stage(int priority)
Definition: Combat.hpp:641
void queue_combat_stage(CombatStage *stage)
Definition: Combat.hpp:643
std::shared_ptr< Unit > get_unit()
Definition: Combat.hpp:639
Definition: Combat.hpp:652
~Combat()
Definition: Combat.cpp:61
std::shared_ptr< Unit > target() const
Definition: Combat.hpp:658
std::shared_ptr< Unit > unit() const
Definition: Combat.hpp:657
time_t _start_time
Definition: Combat.hpp:670
int64_t calculate_magic_defense(int64_t damage)
Definition: Combat.cpp:220
combat_retaliate_type weapon_attack()
Definition: Combat.cpp:70
Combat(std::shared_ptr< Unit > unit, std::shared_ptr< Unit > target)
Definition: Combat.cpp:56
std::weak_ptr< Unit > _target
Definition: Combat.hpp:671
int64_t calculate_weapon_defense(int64_t damage)
Definition: Combat.cpp:65
int64_t deduce_weapon_element_attack(int64_t damage, element_type def_ele, item_equip_location_index loc)
Definition: Combat.cpp:248
int64_t deduce_damage_size_modifier(int64_t damage, item_equip_location_index loc)
Definition: Combat.cpp:277
combat_damage calculate_weapon_attack()
Definition: Combat.cpp:93
combat_damage calculate_magic_attack()
Definition: Combat.cpp:225
std::weak_ptr< Unit > _unit
Definition: Combat.hpp:671
combat_damage calculate_misc_attack()
Definition: Combat.cpp:242
Definition: Combat.hpp:92
bool _is_critical
Definition: Combat.hpp:101
void set_critical(bool is_critical)
Definition: Combat.hpp:97
DamageCritical(Damage *damage, bool is_critical)
Definition: Combat.hpp:94
Damage * _damage
Definition: Combat.hpp:100
bool is_critical()
Definition: Combat.hpp:98
Definition: Combat.hpp:52
void set_hit_type(combat_damage_hit_type hit_type)
Definition: Combat.hpp:57
combat_damage_hit_type _hit_type
Definition: Combat.hpp:62
DamageHitType(Damage *damage, combat_damage_hit_type hit_type)
Definition: Combat.hpp:54
combat_damage_hit_type get_hit_type()
Definition: Combat.hpp:58
Damage * _damage
Definition: Combat.hpp:61
Damage * _damage
Definition: Combat.hpp:87
int16_t get_knockback_cell_count()
Definition: Combat.hpp:85
DamageKnockBackCellCount(Damage *damage, int16_t knockback_cell_count)
Definition: Combat.hpp:81
void set_knockback_cell_count(int16_t knockback_cell_count)
Definition: Combat.hpp:84
int16_t _knockback_cell_count
Definition: Combat.hpp:88
Definition: Combat.hpp:66
int16_t _multi_attack_count
Definition: Combat.hpp:75
Damage * _damage
Definition: Combat.hpp:74
void set_multi_attack_count(int16_t multi_attack_count)
Definition: Combat.hpp:71
int16_t get_multi_attack_count()
Definition: Combat.hpp:72
DamageMultiAttackCount(Damage *damage, int16_t multi_attack_count)
Definition: Combat.hpp:68
Definition: Combat.hpp:45
Definition: Combat.hpp:104
combat_damage_type_mask _damage_type
Definition: Combat.hpp:160
int64_t _right_damage
Definition: Combat.hpp:166
int32_t _skill_id
Definition: Combat.hpp:164
bool operator>(TT right)
Definition: Combat.hpp:151
int64_t _left_damage
Definition: Combat.hpp:167
void set_hit_type(combat_damage_hit_type hit_type)
Definition: Combat.hpp:125
TT operator*(TT right)
Definition: Combat.hpp:137
combat_damage_hit_type _hit_type
Definition: Combat.hpp:161
TT operator/(TT right)
Definition: Combat.hpp:135
combat_damage_hit_type get_hit_type()
Definition: Combat.hpp:126
int32_t _skill_lv
Definition: Combat.hpp:165
int64_t _defense
Definition: Combat.hpp:168
Damage(combat_damage_type_mask damage_type, std::shared_ptr< Unit > source, std::shared_ptr< Unit > target, int32_t skill_id=0, int32_t skill_lv=0)
Definition: Combat.hpp:106
void set_right_damage(int64_t right_damage)
Definition: Combat.hpp:113
bool operator<(TT right)
Definition: Combat.hpp:155
void set_defense(int64_t defense)
Definition: Combat.hpp:123
int64_t calculate() const
Definition: Combat.hpp:130
void sub_right_damage(int64_t damage)
Definition: Combat.hpp:111
void add_left_damage(int64_t damage)
Definition: Combat.hpp:115
int64_t total() const
Definition: Combat.hpp:128
void sub_left_damage(int64_t damage)
Definition: Combat.hpp:116
bool operator!=(TT right)
Definition: Combat.hpp:149
int64_t get_left_damage()
Definition: Combat.hpp:117
int64_t get_right_damage()
Definition: Combat.hpp:112
TT operator-(TT right)
Definition: Combat.hpp:139
std::weak_ptr< Unit > _source
Definition: Combat.hpp:162
std::weak_ptr< Unit > _target
Definition: Combat.hpp:163
bool operator>=(TT right)
Definition: Combat.hpp:153
int64_t get_defense()
Definition: Combat.hpp:122
bool operator<=(TT right)
Definition: Combat.hpp:157
void add_defense(int64_t defense)
Definition: Combat.hpp:120
void set_left_damage(int64_t left_damage)
Definition: Combat.hpp:118
void add_right_damage(int64_t damage)
Definition: Combat.hpp:110
bool operator==(TT right)
Definition: Combat.hpp:147
TT operator+(TT right)
Definition: Combat.hpp:133
void sub_defense(int64_t defense)
Definition: Combat.hpp:121
Definition: Element.hpp:7
bool operator()(CombatOperation *op1, CombatOperation *op2)
Definition: Combat.hpp:593
bool operator()(CombatStage *op1, CombatStage *op2)
Definition: Combat.hpp:631
void operator=(const s_skill_execution_operation_config &config)
Definition: Combat.hpp:441
Definition: CombatDefinitions.hpp:106
Definition: CombatDefinitions.hpp:119