Commit Graph

872 Commits

Author SHA1 Message Date
Seyden
f383c0ea21 Core/SAI: Add SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER (#27581) 2022-01-18 20:51:23 +01:00
Rothend
381333690b Core/SAI: do not allow the waypoint pause timer to update while in combat. (#24877)
(cherry picked from commit 37cb391796)
2022-01-18 00:17:44 +01:00
Rothend
d4a1a7a040 Core/SAI: implement SMART_EVENT_SUMMONED_UNIT_DIES (82), useable by creatures and gameobjects (#24874)
* Core/SAI: implement SMART_EVENT_SUMMONED_UNIT_DIES (82), useable by creatures and gameobjects.

Closes #24831

* Update SmartScriptMgr.h

(cherry picked from commit 5339d1d3b8)
2022-01-18 00:17:28 +01:00
Rothend
1ddde5ca3c Core/SmartAI: allow AreaTrigger SAI scripts to use the player triggering it as base object for actions and targeting (#24817)
* Core/SmartAI: allow AreaTrigger SAI scripts to use the player triggering it as base object for actions and targeting.

Closes #23669
Closes #24791
Closes #24792
Closes #24793

* Apply suggested changes.

* Initialize atPlayer in the constructor

Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
(cherry picked from commit e7a714f66c)
2022-01-06 22:05:03 +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
Ovahlord
38be5e361e Core/SAI: implement SMART_ACTION_ATTACK_STOP
Unlike SMART_ACTION_AUTO_ATTACK, this action is actually stopping the entire attack procedure, rather than just hack-disabling auto-attacks. Keep in mind that this action requires a passive react state to prevent a immediate AttackStart ai reaction

(cherry picked from commit 152ea60116)
2022-01-06 21:39:37 +01:00
ForesterDev
3171cd3fa9 Core/AI: refactor SpellHit and SpellHitTarget. (#24691)
* Core/AI: refactor SpellHit and SpellHitTarget.

- now caster/target is WorldObject instead of Unit
- remove SpellHitByGameObject / SpellHitTargetGameObject (handled by SpellHit / SpellHitTarget)
- rename parameters in scripts according parent methods

* Restore logic in Algalon script

* Changed check for REMORSELESS_WINTER hit to avoid dublicate call, because it has TARGET_UNIT_CASTER for effects 0/1 and TARGET_GAMEOBJECT_SRC_AREA for effect 2

* Fix build after merge

(cherry picked from commit e3b232fe0e)
2022-01-06 20:46:25 +01:00
Rushor
db825c3221 Game/AI: Implement new targettype SMART_TARGET_CLOSEST_UNSPAWNED_GAMEOBJECT (#24494)
* Game/AI: Implement new targettype SMART_TARGET_CLOSEST_UNSPAWNED_GAMEOBJECT which allows to search for closest unspawned gameobjects

* updates: https://github.com/TrinityCore/TrinityCore/issues/24067

* Game/AI: Implement new targettype SMART_TARGET_CLOSEST_UNSPAWNED_GAMEOBJECT which allows to search for closest unspawned gameobjects

(cherry picked from commit 2d948d3366)
2022-01-01 21:33:34 +01:00
Rushor
ecd6bce5d2 Game/AI: Enable check for SMART_TARGET_GAMEOBJECT_RANGE (#24493)
* Thanks to joshwhedon
* Updates: https://github.com/TrinityCore/TrinityCore/issues/24439

(cherry picked from commit a41bb4f77b)
2022-01-01 21:33:27 +01:00
Rushor
864ce5a11c Game/SmartScripts: Reset counter in SAI only on Initialize. (#24489)
* Game/SmartScripts: Reset counter in SAI only on Initialize.

* Game/SmartScripts: Reset counter in SAI only on Initialize.

(cherry picked from commit 4f52f7d7c9)
2022-01-01 20:12:55 +01:00
Giacomo Pozzoni
a947ee1912 Core/SAI: Allow SMART_TARGET_ACTION_INVOKER to target GameObjects (#24416)
* Core/SAI: Allow SMART_TARGET_ACTION_INVOKER to target GameObjects

* Include new Coalesce(..) template by @Shauren

(cherry picked from commit 90b00288c2)
2022-01-01 13:06:27 +01:00
Giacomo Pozzoni
a9e325f6b7 Core/Logs: Log full guid instead of just low guid, part 2
(cherry picked from commit 3def52c1c4)
2022-01-01 00:51:54 +01:00
Giacomo Pozzoni
6ec933f281 Core/Logs: Log full guid instead of just low guid
(cherry picked from commit 468ecb7252)
2021-12-31 21:56:40 +01:00
Shauren
34ae77ca86 Core/SAI: Reserve action ids 2021-12-25 16:01:56 +01:00
ModoX
bc4e285c21 Core/SAI: added new action type SMART_ACTION_ADD_TO_STORED_TARGET_LIST (#27029) 2021-12-25 16:00:34 +01:00
jackpoz
c75d75b9fa Core/AI: Fix charmed Creatures with SAI scripts not starting waypoint paths
(cherry picked from commit 49e77d7c9e)
2021-12-22 22:36:39 +01:00
Shauren
e8d1f37ee0 Core/Maps: Citizens of Dalaran! Raise your eyes to the skies and observe! Any non-map-default light can now be overriden!
Closes #24250

(cherry picked from commit e10313b380)
2021-12-22 21:51:33 +01:00
Shauren
29aef603ef Core/SAI: Allow resetting light overrides with SMART_ACTION_OVERRIDE_LIGHT
(cherry picked from commit c5226aec41)
2021-12-22 21:46:04 +01:00
jackpoz
dab7e5688c Core/AI: Fix remaining charming issue
Make creatures evade when a charming expires and they cannot attack the charmer (i.e. charmer with .gm on)

(cherry picked from commit 69809d1203)
2021-12-22 21:00:14 +01:00
Giacomo Pozzoni
144cfc2bce Core/AI: Make charmed creatures follow their owner (#24195)
* Core/AI: Make charmed creatures follow their owner

* Follow the charmer only when applying the charm

* Make SmartAI follow the charmer

(cherry picked from commit ddf2f60c13)
2021-12-22 20:46:17 +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
ForesterDev
5e178b30fa Core/DynamicInfo: rename some parameters according packet definitions (#24192)
(cherry picked from commit 5cfce94619)
2021-12-22 14:54:59 +01:00
ForesterDev
1d08423725 Core/SmartAI: implement SMART_ACTION_OVERRIDE_LIGHT and SMART_ACTION_OVERRIDE_WEATHER (#24146)
* Core\SmartAI: implement SMART_ACTION_OVERRIDE_LIGHT and SMART_ACTION_OVERRIDE_WEATHER

* Change the invoker of action to any worldobject

* Revert "Change the invoker of action to any worldobject"

This reverts commit 2e15f72585.

* Add dbc-validations for new actions

* Use GetBaseObject() instead of Creature* for new actions. Add debug-logging

(cherry picked from commit c65ba35269)
2021-12-22 01:15:52 +01:00
Ovahlord
a90b9abbf0 Core/SAI: SMART_ACTION_PAUSE_MOVEMENT
Closes #22346

(cherry picked from commit 6f31784979)
2021-12-21 23:55:34 +01:00
Regigicas
aa81d8979f Core/SAI: Fix SMART_ACTION_SET_MOVEMENT_SPEED behavior (#24059)
(cherry picked from commit 1369620436)
2021-12-20 21:25:33 +01:00
Killyana
d946d74ff9 Core/AI: Fix creatures not updating their target properly once engaged
Closes  #21562

(cherry picked from commit 7fb7432620)
2021-12-19 15:54:20 +01:00
Treeston
3db58c4d96 Core/SmartAI: SmartAI creatures no longer process health-based hooks after death.
(cherry picked from commit 1faa54fe8b)
2021-12-18 00:03:55 +01:00
ccrs
e94dca132b Core/SmartAI: add missing movement generator type check on SmartAI::SetCombatMove
ref #21562

(cherry picked from commit 0e3e4353a1)
2021-12-16 22:10:54 +01:00
ccrs
f1ef2f73a4 Core/SmartAI: allow more Unit::ResumeMovement calls on JustReachedHome()
Since ResumeMovement also works on other MOTION_SLOT_DEFAULT generators (like RandomMG)

(cherry picked from commit c8cb866db0)
2021-12-16 22:08:01 +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
ccrs
4e6c59dca7 Core/Unit: rename several getters to follow codestyle
uint8 GetLevel()
        uint8 GetLevelForTarget(WorldObject const* /*target*/)
        void SetLevel(uint8 lvl)
        uint8 GetRace()
        uint32 GetRaceMask()
        uint8 GetClass()
        uint32 GetClassMask()
        uint8 GetGender()

(cherry picked from commit 5c09ff51f7)
2021-12-13 00:42:20 +01:00
Wyrserth
d197a7ce9b Core/SAI: add param3 to SMART_ACTION_CALL_TIMED_ACTIONLIST to allow it to override a currently running actionlist.
(cherry picked from commit eeba12778b)
2021-12-13 00:42:17 +01:00
Wyrserth
83a9222c39 Core/SAI: allow creatures to handle gameobject spellhit SAI events. (#23492)
(cherry picked from commit 7a71127da9)
2021-12-13 00:42:17 +01:00
Wyrserth
62f5d9b46b Core/SAI: do not pass old creatureData to UpdateEntry() and keep current health when changing a NPC's entry. (#23493)
(cherry picked from commit 8967cc96df)
2021-12-13 00:42:17 +01:00
Wyrserth
e8c1adcf8f Core/SAI: silence wrong SAI error when using SMART_ACTION_SET_DATA on a creature using CreatureAI.
This behavior is fully allowed and should not report any kind of error.

(cherry picked from commit c95531595e)
2021-12-13 00:42:16 +01:00
ccrs
f4a71ea9aa Core/AI: remove extra empty line
(cherry picked from commit 3c77c04b05)
2021-12-12 02:15:10 +01:00
Treeston
743d022cee AI/SmartAI: Properly forward to inherited CreatureAI::JustAppeared in SmartAI::JustAppeared. Fixes #23491.
(cherry picked from commit 854a113fc7)
2021-12-12 02:11:15 +01:00
Treeston
e398bb1664 AI/SmartAI: Move SMART_EVENT_RESPAWN invocation from ::InitializeAI() to ::JustAppeared(). Closes #23313.
(cherry picked from commit 37fc38b917)
2021-12-12 01:27:04 +01:00
Wyrserth
5331656785 Core/SAI: allow to start waypoint movement for a creature that is in combat. (#23426)
(cherry picked from commit d6e3660115)
2021-12-11 15:29:32 +01:00
Wyrserth
7745e3f943 Core/SAI: add cooldownMin (event_param2) and cooldownMax (event_param3) to SMART_EVENT_ACCEPTED_QUEST and SMART_EVENT_REWARD_QUEST. (#23422)
(cherry picked from commit 50be697e1f)
2021-12-11 14:14:10 +01:00
Wyrserth
e846d4c3ef Core/SAI: don't allow to start a new SAI actionlist while the entity is already running one. (#23421)
(cherry picked from commit 2b1cde2560)
2021-12-11 14:13:11 +01:00
jackpoz
1b6dee9990 Core/SmartAI: Rename SMART_EVENT_HEALT_PCT to SMART_EVENT_HEALTH_PCT
(cherry picked from commit 50ed1bb5b3)
2021-12-11 11:35:07 +01:00
Wyrserth
d037c6b086 Core/SAI: add action_param3 to SMART_ACTION_REMOVEAURASFROMSPELL to allow it to remove only auras from spells that were cast by the entity itself. (#23345)
(cherry picked from commit d365dd9157)
2021-12-10 21:12:25 +01:00
Giacomo Pozzoni
33347c7d5f Core/Misc: Fix static analysis issues
Fix static analysis issues reported by Coverity Scan

(cherry picked from commit e12398afdc)
2021-12-09 00:24:41 +01:00
jackpoz
e9aed3e442 Core/SmartAI: Improve SMART_EVENT_GOSSIP_HELLO
Add another value to event_param1 for SMART_EVENT_GOSSIP_HELLO to support all cases of OnGossipHello/OnReportUse in GameObjects:
- event_param1 set to 0: execute the action for both OnGossipHello and OnReportUse. This might result in the action being executed twice when clicking the GameObject
- event_param1 set to 1: execute the action for only OnGossipHello
- event_param1 set to 2: execute the action for only OnReportUse

(cherry picked from commit 9e58ef6940)
2021-12-08 21:33:58 +01:00
jackpoz
6034992dff Core/SmartAI: Implement SMART_EVENT_SUMMONED_UNIT and SMART_EVENT_SUMMON_DESPAWNED for GameObject owners
(cherry picked from commit 507a56d627)
2021-12-07 00:31:26 +01:00
Giacomo Pozzoni
5f545f5402 3.3.5 gameobject summoner (#23289)
* Scripts/Misc: Change IsSummonedBy(Unit*) to IsSummonedBy(WorldObject*)

* Scripts/Misc: Fix build

* Core/TempSummons: Rename GetSummoner() to GetSummonerUnit()

* Core/TempSummons: Add support to TempSummons::GetSummoner() to return GameObject too

* Fix build

* Core/TempSummons: Allow GameObject to be owner of TempSummon

* Core/TempSummons: Add support to SAI for GameObject owner of TempSummon

* Scripts/Misc: Fix no-pch build

* Core/TempSummons: Implement PR comments

(cherry picked from commit 797fba98e9)
2021-12-07 00:02:03 +01:00
jackpoz
54044bda82 Core/SmartAI: Fix SMART_EVENT_SUMMON_DESPAWNED
Fix SMART_EVENT_SUMMON_DESPAWNED not working when event_param1 was set to any value other than 0

(cherry picked from commit 457fc22473)
2021-12-06 23:27:45 +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