Commit Graph

776 Commits

Author SHA1 Message Date
Treeston
34c7810fe5 Core: Combat/threat system rewrite (PR #19930)
- PvE combat is now always mutual. UNIT_FLAG_IN_COMBAT is backed by actual references to the units we're in combat with.
- PvP combat is now also tracked, and almost always mutual; spells like Vanish and Feign Death can break this rule. That means we can easily determine a list of players we're fighting.
- By extension, IsInCombatWith now has sensible behavior when invoked on nonplayers.
- Threat and combat systems are no longer the same.
  - They still have an enforced relationship (threat implies combat - clearing combat clears threat)...
  - ...but we can have combat without threat. A creature (with threat list) isn't considered to be engaged until it has an entry on its threat list...
  - ...which means we can now faithfully replicate retail engage behavior. Combat on projectile launch - engagement start on projectile impact. Yay for progress!
- AI method refactor, as already ported in 6113b9d - `JustEngagedWith`, `JustEnteredCombat` and `JustExitedCombat`.
- Vehicle threat is now properly pooled on the main vehicle body (fixes #16542).
- Various edge case bug fixes for threat redirects (Misdirection "cancelling" Vigilance and similar).
- Target re-selection is now significantly faster.
- Fixed a ton of other smaller edge case bugs, probably.

Closes #7951 and #19998.

(cherry picked from commit 532ab1c7f8)
2021-05-16 21:56:01 +02:00
Shauren
91b91b502f Core/Quests: Quest improvements
* Add quest log slot argument to functions dealing with objective progress
* Implemented QUEST_OBJECTIVE_FLAG_SEQUENCED (prevent progressing hidden objectives)
2021-05-09 20:21:32 +02:00
Shauren
dd8aed421a Core/Quests: Drop unneeded QuestSpecialFlags 2021-05-09 16:01:34 +02:00
Treeston
e0afca513a Core/AI: UnitAI.h trimming part two. WaypointX methods kicked upstairs to CreatureAI.h.
(cherry picked from commit 9c1e675590)
2021-04-27 23:51:40 +02:00
Matan Shukry
8b0de23d0e Core/SAI: Don't clear stored pathid if it changed after processing waypoint events (#26334) 2021-04-26 21:39:22 +02:00
Treeston
bce43de7f3 Core/AI: Some more refactoring prep for #19930. CreatureAI::EnterCombat is now called CreatureAI::JustEngagedWith. There's also two new methods on UnitAI, though they're never invoked right now.
(cherry picked from commit 6113b9dec2)
2021-04-16 20:22:13 +02:00
Keader
a7883380ce Core/AI: Making guid const& in SetGUID method (#21128)
(cherry picked from commit 465b43fabe)
2021-04-15 05:53:27 +02:00
Shauren
33b3ebcae6 Core/Objects: Pass privateObjectOwner guid directly to SummonCreature functions 2021-03-28 20:22:05 +02:00
Matan Shukry
c019d4f10c Core/SAI: Don't require BaseObject when creating conversation from smart scripts (#26209) 2021-03-07 11:17:04 +01:00
Matan Shukry
1b4c4d2164 Core/SAI: Implement quest source for SAI (#26170) 2021-03-06 14:20:39 +01:00
jackpoz
55931b0d92 Core/SmartScripts: Code cleanup
(cherry picked from commit f555a67bf8)
2021-03-04 18:17:08 +01:00
Killyana
77ee6dca45 Core/SAI: Add event_parm5 "player only" for EVENT_OOC_LOS and EVENT_IC_LOS
Closes #21497

(cherry picked from commit 5ad38c31b0)
2021-03-04 18:15:55 +01:00
Shauren
afae75841b Core/SAI: Rename SMART_ACTION_TALK_CONVERSATION to SMART_ACTION_CREATE_CONVERSATION 2021-02-27 11:42:44 +01:00
Matan Shukry
0996d60944 Core/SAI: Add SAI action to create a conversation (#26169) 2021-02-27 11:22:55 +01:00
Matan Shukry
e0278f0537 Core/SAI: Added new Flags argument for SMART_ACTION_SUMMON_CREATURE (#26055)
* Added personalSpawn for SMART_ACTION_SUMMON_CREATURE
* Added flags for smart action summon creature, including prefer unit and personal spawn. When preferUnit flag is chosen only the unit will be chosen, even if nullptr
2021-02-10 21:18:01 +01:00
jackpoz
852c9e9108 Core/Misc: Fix static analysis issues
(cherry picked from commit a80c95a1c7)
2021-02-06 21:41:51 +01:00
BAndysc
17676d4d41 Core/SAI: Add missing AreaTrigger to SmartScript::GetBaseObject 2021-02-06 19:20:07 +01:00
Shauren
875fd4107f Core/SAI: Added SAI support for new areatriggers 2021-02-05 18:12:55 +01:00
ccrs
3e5a955fc8 Core/AI: rearrange SAI private methods
(cherry picked from commit 60a5535f64)
2021-01-29 19:23:53 +01:00
ccrs
bf12bae467 Core/Misc: waypoint movement
- Creature: update current waypoint to store nodeId and pathId
- MotionMaster: change variable type on GetMotionSlotType and GetMotionSlot to keep consistency and prevent errors (ASSERT is now no longer needed)
- UnitAI: add new waypoint hooks WaypointPathStarted and WaypointPathEnded
- SAI: handle WAYPOINT related events if creature is no escorting
* SMART_EVENT_WAYPOINT_RESUMED still not implemented for no escorting

TODO: the new hooks can save, now duplicated, logic on EscortAI and SAI

closes #20777
updates #20310
updates 21bd52cb99

(cherry picked from commit e10d7dd45c)
2021-01-29 19:23:53 +01:00
Kittnz
097335f2c4 Core/SAI: Add distance option for SMART_ACTION_SOUND & SMART_ACTION_RANDOM_SOUND (#20717)
(cherry picked from commit 37995ade29)
2021-01-13 22:04:52 +01:00
Wyreth
b902e739d4 Core/SAI: remove double calls to SMART_EVENT_RESPAWN for creatures and gameobjects (#20420)
(cherry picked from commit 637b5f922d)
2021-01-13 22:04:52 +01:00
Wyreth
56dca10f1b Core/SAI: allow to pause/resume waypoint for non-escorting NPCs (#20684)
(cherry picked from commit 21bd52cb99)
2021-01-13 22:04:52 +01:00
jackpoz
d8804418ce Core/SAI: Fix static analysis issue
Initialize uninitialized value, move class field from public to private.

(cherry picked from commit 7dc97c0353)
2021-01-13 22:04:52 +01:00
Shauren
2e4609f6e1 Core/Chat: Send broadcast text id in sound packets to allow playing encrypted sound files 2020-12-27 22:43:36 +01:00
Shauren
b231903932 Core/Misc: Port all the refactors sneaked in master to 3.3.5 include cleanup port 2020-09-04 13:38:24 +02:00
Treeston
06a1271a50 Core/Misc: random refactors
(cherry picked from commit 37dff2b7a1)
2020-08-23 17:47:41 +02:00
Treeston
27806eeac9 Core/Spawn: Move spawn group state management from sObjectMgr to the Map object, which makes it actually function as intended with instances. Woops.
(cherry picked from commit f279207d48)
2020-08-23 17:00:59 +02:00
ccrs
9a5e2b80b3 Core/Creature: regenerate health
There are three possible scenarios regarding regenerating health
- db lock and curhealth set to > 0
- db lock and curhealth set to 0
- dynamic lock (set in scripts and such) overriding db lock

(cherry picked from commit 91c0d49c18)
2020-08-23 15:56:21 +02:00
ccrs
138edeb34e Core/AI: add missing checks on AssistPlayerInCombatAgainst
(cherry picked from commit ee5cbf28bc)
2020-08-23 00:49:53 +02:00
ccrs
e10018029d Core/SmatAI: correct MoveInLineOfSight
mistake introduced in 15f2706aca that was masqueraded by other checks in combat start, till recent related commits

(cherry picked from commit d117a0e4d4)
2020-08-23 00:49:36 +02:00
ccrs
0a133e77d6 Core/Movement: 7fff83d675 followup
remove home position set from creature PauseMovement, and use it when necessary
change log level on DelayedDelete

(cherry picked from commit cd4775420a)
2020-08-23 00:48:46 +02:00
ccrs
97585597f0 Core/Movement: waypoint movement (#20121)
Following the work done in #19361 this is the cleanup and improvement of the related logic of waypoint management.

Ref 28050f3 #18020
(taking the good parts and ignoring the incomplete work)

(cherry picked from commit 7fff83d675)
2020-08-23 00:45:46 +02:00
Treeston
129dd7c909 Core/Scripts: dynamic_spawning follow-up, I had forgotten JustRespawned existed.
- Rename JustRespawned to JustAppeared, which better matches its behavior anyway.
- Properly invoke JustAppeared for new (re-)spawns - fixes #20111.
- Fix Thaddius script to work with dynamic_spawning (mostly unrelated to the above) - Feugen/Stalagg should really be a summon group, but I don't have time to fix that right now.
- Fix default value for DynamicEscortNPC to match worldserver.conf.dist.

(cherry picked from commit 184c45cfe0)
2020-08-22 20:10:42 +02:00
r00ty-tc
03b125e6d1 Dynamic Creature/Go spawning:
- True blizzlike creature spawn/respawn behavior - new creature = new object
 - Toggleable spawn groups (with C++/SAI/command options to use them)
 - Custom feature: dynamic spawn rate scaling. Accelerates respawn rate based on players in the zone.
 - Backward compatibility mode (set via group and for summons)
   to support creatures/gos that currently don't work well with this
   (this should be removed once the exceptions are fixed)

Fixes and closes #2858
Tags #8661 as fixable.
Fixes and closes #13787
Fixes #15222.

(cherry picked from commit 59db2eeea0)
2020-08-22 12:59:57 +02:00
jackpoz
77e6355fba Core/Misc: Fix static analysis issues
(cherry picked from commit 9cf4dd7345)
2020-08-19 00:14:06 +02:00
treeston
daf9c703c4 Two more refactors I missed for #19930. Last ones for now, I promise.
(cherry picked from commit 62d5113252)
2020-08-18 18:53:13 +02:00
Shauren
1c52d5fff7 Core/Misc: Replace NULL with nullptr 2020-08-14 17:06:03 +02:00
Treeston
8be23fcbbd [3.3.5] Combat/Threat rewrite - prep & refactor (#19966)
* Combat/Threat rewrite (PR #19930) prep work. Mostly refactors, and a compatibility layer on ThreatManager/HostileReference that allows scripts to be changed already.

(cherry picked from commit e2a1ccd118)
2020-08-13 22:46:44 +02:00
ariel-
593d3243d4 Core/SmartAI: implemented SMART_EVENT_EVENT_PHASE_CHANGE
- Use instead of Update + event_phase_mask when action needs to be synchronized

(cherry picked from commit 619a5534c5)
2020-07-17 18:38:25 +02:00
Carbenium
692ec8e7c1 Core/SAI: Apply include cleanups to cherry-picked changes 2020-07-16 22:00:30 +02:00
ariel-
5903a10a83 Core/AI: segregate GameObject ReportUse from normal Use (lock open/normal click)
Closes #19819

(cherry picked from commit 2335b9de1a)
2020-07-16 21:47:28 +02:00
treeston
bb7061407f SAI fixes follow-up: I missed one.
(cherry picked from commit cb265e02aa)
2020-07-16 21:47:27 +02:00
treeston
e6145a8ec4 Fix a whole set of possible infinite loop crashes in SAI (events triggering themselves even with cooldown set).
(cherry picked from commit 823007934a)
2020-07-16 21:47:27 +02:00
ariel-
960bfcabc3 Core/SAI: properly validate stored targets when using SmartTrigger and fix a related crash
(cherry picked from commit 866074b689)
2020-07-16 21:47:27 +02:00
ariel-
259bde5914 Core/SAI: Change SmartScript::GetTargets to return an ObjectList instead of a ObjectList*
Applied the same treatment to GetWorldObjectsInDist

Honestly no idea why the original idea insisted so much
on using pointers. No more missing null checks or deletes.

SmartAI's "ObjectList" is now a std::vector instead of a std::list
because no where it was being used as an actual list.

Original idea by DDuarte :P

(cherry picked from commit a97439e8d6)
2020-07-16 20:59:25 +02:00
ariel-
1881088744 Core/AI: Factory functions cleanup
- Get rid of fugly void pointers
- Streamlined AI selection code, using Permissible as it should've been instead of harcoded checks on the selector code
- Moved IdleMovementGenerator singleton to factory code

(cherry picked from commit ce3787f190)
2020-06-14 23:49:05 +02:00
ariel-
444754e65a Core/SmartAI: allow SMART_ACTION_SEND_GOSSIP_MENU to override default gossip
Closes #19769

(cherry picked from commit f2b0819e53)
2020-06-14 23:49:04 +02:00
Shauren
c7306439e7 Core/Spells: Implement using different difficulty data from all spell related db2s, not just SpellEffect and SpellPower 2020-06-12 01:29:18 +02:00
Shauren
4d69cc1c56 Core/Misc: GCC build and warning fixes 2020-05-21 22:15:58 +02:00