Commit Graph

907 Commits

Author SHA1 Message Date
robinsch
f7956ffd1e Core/SAI: Prevent loading invalid smart_scripts entry (#26508)
(cherry picked from commit 8c0e6e9ee4)
2022-03-09 14:20:25 +01:00
Engilas
8a4d731d55 Core/SmartAI: AI change on charmed (#26065)
* Fix AI refresh on charmed

* Remove unnecessary refresh

* Check SMART_EVENT_FLAG_WHILE_CHARMED flag

(cherry picked from commit f6e52f6b3d)
2022-03-06 21:40:42 +01:00
Giacomo Pozzoni
a4a3e2e759 Core/Creature: Allow to skip Rate.Corpse.Decay.Looted when calling SetCorpseDelay() (#25989)
Add a second parameter to SetCorpseDelay() that specifies if Rate.Corpse.Decay.Looted setting should be ignored, false by default (aka don't ignore by default).
Add a second parameter to SMART_ACTION_SET_CORPSE_DELAY to specify if Rate.Corpse.Decay.Looted should be included, false by default (aka ignore by default).

(cherry picked from commit d5fc86af8b)
2022-03-06 18:59:38 +01:00
Giacomo Pozzoni
4c30b2a182 Core/SAI: Add new action SMART_ACTION_SET_HEALTH_PCT (#25932)
* Core/SAI: Add new action SMART_ACTION_SET_HEALTH_PCT

Add new action SMART_ACTION_SET_HEALTH_PCT (142) with one single parameter "percent" to set the Unit health.
Close #25317

* Do not allow 0%

(cherry picked from commit 7d6f7e4d19)
2022-03-06 01:43:57 +01:00
Kargatum
373ed8f46b Core: whitespace cleanup, reduce double blank line to single (#25795)
* Core/Misc: fix double empty line

* worldserver.conf

(cherry picked from commit a32b6b8ac4)
2022-03-05 20:07:57 +01:00
Giacomo Pozzoni
da0d9ee283 Core/SAI: Fix SMART_EVENT_FLAG_NOT_REPEATABLE flag being ignored when specifying a chance (and other SMART_ACTION_CAST fixes) (#25778)
* Core/SAI: Fix SMART_EVENT_FLAG_NOT_REPEATABLE flag being ignored when specifying a chance

Fix SMART_EVENT_FLAG_NOT_REPEATABLE flag being ignored when specifying a chance, always making the action trigger.

* Fix SMART_ACTION_CAST with SMART_EVENT_FLAG_NOT_REPEATABLE not casting the spell at all if rolled chance was successful but creature couldn't cast the spell

* Prevent linked actions if SMART_ACTION_CAST couldn't be completed and will be retried later

(cherry picked from commit 96b289cadb)
2022-03-05 17:11:58 +01:00
Ovah
dde5a3e326 Core/SAI: implement new smart actions to change AI Animkits and to enable/disable hover movement (#25623)
SMART_ACTION_SET_HOVER (parameter1: enable/disable)

* added SMART_ACTION_SET_AI_ANIM_KIT as immediately deprecated

(cherry picked from commit b7ba856b63)
2022-03-05 16:46:42 +01:00
jackpoz
eb17e94b2e Core/SAI: Fix SMART_ACTION_WP_RESUME actually pausing next waypoint if the current path was not paused
Fixes #25519

(cherry picked from commit 5be7c2ad4f)
2022-02-28 14:42:53 +01:00
jackpoz
b059f2f8ee Core/SAI: Allow to debug SmartAI methods
(cherry picked from commit 59bb822f78)
2022-02-28 14:42:40 +01:00
Giacomo Pozzoni
a65b3493a7 Core/SAI: Add orientation and delay columns to waypoints table (#25472)
* Core/SAI: Add orientation and delay columns to waypoints table

* Rename 2020_99_99_99_world.sql to 2020_09_19_00_world.sql

(cherry picked from commit 4b7d19c91b)
2022-02-27 20:08:41 +01:00
Giacomo Pozzoni
60519e947f Core/SAI: Fix SMART_ACTION_WP_PAUSE with 0 delay pausing the path only for 1 world loop update (#25471)
* Core/SAI: Fix SMART_ACTION_WP_PAUSE with 0 delay pausing the path only for 1 world loop update

* Add code comments

* Remove special handling of SMART_ACTION_WP_PAUSE in SMART_EVENT_WAYPOINT_REACHED

(cherry picked from commit 7dd51ae6d9)
2022-02-27 20:08:41 +01:00
Shauren
ad4f4bfab7 Core/Misc: Minor game include cleanup 2022-02-13 00:49:10 +01:00
Seyden
79c6054369 Core/Objects: Use player as summoner for personal clones (#27716)
* This allows clones to properly inherit phases
2022-02-08 00:03:02 +01:00
Rushor
dfeb8c267f Game/AI: Implement option to move a creature back to Homeposition on Evade. (#24492)
* Game/AI: Implement option to move a creature back to Homeposition on Evade.

* If ToHomePosition (action param 1) is 1 > Move to last stored position
* If ToHomePosition (action param 1) is 0 > Move to homeposition
* Ref: https://github.com/TrinityCore/TrinityCore/issues/24226

* Add parameter for walkmode

* Game/AI: SAI SMART_ACTION_EVADE - Rename ToHomePosition to ToRespawnPosition and store point from GetRespawnPosition.

* Game/AI: SAI SMART_ACTION_EVADE - Rename ToHomePosition to ToRespawnPosition

* Remove broken bits, simplify the code

* Update comments

* Code cleanup

Co-authored-by: jackpoz <giacomopoz@gmail.com>
(cherry picked from commit 02fca032e1)
2022-02-05 22:51:52 +01:00
Maks Szokalski
bc04acb726 Add "On" to some gossip methods in AI (#25415)
* Add "On" to some methods

* Update npc_innkeeper.cpp

* Update zone_borean_tundra.cpp

(cherry picked from commit 41188eb535)
2022-02-05 22:18:19 +01:00
NoName
ee620856ad Core/Movement: Corrected Animation Tier handling (PR #24875)
Co-authored-by: Warpten <vertozor@gmail.com>
Co-authored-by: Ovahlord <dreadkiller@gmx.de>
Co-authored-by: Carbenium <carbenium@outlook.com>
(cherry picked from commit dad187615d)
2022-02-05 15:40:31 +01:00
Treeston
fc094509e9 Core/Scripts: Remove now-unused WaypointPathStarted hook. WaypointStarted does everything it used to do, anyway. b3694bf follow-up.
(cherry picked from commit c9356190b7)
2022-02-05 13:31:50 +01:00
jackpoz
c2d2df96db Core/SAI: Fix SMART_EVENT_WAYPOINT_START not being called at every waypoint checking wrong path id parameter
Remove multiple calls to SMART_EVENT_WAYPOINT_START for the 1st waypoint.
Closes #24760

(cherry picked from commit b3694bf47b)
2022-02-05 13:31:00 +01:00
jackpoz
ae6f8bc4f5 Core/SAI: Do not allow SMART_EVENT_RESET to call SMART_ACTION_CALL_SCRIPT_RESET
There might be cases where this should be allowed (i.e. if the SMART_TARGET_* is another object) but for now we'll just never allow it.

(cherry picked from commit 28921f191d)
2022-02-05 12:08:58 +01:00
Giacomo Pozzoni
4dff5bd09b Core/SAI: Reduce the chance of infinite loops/stack overflows (#25398)
Fixes #24092

(cherry picked from commit a58aeb41f4)
2022-02-05 11:51:54 +01:00
Giacomo Pozzoni
902ed74c2a Core/SAI: Implement SMART_TARGET_ACTION_INVOKER in SMART_EVENT_FRIENDLY_HEALTH_PCT (#25318)
* Core/SAI: Implement SMART_TARGET_ACTION_INVOKER in SMART_EVENT_FRIENDLY_HEALTH_PCT

* Require radius (5th parameter) to be set

(cherry picked from commit cbed1039c4)
2022-02-04 00:27:13 +01:00
jackpoz
1f2c48f8bb Core/SAI: Remove completed timed action lists even while evading
Fixes #25294

(cherry picked from commit 03eb0886a8)
2022-02-04 00:27:12 +01:00
Shauren
88659dcebf Core/Gossip: Sync naming and db structure with 3.3.5 2022-01-26 23:49:42 +01:00
Giacomo Pozzoni
f2ee365da4 Core/SAI: Spell casts that cannot be executed because the unit is currently casting another spell will be retried asap with priority over other events (#25238)
* Core/SAI: Spell casts that cannot be executed because the unit is currently casting another spell will be retried asap with priority over other events

* Core/SAI: Re-sort the events only when needed

* Fix some priority reset and wrong mEventSortingRequired handling

* Code cleanup.
Sort only events loaded from db (not stored events, not timed action list).

* Code cleanup.
Raise priority of failed casts so they are retried before other spells

* Keep priority of the action fails and is rescheduled on next update

* Don't try recasting a spell in SMART_ACTION_CAST if there are multiple targets and at least 1 was successful

(cherry picked from commit ca25e8d019)
2022-01-26 22:26:08 +01:00
Peter Keresztes Schmidt
2e3c612c80 Core/Unit: Make HandleEmoteCommand typesafe (#25249)
* Scripts/ScarletMonastery: Fix wrong emote during Headless Horseman encounter

* Scripts/HoR: Fix wrong emote during escape event

* Core/Unit: Make improve type safety of HandleEmoteCommand

Change argument type to the expected enum type Emote

* Scripts/CoS: Use SetUInt32Value to set UNIT_NPC_EMOTESTATE

UNIT_NPC_EMOTESTATE is no flag field

(cherry picked from commit 6c7837f947)
2022-01-26 21:46:51 +01:00
Giacomo Pozzoni
e11e1938b5 Core/SAI: Fix creatures casting with flag SMARTCAST_COMBAT_MOVE not switching to melee when the school of the spell they are trying to cast gets silenced (and other cases of spell failure) (#25226)
* Core/SAI: Fix creatures casting with flag SMARTCAST_COMBAT_MOVE not switching to melee when the school of the spell they are trying to cast gets silenced (and other cases of spell failure)

* Core/SAI: Retry casting after 500ms if a cast failed

Fixes #24914

(cherry picked from commit 63a6e1e048)
2022-01-26 19:21:10 +01:00
jackpoz
b3545479bf Core/SAI: Fix creatures casting spells while moving with flag SMARTCAST_COMBAT_MOVE
Fixes #24019

(cherry picked from commit 2910d0fb24)
2022-01-26 16:23:15 +01:00
Giacomo Pozzoni
864d775280 Core/Misc: Fix static analysis issues (#25194)
(cherry picked from commit 07fd84b679)
2022-01-26 14:06:40 +01:00
Giacomo Pozzoni
1977d26050 Core/SAI: Ignore SAI while evading (#25108)
(cherry picked from commit 420b21be98)
2022-01-24 13:21:46 +01:00
Shauren
c7899c1e76 Core/WorldObject: std::chrono-ify SummonPersonalClone 2022-01-24 12:57:40 +01:00
Carbenium
82fce41852 Core/WorldObject: Replace non-std::chrono SummonGameObject overloads
Also fix intended despawn time of GOs used by the "Engineering a Disaster" quest

(cherry picked from commit 8642aaaf92)
2022-01-24 12:55:43 +01:00
Carbenium
310f996b1d Core/WorldObject: Partially std::chrono-ify SummonCreature overloads
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, uint32 despawnTime = 0);
to
TempSummon* SummonCreature(uint32 entry, float x, float y, float z, float o = 0, TempSummonType despawnType = TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime = 0s);

(cherry picked from commit 1131229ee9)
2022-01-24 11:55:32 +01:00
Peter Keresztes Schmidt
ad340466d0 Misc: Use [[fallthrough]] attribute instead of comment to mark intentional fallthroughs (#25054)
Related: #25006
(cherry picked from commit 85b5b842ca)
2022-01-23 22:02:03 +01:00
akrom23
77d76ecc1d Creature/AI: Remove SetVisible from SmartAI::InitializeAI
Closes #24184

(cherry picked from commit f99a79cb43)
2022-01-22 00:34:25 +01:00
Shauren
a270005de1 Core/SAI: Support SMART_TARGET_POSITION in SMART_ACTION_BECOME_PERSONAL_CLONE_FOR_PLAYER 2022-01-19 19:20:56 +01:00
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