Fix combat movement (#18026)

* Improve combat movement

 - Removed a bunch of logic related to another attempt at fixing combat movement.
- Removed SMART_ACTION_SET_CASTER_COMBAT_DIST and updated smarts scripts accordingly.
- Cherry-picked 7fb7432620
- Cherry-picked 63a6e1e048

Co-Authored-By: Ludovic Barbier <ludovic.barbier03@gmail.com>
Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>

* Some more cleanup + fix sql

* More fixes to caster chase/combat movement + some cherry picks because why not

- Fix casters always trying to chase to melee range
- Fix casters another case of casters sometimes walking back instead of stopping
- Cleaned up some code
- Cherry picked ca25e8d019
- Cherry picked 96b289cadb

Co-Authored-By: Giacomo Pozzoni <giacomopoz@gmail.com>

* Added parentheses

* Fixed caster combat movement when target is rooted

- Made a few adjustments to chase range and stuff, but nothing set in stone.

* convert uint to int

---------

Co-authored-by: Ludovic Barbier <ludovic.barbier03@gmail.com>
Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
This commit is contained in:
AG
2024-01-03 09:56:24 +01:00
committed by GitHub
parent 623ee56509
commit 8f127f9e21
8 changed files with 224 additions and 142 deletions

View File

@@ -26,6 +26,7 @@
#include "Spell.h"
#include "SpellMgr.h"
#include "Unit.h"
#include <limits>
typedef uint32 SAIBool;
@@ -686,7 +687,7 @@ enum SMART_ACTION
SMART_ACTION_EXIT_VEHICLE = 203, // none
SMART_ACTION_SET_UNIT_MOVEMENT_FLAGS = 204, // flags
SMART_ACTION_SET_COMBAT_DISTANCE = 205, // combatDistance
SMART_ACTION_SET_CASTER_COMBAT_DIST = 206, // followDistance, resetToMax
// UNUSED = 206,
SMART_ACTION_SET_HOVER = 207, // 0/1
SMART_ACTION_ADD_IMMUNITY = 208, // type, id, value
SMART_ACTION_REMOVE_IMMUNITY = 209, // type, id, value
@@ -1859,7 +1860,10 @@ enum SmartEventFlags
SMART_EVENT_FLAG_WHILE_CHARMED = 0x200, // Event occurs even if AI owner is charmed
SMART_EVENT_FLAG_DIFFICULTY_ALL = (SMART_EVENT_FLAG_DIFFICULTY_0 | SMART_EVENT_FLAG_DIFFICULTY_1 | SMART_EVENT_FLAG_DIFFICULTY_2 | SMART_EVENT_FLAG_DIFFICULTY_3),
SMART_EVENT_FLAGS_ALL = (SMART_EVENT_FLAG_NOT_REPEATABLE | SMART_EVENT_FLAG_DIFFICULTY_ALL | SMART_EVENT_FLAG_RESERVED_5 | SMART_EVENT_FLAG_RESERVED_6 | SMART_EVENT_FLAG_DEBUG_ONLY | SMART_EVENT_FLAG_DONT_RESET | SMART_EVENT_FLAG_WHILE_CHARMED)
SMART_EVENT_FLAGS_ALL = (SMART_EVENT_FLAG_NOT_REPEATABLE | SMART_EVENT_FLAG_DIFFICULTY_ALL | SMART_EVENT_FLAG_RESERVED_5 | SMART_EVENT_FLAG_RESERVED_6 | SMART_EVENT_FLAG_DEBUG_ONLY | SMART_EVENT_FLAG_DONT_RESET | SMART_EVENT_FLAG_WHILE_CHARMED),
// Temp flags, used only at runtime, never stored in DB
SMART_EVENT_FLAG_TEMP_IGNORE_CHANCE_ROLL = 0x40000000, //Event occurs no matter what roll_chance_i(e.event.event_chance) returns.
};
enum SmartCastFlags
@@ -1889,7 +1893,7 @@ enum SmartFollowType
struct SmartScriptHolder
{
SmartScriptHolder() : entryOrGuid(0), source_type(SMART_SCRIPT_TYPE_CREATURE)
, event_id(0), link(0), event(), action(), target(), timer(0), active(false), runOnce(false)
, event_id(0), link(0), event(), action(), target(), timer(0), priority(DEFAULT_PRIORITY), active(false), runOnce(false)
, enableTimed(false) {}
int32 entryOrGuid;
@@ -1908,9 +1912,18 @@ public:
uint32 GetTargetType() const { return (uint32)target.type; }
uint32 timer;
uint32 priority;
bool active;
bool runOnce;
bool enableTimed;
// Default comparision operator using priority field as first ordering field
bool operator<(SmartScriptHolder const& other) const
{
return std::tie(priority, entryOrGuid, source_type, event_id, link) < std::tie(other.priority, other.entryOrGuid, other.source_type, other.event_id, other.link);
}
static constexpr uint32 DEFAULT_PRIORITY = std::numeric_limits<uint32>::max();
};
typedef std::unordered_map<uint32, WayPoint*> WPPath;