DeathState being updated wrong when a creature/critter is killed by melee/low damage
Originally reported on CC at: https://github.com/chromiecraft/chromiecraft/issues/5453 By: Apathyxia
What client do you play on?
enGB
Faction
Alliance
Content Phase:
30-39
Current Behaviour
Quest Marsh Frog Legs quest item Marsh Frog Leg does not drop if the frogs are killed by basic attacks. They do, however, drop if killed with abilties or spells.
Expected Blizzlike Behaviour
The frogs should drop legs even if killed by basic attacks.
Source
https://youtu.be/mmJtYlLkq4g?t=397
Steps to reproduce the problem
- Pick up quest https://www.wowhead.com/wotlk/quest=1218/marsh-frog-legs in Dustwallow Marsh, north east of Theramore.
- Kill nearby frog with basic attacks and with spells / abilities
- Observer that basic attack kills don't yield quest items
Extra Notes
I tested this as an alliance druid. Tested both human form, cat form and spells. Abilities as well as spells yielded quest items - hitting with a staff or basic attacking in cat form did not yield quest items.
Other issues that are related: https://github.com/chromiecraft/chromiecraft/issues/5670 - author claims that there is also an issue with loot rotation - needs to be checked, but is more likely to also be a part of the auto-attack problem https://github.com/azerothcore/azerothcore-wotlk/issues/16267 https://github.com/chromiecraft/chromiecraft/issues/4939
AC rev. hash/commit
https://github.com/chromiecraft/azerothcore-wotlk/commit/ce6ca597b54e64f328cacddae5f003cdc41a343d
Operating system
Ubuntu 20.04
Modules
- mod-ah-bot
- mod-bg-item-reward
- mod-BreakingNewsOverride
- mod-cfbg
- mod-chat-transmitter
- mod-cta-switch
- mod-desertion-warnings
- mod-duel-reset
- mod-eluna
- mod-instanced-worldbosses
- mod-ip-tracker
- mod-low-level-arena
- mod-low-level-rbg
- mod-multi-client-check
- mod-progression-system
- mod-pvp-titles
- mod-pvpstats-announcer
- mod-queue-list-cache
- mod-rdf-expansion
- mod-transmog
- mod-weekend-xp
- mod-zone-difficulty
- lua-carbon-copy
- lua-event-scripts
- lua-exchange-npc
- lua-level-up-reward
- lua-recruit-a-friend
- lua-send-and-bind
- lua-temp-announcements
- lua-zonecheck
Customizations
None
Server
ChromieCraft
Good day. It will be great if someone from devs can find time to have a look into this quest, since Dustwallow Marsh in popular quest hub at wotlk and a lot (if not each) player encountered with this bug during questing. And if for casters there is no problem to kill frogs with spells and get quest items, for hunters and rogues it's hard. I think that some useful discussion for also in this report - https://github.com/azerothcore/azerothcore-wotlk/issues/16267.
Thank you in advance for your time and attention.
Good day. It will be great if someone from devs can find time to have a look into this quest, since Dustwallow Marsh in popular quest hub at wotlk and a lot (if not each) player encountered with this bug during questing. And if for casters there is no problem to kill frogs with spells and get quest items, for hunters and rogues it's hard.
Thank you in advance for your time and attention.
I can actually confirm this on https://github.com/azerothcore/azerothcore-wotlk/commit/79b39f9655111088a741185c4dabd31dae7d85ea
Killing the frog with a melee ability as a rogue will result in no loot Killing the frog with a ranged ability as a mage will result in loot
So the report is partially correct. Any non-melee ability will result in loot. But Sinister Strike for example won't work
i found that if you change type of creature from Critter (8) to somehting Not specified (10) UPDATE creature_template SET type = 10 WHERE entry = 23979; than loot will be after mele attack Also there is another creature Dig Rat (3444) with lootid and type 8, and it has the same problem with loot (only if spell damage kills it you can loot) I am assuming that creature type (8) causes bug - no loot after melee attack
Only two entrys with lootid and type 8 in DB exist.
SELECT entry, name FROM creature_template WHERE type = '8' AND lootid <> '0';
+-------+------------------+
| entry | name |
+-------+------------------+
| 3444 | Dig Rat |
| 23979 | Giant Marsh Frog |
+-------+------------------+
2 rows in set
Here's the issue.
https://github.com/azerothcore/azerothcore-wotlk/blob/da6ff31056d46c046ab570bd335cd1e81242cd96/src/server/game/Entities/Unit/Unit.cpp#L17974 IsDamageEnoughForLootingAndReward() returns true.
https://github.com/azerothcore/azerothcore-wotlk/blob/da6ff31056d46c046ab570bd335cd1e81242cd96/src/server/game/Entities/Player/PlayerStorage.cpp#L5644 IsDamageEnoughForLootingAndReward() returns false.
https://github.com/azerothcore/azerothcore-wotlk/blob/da6ff31056d46c046ab570bd335cd1e81242cd96/src/server/game/Entities/Creature/Creature.cpp#L3706-L3709 Somewhere between the two checks above _playerDamageReq is changed to > 0 causing IsDamageEnoughForLootingAndReward() to return false.
This only happens for melee damage and not spell damage, hence why we get loot from spells but not from melee.
Killed with Melee
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Unit::Kill isRewardAllowed TRUE
CREATURE ENTRY 23979 . _playerDamageReq 1 . IS DAMAGE ENOUGH? false
Player::isAllowedToLoot FALSE
Killed with Spell
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Unit::Kill isRewardAllowed TRUE
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Creature::LowerPlayerDamageReq first _playerDamageReq 6
Creature::LowerPlayerDamageReq second _playerDamageReq 0
Creature::LowerPlayerDamageReq first _playerDamageReq 0
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Unit::Kill isRewardAllowed TRUE
Creature::ResetPlayerDamageReq _playerDamageReq 2
CREATURE ENTRY 23979 . _playerDamageReq 2 . IS DAMAGE ENOUGH? false
Player::isAllowedToLoot FALSE
Pretty clear to say that ResetPlayerDamageReq() is causing issues here
Called from here https://github.com/azerothcore/azerothcore-wotlk/blob/6202835cff40a47658d14a15d6ebb33e2159b1a4/src/server/game/AI/CreatureAI.cpp#L309
But now the question is. Why the HELL isn't the creature classed as dead when killed by melee https://github.com/azerothcore/azerothcore-wotlk/blob/6202835cff40a47658d14a15d6ebb33e2159b1a4/src/server/game/AI/CreatureAI.cpp#L292-L297
So this is somehow due to DeathState being changed from Corpse to Alive
Creature::LowerPlayerDamageReq first _playerDamageReq 6
Creature::LowerPlayerDamageReq second _playerDamageReq 0
Creature::LowerPlayerDamageReq first _playerDamageReq 0
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Creature::IsDamageEnoughForLootingAndReward DeathState 0
Unit::Kill isRewardAllowed TRUE
CreatureAI::_EnterEvadeMode DeathState 0
Creature::ResetPlayerDamageReq _playerDamageReq 1
DamageReq has been increased to ONE
CREATURE ENTRY 23979 . _playerDamageReq 1 . IS DAMAGE ENOUGH? false
Creature::IsDamageEnoughForLootingAndReward DeathState 2
Player::isAllowedToLoot FALSE
CreatureAI::_EnterEvadeMode DeathState 0
CreatureAI::_EnterEvadeMode DeathState 0
CreatureAI::_EnterEvadeMode DeathState 0
But let me tell you. The frog is very much dead.
So this is probably not an issue of loot, but an issue of DeathState being changed incorrectly
CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Creature::IsDamageEnoughForLootingAndReward DeathState 0
Unit::Kill isRewardAllowed TRUE
CreatureAI::_EnterEvadeMode DeathState 0
Creature::ResetPlayerDamageReq _playerDamageReq 1
DamageReq has been increased to ONE
CREATURE ENTRY 23979 . _playerDamageReq 1 . IS DAMAGE ENOUGH? false
Creature::IsDamageEnoughForLootingAndReward DeathState 2
Player::isAllowedToLoot FALSE
CreatureAI::_EnterEvadeMode DeathState 0
And this is also weird. At kill it is Alive, then ResetPlayerDamageReq() is called, then it is Corpse, then it magically becomes Alive again.
Definetly something wrong with DeathState here and not loot. As the Loot is restricted by _EnterEvadeMode() going through
Creature::Update ALIVE
Creature::Update ALIVE
Creature::Update ALIVE
Creature::LowerPlayerDamageReq first _playerDamageReq 6
Creature::LowerPlayerDamageReq second _playerDamageReq 0
Creature::IsDamageEnoughForLootingAndReward CREATURE ENTRY 23979 . _playerDamageReq 0 . IS DAMAGE ENOUGH? true
Creature::IsDamageEnoughForLootingAndReward DeathState 0
Unit::Kill isRewardAllowed TRUE
CreatureAI::_EnterEvadeMode DeathState 0
Creature::ResetPlayerDamageReq _playerDamageReq 6
Creature::Update CORPSE
Creature::IsDamageEnoughForLootingAndReward CREATURE ENTRY 23979 . _playerDamageReq 6 . IS DAMAGE ENOUGH? false
Creature::IsDamageEnoughForLootingAndReward DeathState 2
Player::isAllowedToLoot FALSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
CreatureAI::_EnterEvadeMode DeathState 0
CreatureAI::_EnterEvadeMode DeathState 0
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
Creature::Update CORPSE
How do we know it is melee-related?
Spell hit: 18 -> Get Loot Melee hit: 20 -> No Loot
If someone want to replicate my beautiful logs to debug, here they are https://gist.github.com/Kitzunu/5946a9d78c2bd7358ff04c4ab45246ef