azerothcore-wotlk icon indicating copy to clipboard operation
azerothcore-wotlk copied to clipboard

DeathState being updated wrong when a creature/critter is killed by melee/low damage

Open elthehablo opened this issue 2 years ago • 15 comments

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

  1. Pick up quest https://www.wowhead.com/wotlk/quest=1218/marsh-frog-legs in Dustwallow Marsh, north east of Theramore.
  2. Kill nearby frog with basic attacks and with spells / abilities
  3. 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

Customizations

None

Server

ChromieCraft

elthehablo avatar May 26 '23 13:05 elthehablo

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.

kerricsson avatar Jun 02 '23 17:06 kerricsson

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.

kerricsson avatar Jul 21 '23 19:07 kerricsson

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

Kitzunu avatar Oct 27 '23 23:10 Kitzunu

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

chaosua avatar Oct 28 '23 19:10 chaosua

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

Kitzunu avatar Jan 03 '24 18:01 Kitzunu

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

image

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

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

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

How do we know it is melee-related?

Spell hit: 18 -> Get Loot Melee hit: 20 -> No Loot

Kitzunu avatar Jan 03 '24 19:01 Kitzunu

If someone want to replicate my beautiful logs to debug, here they are https://gist.github.com/Kitzunu/5946a9d78c2bd7358ff04c4ab45246ef

Kitzunu avatar Jan 03 '24 19:01 Kitzunu