cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
179 stars 47 forks source link

🐛 [Bug Report] All creatures and npcs spawning with empty HP #2455

Closed leojoeng closed 3 years ago

leojoeng commented 3 years ago

Current behavior: Hello, bug found in the latest release of vanilla 1.12, which all creatures and npcs spawning with empty HP, although it can regen back full HP within a few secs but it is not intended to be as the original game. unknown

Expected behavior: Creatures or Npcs is supposed to be full health when spawning. Steps to reproduce:

  1. Kill a mob or npc.
  2. Try using command .respawn on any dead body and look at the hp bar while it respawns.

Client version: 1.12.1.5875

Commit hash: 234187bd2e77ab946e5332b46fc7188b641d1aaa

Database version: Classic DB version 1.11 "Into the Frozen Heart of Naxxramas". For Classic core z2757.

Operating system: Windows 10

MilkmanMHOC commented 3 years ago

Unfortunately some players can use this to their advantage by camping spawns and tagging things at low health. Once hit, they stop their fast HP gain and are quickly or instantly killed depending on the speed at which they are hit as they re spawn.

cala commented 3 years ago

NPCs in Classic DB have their health set to the max value for their level in the database (checked right now). So I assume the issue you describe occurs either at creature loading in core from database (type conversion issue ?) or when adding the creature to the world and calculting their stats.

killerwife commented 3 years ago

@cala setting hp to max value is not correct for mobs which have multiple levels. The fix to this issue is REMOVED BAD QUERY and also setting it for any creature which has multiple levels.

The line of code responsible for this is:

uint32 curhealth = data->curhealth > 1 ? data->curhealth : GetMaxHealth();

when utilizing CLS to calculate max HP.

Somehow it slipped through the cracks and is an issue across all 3 cores due to my fault. I will fix tbc-db but @cala and @Grz3s need to fix their own repos so i dont mess something up.

EDIT: curhealth=1 is correct, not curhealth=0 EDIT2: The fix is to use curhealth==1 whenever we use CLS. Only mobs which spawn with not-full hp and should keep that not-full hp should not have ==1

killerwife commented 3 years ago

Last thing, I would like to know the exact spawn this occurs on (because i dont think it occurs on all classic-db spawns as of now) in case this did not work.

leojoeng commented 3 years ago

Last thing, I would like to know the exact spawn this occurs on (because i dont think it occurs on all classic-db spawns as of now) in case this did not work.

This occurs on every creature that not curhealth=1 in DB, curhealth>1 or =0 will spawn with 0 hp.

killerwife commented 3 years ago

Solved https://github.com/cmangos/classic-db/commit/6ae09371ba6a9f059ca870a49fe2789a061343a0 Pull both core and db

cala commented 3 years ago

setting hp to max value is not correct for mobs which have multiple levels.

@killerwife this is the current convention for Classic and WotLK databases. I honestly don't mind this convention being changed, but as it affects all creatures in the world it should be advertised a bit more as it seems that neither @Grz3s nor myself were aware of it being changed, at least in TBC-DB.

In a more broad scope, I think this change questions the very existence of curhealth and curmana fields now that we use CLS. All creatures that I can think of (at least in Classic) that do not spawn with full health/mana are handled in ScriptDev2, making these fields rather unnecessary.

killerwife commented 3 years ago

TBC and WOTLK has a lot more of these. This is why creature_spawn_data_template has curhealth and curmana so we can remove it creature table because the number of mobs is below 2% of all mobs. I guess I have not advertised this enough, however before my changes, mobs which had curhealth set to less than max of max lvl, it always used to spawn with less than 100% but it quickly regenned the hp.

I guess this is one of these things we changed on vengeance in like 2016 and it slipped through the cracks.

That being said, the main culprit of this issue was the default value of creature_spawn_data_template column curhealth being different in mangos-classic than in tbc and wotlk, I have fixed that and pushed that.

cala commented 3 years ago

Thanks. Good job. 👍🏻

Grz3s commented 3 years ago

strange koz im adding/removing .. lots creatures almost every day .. and i didnt see that happening even once.... BTw: i saw this issue with pets/guardians... some time ago.. but its not related or prob fixed already

killerwife commented 3 years ago

@Grz3s you copied my 0334_cyclic_splines.sql where it was fixed

Grz3s commented 3 years ago

that explains all ..