Commit Graph

301 Commits

Author SHA1 Message Date
Peter Keresztes Schmidt
365ae6ff25 Fix some compiler warnings reported by GCC (#25007)
* Core/AI: Remove unneeded null checks

GetMap() can never return NULL.

Fixes additionally -Wunused-variable warnings
reported by GCC.

* Core/GameObject: Fix a -Wunused-variable warning reported by GCC

* Core/Player: Fix a -Wunused-variable warning reported by GCC

* Scritps/CavernsOfTime: Fix -Wimplicit-fallthrough warnings reported by GCC

* Scritps/CavernsOfTime: Fix a -Wmaybe-uninitialized warning reported by GCC

Warning:

/home/peterke/DEV/TrinityCore/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp: In member function ‘virtual void npc_arthas_stratholme::npc_arthas_stratholmeAI::UpdateAI(uint32)’:
/home/peterke/DEV/TrinityCore/src/server/scripts/Kalimdor/CavernsOfTime/CullingOfStratholme/npc_arthas.cpp:1119:58: warning: ‘emote’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 1119 |                                 (*it)->HandleEmoteCommand(emote);
      |                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~

* Scritps/PitOfSaron: Fix -Wunused-variable warnings reported by GCC

* Scritps/EyeOfEternity: Fix a -Wclass-memaccess warning reported by GCC

Warning:

/home/peterke/DEV/TrinityCore/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp: In member function ‘virtual void boss_malygos::boss_malygosAI::UpdateAI(uint32)’:
/home/peterke/DEV/TrinityCore/src/server/scripts/Northrend/Nexus/EyeOfEternity/boss_malygos.cpp:950:81: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class ObjectGuid’; use assignment or value-initialization instead [-Wclass-memaccess]
  950 |                             memset(_surgeTargetGUID, 0, sizeof(_surgeTargetGUID));
      |

* Scritps/CoilfangReservoir: Fix a -Wclass-memaccess warning reported by GCC

Warning:

/home/peterke/DEV/TrinityCore/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp: In member function ‘void boss_leotheras_the_blind::boss_leotheras_the_blindAI::Initialize()’:
/home/peterke/DEV/TrinityCore/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_leotheras_the_blind.cpp:220:55: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘class ObjectGuid’; use assignment or value-initialization instead [-Wclass-memaccess]
  220 |             memset(InnderDemon, 0, sizeof(InnderDemon));
      |                                                       ^

* Scritps/Naxx: Fix a -Wimplicit-fallthrough warning reported by GCC

For discussion see https://github.com/TrinityCore/TrinityCore/pull/25007

(cherry picked from commit 10be49bdfe)
2022-01-23 00:16:31 +01:00
Rothend
962a2ac703 Core/EscortAI: set maximum distance allowed between player and escortee to default vision range. (#24865)
(cherry picked from commit 4caa218641)
2022-01-06 23:34:02 +01:00
Peter Keresztes Schmidt
c4098897a8 game/AI: Convert SelectAggroTarget to enum class (#24818)
* game/AI: Convert SelectAggroTarget to enum class

* game/AI: Rename SelectAggroTarget to SelectTargetMethod

(cherry picked from commit 418c3b1fd5)
2022-01-06 21:53:27 +01:00
jackpoz
ecdc387df2 Core/Misc: Remove whitespace at the end of lines
(cherry picked from commit caae3886d2)
2022-01-01 01:00:26 +01:00
Ujp8LfXBJ6wCPR
ee5384a15d Modernize codebase with Clang-Tidy range based loops (#24165)
Manual expansion of auto types into "typed types"

(cherry picked from commit a933ba6015)
2021-12-22 16:42:54 +01:00
Shauren
5d02739b98 Scripts: Fix rbac permission for skipping default boss sequencing check
(cherry picked from commit e660c8bc19)
2021-12-20 21:40:47 +01:00
Shauren
68a25f5e9b Core/Scripts: Add missing implementation for samePhase argument of ScriptedAI::ForceCombatStopForCreatureEntry 2021-12-19 18:12:12 +01:00
ccrs
d967d03151 Core/AI: add another helper for "ScriptedAI::ForceCombatStop"
(cherry picked from commit 3842ab2781)
2021-12-19 01:05:59 +01:00
ccrs
50c90728b2 Core/AI: 06443e3 followup
(cherry picked from commit bb9af06cd4)
2021-12-18 23:13:20 +01:00
ccrs
2f5d97b951 Core/AI: add missing public tag & correct alignment
(cherry picked from commit fe7c2c3772)
2021-12-18 23:10:45 +01:00
ccrs
d3ddb3726a Core/AI: 06443e3 followup
cause its not "that" horrible

(cherry picked from commit a71c5f4c7f)
2021-12-18 23:03:00 +01:00
jackpoz
7d78ddcbd5 Core/AI: Add new method to force creatures around to stop combat
(cherry picked from commit 06443e38e7)
2021-12-18 22:46:24 +01:00
Treeston
8c3eb07889 Scripts/FollowerAI: Some cleanup:
- FollowerAI properly resumes follow after evading.
- Removed duplicated getters from CreatureAI (IsEscorted vs IsEscortNPC), they were used to do the same thing
- FollowerAI properly assists in combat.
- FollowerAI properly despawns if quest is abandoned.
- FollowerAI now supports dynamic respawning for escort NPCs.

(cherry picked from commit 3d4bebd8d9)
2021-12-17 23:05:55 +01:00
Treeston
c13d83796f Core/AI: Finally move the "is creature engaged" flag to be a property of the creature AI, where it honestly always belonged. Fixes #17981 and #23602 for real this time.
(cherry picked from commit 0e7c66cb4c)
2021-12-17 00:23:33 +01:00
Treeston
eee950cdd7 Core/Misc: Various dynspawn cleanup and refactors split off from pooling rewrite:
- Map::RemoveRespawnTime(SpawnObjectType, LowType, doRespawn) split into Map::Respawn and Map::RemoveRespawnTime, without the extra boolean
- Map::RemoveRespawnTime(RespawnInfo*) merged into Map::DeleteRespawnInfo(RespawnInfo*) and is now private
- Map::DeleteRespawnInfo(void) renamed to Map::UnloadAllRespawnInfos to properly describe what it does
- Map::ProcessRespawns now actually saves the delayed respawn time to DB if the respawn was delayed
- Map::AddRespawnInfo now takes const reference, and returns success as a boolean
- Map::AddRespawnInfo no longer offers an unused "replace" parameter
- Map::DeleteRespawnInfo no longer offers a variety of unused private overloads
- Map::SaveRespawnTime no longer offers a tantalizing writeDB parameter. Parameter is now called "startup" to properly describe what it does.
- Map::SaveRespawnInfoDB now takes RespawnInfo reference instead of all the various fields. Still public because compatibility mode. QQ.
- Map::GetWorldObjectBySpawnId sanitized
- Map::GetXRespawnTime methods sanitized to all go through Map::GetRespawnTime

(cherry picked from commit d60082ae86)
2021-12-16 01:33:09 +01:00
Treeston
38d7c1530a Combat/Threat: Split ThreatManager::NotifyDisengaged off from ThreatManager::ClearAllThreat. NotifyDisengaged signifies intent to clear the engagement flag, and should only be called from AI. Fixes #23490.
(cherry picked from commit 1158f267df)
2021-12-12 02:09:15 +01:00
ccrs
c511fa2803 Core/Misc: remove incorrect ClearUnitState calls related to movement
these unit states should never be removed outside motionmaster's handlings

(cherry picked from commit 79b90f9d3a)
2021-12-05 18:37:12 +01:00
ccrs
bda32dfbd1 Core/AI: couple movement related corrections in FollowerAI
plus EnterEvadeMode streamline

(cherry picked from commit f309b49eb1)
2021-12-05 16:51:19 +01:00
ccrs
88f5536c43 Core/AI: streamline FollowerAI::MoveInLineOfSight with SmartAI and EscortAI
plus another method reorganization

(cherry picked from commit d3b8d69e38)
2021-12-05 16:50:53 +01:00
ccrs
edbf45404b Core/AI: streamline FollowerAI::AssistPlayerInCombatAgainst with SmartAI and EscortAI
plus couple method reorganizations

(cherry picked from commit 0e22d61d4a)
2021-12-05 16:50:15 +01:00
ccrs
844f969ed7 Core/AI: logs, codestyle & cosmetics standarization
(cherry picked from commit fdb71ce19e)
2021-12-05 16:48:58 +01:00
ccrs
dd11603150 Core/AI: variable naming standarization
plus minimum codestyle changes

(cherry picked from commit 179c7da1fc)
2021-12-05 16:17:02 +01:00
Killyana
36e009baf2 Core: Restore reset in EscortAI::InitializeAI (#23197)
Closes  #23008

(cherry picked from commit 56b65329e5)
2021-12-02 00:39:20 +01:00
Ovah
b606c22dfd Core/EscortAI: initialize run state before filling waypoints (PR #22416)
(cherry picked from commit 993c392cd7)
2021-10-26 23:58:36 +02:00
Treeston
e4e8c1c59c Core/AI: Clean up charm AI handling, we now have two unique_ptr instead of a crapton of booleans
(cherry picked from commit 042f5515e4)
2021-10-22 23:47:51 +02:00
Treeston
5d48e8db7d Core/AI: Remove unnecessary parameter from DoZoneInCombat after eb1972f
(cherry picked from commit c00a2efb21)
2021-10-22 13:29:34 +02:00
Seyden
8f097e4425 Core/Scripts: Implement script name reloading
* Authored by Seyden
* Co-authored by Naios
* We thank Shauren for your helpful feedback
2021-10-22 12:52:37 +02:00
Treeston
58000148d3 Core/AI: EscortAI::SetRun now also adjusts already-in-progress waypoint paths, as opposed to only affecting future path loading. Closes #21290.
(cherry picked from commit 121346f1f9)
2021-10-22 00:40:20 +02:00
Meji
5c287929b2 Core/Gossip: Update GossipOptionIcon enum (#26906) 2021-10-03 16:24:07 +02:00
ccrs
426f9f2f92 Core/Movement: MotionMaster reimplementation (#21888)
Internal structure and handling changes, nothing behavioural (or thats the intention at least).

(cherry picked from commit 982643cd96)
2021-09-28 00:15:13 +02:00
ariel-
962f6d7988 Core/Spells: rework part 5: GameObject casting
Closes #21330
Closes #18885
Ref #18752

(cherry picked from commit 45c5e1b9d6)
2021-08-28 15:59:11 +02:00
Treeston
994121e671 Core/CreatureAI: CheckBoundary -> IsInBoundary, better reflects what it does. Also moved to public so spellscript can use it.
(cherry picked from commit df639d85e4)
2021-08-23 23:28:48 +02:00
Treeston
f4cc76063f Core/AI: EscortAI init logic moved from JustAppeared to InitializeAI. There are no escort NPCs using compatibility mode anymore, so this is equivalent.
As a result, inheriting scripts calling Start in on-create hooks (like JustSummoned) will now work properly again.

Tagging #20310.

(cherry picked from commit e4e6e2209c)
2021-06-19 23:33:38 +02:00
Treeston
8b7728f82e Core/Map: New Map::ForceRespawn to override objections and force a respawn (equivalent to force = true). Use this to fix various GM commands.
Scripts/Valithria: Fix an issue that could get the encounter stuck in an unloaded state.

(cherry picked from commit 3bb33e3108)
2021-05-16 21:56:06 +02:00
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
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
Treeston
9b141207d1 [3.3.5] CastSpell unclusterfucking (that's a word now) (#21123)
Core/Spell: The giant CastSpell unclusterfucking (that's a word now) of this generation.

- CastSpell now always takes three arguments - target, spellId, and a struct containing extra arguments
- This struct (CastSpellExtraArgs, see SpellDefines.h) serves as a conglomerate of every previous combination of the 20 billion different CastSpell overloads, all merged into one
  - It has some great utility constructors - check them out! All of these can be used to implicitly construct the ExtraArgs object.
- A gajillion refactors to make everything behave the way it always has

(cherry picked from commit d507a7e338)
2021-04-16 15:22:42 +02:00
ccrs
82b7f47d53 Core/AI: reorder methods in ScriptedEscortAI
plus ninja rename

(cherry picked from commit 0db5516a1a)
2021-02-25 18:50:55 +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
ccrs
138edeb34e Core/AI: add missing checks on AssistPlayerInCombatAgainst
(cherry picked from commit ee5cbf28bc)
2020-08-23 00:49:53 +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
treeston
2dfafa69eb Hi, I'm Treeston, and welcome to Combat PR Prep Refactors.
Today, we're moving UNIT_FLAG_IMMUNE_TO_PC and UNIT_FLAG_IMMUNE_TO_NPC to higher-level abstraction so combat manager can react to it.
New methods on Unit:
- void SetImmuneTo<All/PC/NPC>(apply, keepCombat = false);
- bool IsImmuneTo<All/PC/NPC>() const;

(cherry picked from commit 74af880217)
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
treeston
803012cc40 Add another helper to ScriptedGossip.h for resolving listId -> action.
(cherry picked from commit 302a039b7c)
2020-06-14 23:49:04 +02:00
ariel-
6fa8b8e1d5 Core/Creature: fix _DespawnAtEvade saving wrong respawn time
Closes #19557

(cherry picked from commit 47d387d6b0)
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
ariel-
93c19c4194 Core/Misc: camelize GetFaction/SetFaction properly
(cherry picked from commit 4c4dca6d69)
2020-04-29 01:36:41 +02:00