Commit Graph
578 Commits
Author SHA1 Message Date
Shauren cd5357dc18 Core/PacketIO: 9.1.0 opcodes and packet structures 2021-08-08 00:18:05 +02:00
ariel- d91e099b10 Core/Spells: prevent creatures to focus channeled spells without SPELL_ATTR1_CHANNEL_TRACK_TARGET
- Creatures stuck here wouldn't try attacking because of this
- Remove one workaround in halion script, now it's unneeded

Ref #11311

(cherry picked from commit 29f7258dc824659cb2de81c5ff3b3b3853de2a8b)
2021-06-21 12:47:03 +02:00
Treeston 95fb6fe075 Core/Creature: Adjust SelectVictim behavior: (PR #21324)
- No more automatic combat -> threat promotion. This matches anecdotal retail behavior - spells already in transit will not cause mob to chase you if its primary target vanishes before the spell hits.
- Prevent mobbing by stopping creatures from auto-acquiring a nearby target just because the primary target vanished.

(cherry picked from commit 1acfefb973895b0e3df3c8d9b43b920d2a1b5392)
2021-06-19 01:35:41 +02:00
Treeston cb3a041482 Core/Creature: add an assertion to guard against infinite loops
(cherry picked from commit 320306554c2240c74d991f459e7bad5eef39ec5a)
2021-06-18 21:20:41 +02:00
ariel- c77925da4a Core/Entities: killed Creature::SetInCombatWithZone and replaced with AI version
Closes #12108 (again)

(cherry picked from commit 7c9722a4ae08b5f283f6a085a411e37604a7da9f)
2021-06-16 21:03:06 +02:00
ariel- 861cf261c5 Core/Formations: update codestyle and fix crash
Closes #21288

(cherry picked from commit 73cc613dc86d7d72d78f22affe2faba6786bccc5)
2021-06-16 19:26:32 +02:00
Treeston ac8ff49274 Core/Unit: Abide UNIT_FLAG2_DISABLE_TURN on creatures. Add that flag to Kologarn (from sniff). Hi sirikfoll.
(cherry picked from commit d9c772303cc17d98581cc52bb51116f640e23c08)
2021-05-17 00:36:06 +02:00
kelno 1206e815cd Core/Creature: improve DB linked_respawn handling (#21172)
* Fixed SetCreatureLinkedRespawn function possible erasing/replacing a GameObject link (instead of a creature one)

(cherry picked from commit 70eb18d0e58ecf0cfcda4f410a183c671fbafe5c)
2021-05-16 21:56:06 +02:00
Treeston c31ae7ab33 Core/Threat: Fix a potential exploit allowing players to damage a boss without them taking damage.
Scripts/Halion: General cleanup of old hacks no longer needed under new combat system.

(cherry picked from commit 9ad11e67fb6b410f18031ee68259866ea1354c8c)
2021-05-16 21:56:06 +02:00
Treeston 5aee452943 Core/Misc: A variety of clean-up changes, mostly following up on 532ab1c to fix legacy bugs exposed by it:
- Triggers can no longer have a threat list (this may expose some ugliness in old legacy scripts)
- Threat entries are forced to OFFLINE if the AI refuses to attack the target
- Clean up passive creature evade behavior to be more consistent
- Fix a months old issue in spawn group management that would cause "Inactive" to incorrectly show in .list respawns for system groups outside of map 0
- Valithria script cleanups, remove old hacks and make it work with the new system. Closes #21174.
- Some strings cleanup

(cherry picked from commit 9f9507e6a1fd50a5ce643a4096c1712700244a61)
2021-05-16 21:56:05 +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 532ab1c7f8653d1a2e48aa1f1f8a9ba1041d4bb7)
2021-05-16 21:56:01 +02:00
Jeremy 446fc391f0 Core/Entities: Fix some weird movement due to los issues (#21125)
* Core/Entities: Fix some weird movement due to los issues
- Made LoS check use collisionHeight instead of midsection. Value was too low.
- Gnomes will now have a breath bar more quickly than for example a tauren.
- Changes have been made to checking for ground z as well, some tweeking might be needed but removed most of the scattered +2.0f/+0.5f/we
* Add 0.05f to isInAir check in Creature::UpdateMovementFlags

(cherry picked from commit e42903ec16f4849b71bc8736e3151a1e11d3cd25)
2021-04-15 05:53:27 +02:00
jackpoz e17e4e6f07 Core/Misc: Replace time(NULL) with GameTime::GetGameTime()
(cherry picked from commit 12701cb0c6c45eb105ad449eb9a56e76d84d691e)

 Conflicts:
	src/server/game/Achievements/AchievementMgr.cpp
	src/server/game/AuctionHouse/AuctionHouseMgr.cpp
	src/server/game/AuctionHouseBot/AuctionHouseBotBuyer.cpp
	src/server/game/AuctionHouseBot/AuctionHouseBotSeller.cpp
	src/server/game/Battlefield/Battlefield.cpp
	src/server/game/Battlefield/Zones/BattlefieldWG.cpp
	src/server/game/Battlegrounds/BattlegroundMgr.cpp
	src/server/game/Calendar/CalendarMgr.h
	src/server/game/DungeonFinding/LFGQueue.cpp
	src/server/game/Entities/Corpse/Corpse.cpp
	src/server/game/Entities/Creature/Creature.cpp
	src/server/game/Entities/Item/Item.cpp
	src/server/game/Entities/Pet/Pet.cpp
	src/server/game/Entities/Player/Player.cpp
	src/server/game/Entities/Unit/Unit.cpp
	src/server/game/Globals/ObjectMgr.cpp
	src/server/game/Grids/ObjectGridLoader.cpp
	src/server/game/Guilds/Guild.cpp
	src/server/game/Handlers/AuctionHouseHandler.cpp
	src/server/game/Handlers/BattlefieldHandler.cpp
	src/server/game/Handlers/CalendarHandler.cpp
	src/server/game/Handlers/CharacterHandler.cpp
	src/server/game/Handlers/ChatHandler.cpp
	src/server/game/Handlers/LFGHandler.cpp
	src/server/game/Handlers/MailHandler.cpp
	src/server/game/Handlers/MiscHandler.cpp
	src/server/game/Handlers/MovementHandler.cpp
	src/server/game/Handlers/PetHandler.cpp
	src/server/game/Handlers/QueryHandler.cpp
	src/server/game/Handlers/TicketHandler.cpp
	src/server/game/Instances/InstanceSaveMgr.cpp
	src/server/game/Server/WorldSession.cpp
	src/server/game/Server/WorldSocket.cpp
	src/server/game/Spells/Auras/SpellAuras.cpp
	src/server/game/Tickets/TicketMgr.cpp
	src/server/game/Tickets/TicketMgr.h
	src/server/game/World/World.cpp
	src/server/scripts/Commands/cs_gobject.cpp
	src/server/scripts/Commands/cs_instance.cpp
	src/server/scripts/Commands/cs_list.cpp
	src/server/scripts/Northrend/zone_wintergrasp.cpp
	src/server/scripts/Spells/spell_item.cpp
2021-04-15 05:53:27 +02:00
ariel- e4ca95983b Core/Creatures: fixed school immunity unapply when updating entry and unified code
- Also use correct data type for SQL (INT <-> uint32)

(cherry picked from commit 00c0ec3f2784e67f4ccc7616bf65aa7e5496687a)
2021-04-15 05:53:27 +02:00
Wyreth ed3b34e33f Core/Creature: implement school immunity for creatures in creature_template (#20709)
(cherry picked from commit ae878e18ef121b7b1960f40f2b0f99debd2155d8)
2021-04-15 05:53:27 +02:00
ariel- 88ae43fa51 Core/Misc: minor typo and codestyle fixes
- Replace NULL uses in new code with nullptr
- Fix wrong (accumulated) load time log when loading calendar invites
- Make Creature::CanRegenerateHealth const as its just a getter
- Mark OnlyOnceAreaTriggerScript::OnTrigger as final in case someone wants to override that (you are supposed to use protected _OnTrigger hook)

(cherry picked from commit 78a1c687a25d91dd6b13251f28d03ec6a0a49b8a)
2021-03-15 20:17:31 +01:00
jackpoz a01d397c3d Core/Misc: Fix static analysis issues
Fix static analysis issues reported by 3rd party tools

(cherry picked from commit 24e82fe83d384e3a4cf17719e728760053516607)
2021-02-25 18:50:55 +01:00
Ovah 2a51edc5bc Core/Creatures: Implemented extra flag to use offhand attacks (#21008)
* Fixed initial offhand attack timer so the main and offhand attacks will now act blizzlike instead of getting executed at the same time

Note: since some creature equipment items cannot be identified as weapon since they are only visual items there is no way to detect this automaticly
(cherry picked from commit 869affa89300c24b85896a050b58241714786454)
2021-02-25 18:50:55 +01:00
ccrs 58de8141e5 Core/Creature: 2d1ef6b5b0 followup
closes #20532

(cherry picked from commit caefe2b43e20eef28689c94c230f00fb5e61af20)
2021-02-15 19:13:25 +01:00
ccrs 92026abee1 Scripts/World: update guard scripts
Also remove deprecated method from Creature

(cherry picked from commit 299323ce5d2e478f2eb7fcd6572c5fbf87b98c6e)
2021-02-15 19:13:25 +01:00
r00ty-tc f3ac10f36f Core/Spawn: Limit saved/stored respawn time.
- Limit to time_t maximum, for the compiled-for architecture.

Closes #20834

(cherry picked from commit 3446424540c5692c9e0ff11803d70e8129a5adc4)
2021-02-06 21:41:51 +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 e10d7dd45cfc073c791cd5e5f3f964d14b37df3d)
2021-01-29 19:23:53 +01:00
Teppic1 0f837c0a02 Core/Creatures: Remove duplicate check for evade from Creature::CanAssistTo (#20722)
(cherry picked from commit 967dcc5dba0df965e4df19b5c6d02e4880dfce58)
2021-01-13 22:04:52 +01:00
r00ty-tc 7a21d02da1 Core/Maps: Prevent potential null dereference
- Coverity: 1381663

(cherry picked from commit 82a93e6be95af4419e001a7dbf109b416a109fb6)
2021-01-13 22:04:52 +01:00
Shauren 4ca29f3cb0 Core/Misc: First set of required db changes for 9.0 2020-12-08 18:16:46 +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 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 91c0d49c188977c3d797f5749b1204612ce50195)
2020-08-23 15:56:21 +02:00
Treeston 22b754c9e2 Core/Creature: temporary summons are now dynamic flagged (oversight in dynspawn). This fixes issues with vehicle kit resets breaking AI.
Closes #20137 #20138 #20153.

(cherry picked from commit 92e9376e5eecdc3412104a0ee304d389d4ce0188)
2020-08-23 14:52:51 +02:00
ccrs 0a133e77d6 Core/Movement: 7fff83d6752 followup
remove home position set from creature PauseMovement, and use it when necessary
change log level on DelayedDelete

(cherry picked from commit cd4775420a4894012616d54467eb3827430245b5)
2020-08-23 00:48:46 +02:00
sirikfoll 7586daad62 Core/Misc: Remove Whitespaces
(cherry picked from commit e2565c2597a72ea7868eef3156014dc3a83c058f)
2020-08-23 00:48:19 +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 7fff83d67526efff63867d41b9e036a19a9287b3)
2020-08-23 00:45:46 +02:00
Treeston b538cdc129 Core/Creature: Fix a crash in .npc delete (closes #20124). Also fix an issue breaking vehicles in certain edge case situations.
(cherry picked from commit 4cf49614e6e3e4a2da09c0f00404f323ae948590)
2020-08-22 20:52:13 +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 184c45cfe0fbe4f3e4fb701f0f99994df98bdc8a)
2020-08-22 20:10:42 +02:00
Treeston f15b4f5043 Scripts/Commands: Fix some quirkiness and potential crashes with live DB modification commands (npc move and npc delete), which are horrible and should be deleted anyway.
Fixes #20104.

(cherry picked from commit 759357049cdbe9a2f97bbab6e61299cd65ba1bec)
2020-08-22 13:16:34 +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 59db2eeea0a35028779fd76372ae06cc98c8086f)
2020-08-22 12:59:57 +02:00
Treeston e6be53d141 Core/WorldObject: Properly initialize position data for all types when initially creating them. Fixes some issues with PvP objectives not having the correct area ID set on initialization. Closes #20028.
(cherry picked from commit 28b3469e89f89a8c87fad06bad27800939abf0f5)
2020-08-20 00:18:48 +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 74af880217fc567c9949d7557408718af889402f)
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 e2a1ccd118d129b96e09ff1a15ed0adb1d4a3897)
2020-08-13 22:46:44 +02:00
Treeston 51ce3b1c1d [3.3.5] Get zone/area IDs from vmap data in the liquid update (#19840)
* Add new method Map::getFullVMapDataForPosition to get area info and liquid info in a single vmap lookup
* Use this lookup in Map:: relocation methods to update m_areaId and m_zoneId fields on WorldObject
* Adjust GetZoneId/GetAreaId on WorldObject to always return these cached fields
* Clean up liquid state handling on Unit and Player
* Hand floor's Z coord up through GetFullTerrainStatusForPosition, use it to update a new field in WorldObject, and use that to feed a new GetFloorZ call on WorldObject.

Closes #16489

(cherry picked from commit f6c849729b27b77228704b595de3adaf24da2c10)
2020-07-16 22:00:24 +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 ce3787f190d28c1e981598eef2cd24c622a2cbae)
2020-06-14 23:49:05 +02:00
Treeston aa811d57b6 Partial revert of 15a207f, which was causing issues (ref #4943 and #19768). Instead, fix the underlying issue from 15a207f one level further down - Unit::getAttackerForHelper() shouldn't return units that we aren't in combat with (victim can be such a unit for players/player pets, which can startattack from a distance without entering combat). (#19814)
Fixes the following issues:
- Player pets would aggro neutral mobs as soon as they start autocasting (Imp's Firebolt) if they're in react range (due to victim != null, autocast counts as autoattack and sets victim)
- Neutral mobs would randomly evade when aggro switched between targets.

Closes #19768, #19485 and #10921.

(from PR #19814)

(cherry picked from commit 69fd6245dc41dca658cadb4e99c1ee6593fe000b)
2020-06-14 23:49:04 +02:00
ariel- 6fa8b8e1d5 Core/Creature: fix _DespawnAtEvade saving wrong respawn time
Closes #19557

(cherry picked from commit 47d387d6b0d123334e4721c55426c1d236297112)
2020-06-14 23:49:04 +02:00
ccrs 55576d20d8 Core/Creature: drop method SetPosition
eeeevil, use UpdatePosition. It was there just for old scripts compatibility.

(cherry picked from commit 17579f8d91e0dcc6990fe581de9ca51ed444b754)
2020-06-14 20:04:17 +02:00
ccrs 08f13f83af Core/Creature: IsMovementPreventedByCasting followup
Handle correctly move allowed channels: IsChannelActive checks if channel phase has started (after cast if any)
Must skip the other checks since all channels focus target.

ref #19532

(cherry picked from commit b74264aef418a3c44e98a3cf9da692fd662e008d)
2020-06-14 20:04:16 +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- 6604849716 Core/Scripts: unified scripted gossip/quest api
- Changed self-accessor on GameObjectAI to "me", like UnitAI
- Moved all related functions to AI, now Unit and GameObject have the same function names with identical behaviour
- Remove "OnUpdate" from CreatureScript/GameObjectScript, was never used and we already have AI Update method
- Quest methods no longer return a bool, the return value was used to call the AI version if the ScriptMgr one returned false
- Implemented GameObjectAI::Destroyed hook (was never called), implemented Damaged method
- Rename OnStateChanged to OnLootStateChanged to reflect when it's really called, and created a new hook OnStateChanged that only gets called on GOState change
- Since the functions are now only getting called from AI, made GetAI methods full virtual. (CanSpawn method is anyways going to be used on creatures with AI)

(cherry picked from commit f913f3bb8977c127d200d5d4a608ab434b21bbcd)
2020-05-03 03:04:32 +02:00
Shauren 82b4ca3b7c Core/Creatures: Fixed level 240 guards and updated scaling level calculation 2020-05-02 22:37:32 +02:00
funjoker 314a35f0cd Core/Creatures: Update creature scaling to use content tuning
Closes #22831
2020-05-02 22:37:28 +02:00
ariel- 93c19c4194 Core/Misc: camelize GetFaction/SetFaction properly
(cherry picked from commit 4c4dca6d694bd1064b403a31a5b1c776a326f3ce)
2020-04-29 01:36:41 +02:00