SirPlease / L4D2-Competitive-Rework

Just refreshing and optimizing the core files a bit, eh?
GNU General Public License v3.0
242 stars 131 forks source link

[BUG] Witch/Tank Damage Announce - No Report and Wrong Percentage #821

Open deprid opened 2 days ago

deprid commented 2 days ago

Describe the bug

When 5 or more survivors do some damage to a Witch/Tank, no damage report gets produced or the percentage does not add up to 100% in the damage report. Both l4d_witch_damage_announce as well as l4d_tank_damage_announce have this bug.

Related SourceMod error log: Witch: ``` L 09/19/2024 - 17:03:09: [SM] Exception reported: Invalid memory access L 09/19/2024 - 17:03:09: [SM] Blaming: l4d_witch_damage_announce.smx L 09/19/2024 - 17:03:09: [SM] Call stack trace: L 09/19/2024 - 17:03:09: [SM] [1] Line 250, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::PrintWitchDamage L 09/19/2024 - 17:03:09: [SM] [2] Line 214, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::CalculateWitch L 09/19/2024 - 17:03:09: [SM] [3] Line 186, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::WitchDeath_Event L 09/19/2024 - 17:03:09: [SM] Exception reported: Invalid memory access L 09/19/2024 - 17:03:09: [SM] Blaming: l4d_witch_damage_announce.smx L 09/19/2024 - 17:03:09: [SM] Call stack trace: L 09/19/2024 - 17:03:09: [SM] [1] Line 250, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::PrintWitchDamage L 09/19/2024 - 17:03:09: [SM] [2] Line 214, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::CalculateWitch L 09/19/2024 - 17:03:09: [SM] [3] Line 203, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::PrintAnyway L 09/19/2024 - 17:13:32: Error log file session closed. L 09/17/2024 - 22:57:16: [SM] Exception reported: Invalid memory access L 09/17/2024 - 22:57:16: [SM] Blaming: l4d_witch_damage_announce.smx L 09/17/2024 - 22:57:16: [SM] Call stack trace: L 09/17/2024 - 22:57:16: [SM] [1] Line 250, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::PrintWitchDamage L 09/17/2024 - 22:57:16: [SM] [2] Line 219, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::CalculateWitch L 09/17/2024 - 22:57:16: [SM] [3] Line 203, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_witch_damage_announce.sp::PrintAnyway L 09/17/2024 - 22:58:06: Error log file session closed. ``` Tank: ``` L 08/09/2024 - 20:46:48: [SM] Exception reported: Invalid memory access L 08/09/2024 - 20:46:48: [SM] Blaming: l4d_tank_damage_announce.smx L 08/09/2024 - 20:46:48: [SM] Call stack trace: L 08/09/2024 - 20:46:48: [SM] [1] Line 285, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_tank_damage_announce.sp::PrintTankDamage L 08/09/2024 - 20:46:48: [SM] [2] Line 209, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_tank_damage_announce.sp::Event_RoundEnd L 08/09/2024 - 20:51:18: [SM] Exception reported: Invalid memory access L 08/09/2024 - 20:51:18: [SM] Blaming: l4d_tank_damage_announce.smx L 08/09/2024 - 20:51:18: [SM] Call stack trace: L 08/09/2024 - 20:51:18: [SM] [1] Line 285, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_tank_damage_announce.sp::PrintTankDamage L 08/09/2024 - 20:51:18: [SM] [2] Line 226, D:\steamcmd\l4d2\left4dead2\addons\sourcemod\scripting\l4d_tank_damage_announce.sp::Timer_CheckTank ```

To Reproduce Steps to reproduce the behavior:

  1. Play in a server with more than 5 or more survivors (coop)
  2. Make sure 5 or more survivors do some damage to a Witch
  3. Bug happens, no damage report get produced or the percentage does not add up to 100%

Screenshots/Video

No Tank damage report: ![20240806222022_1](https://github.com/user-attachments/assets/f36d34bd-5314-490c-8e85-ca94f1a0e945) ![20240807000900_1](https://github.com/user-attachments/assets/3c834b89-618a-43f4-acb1-3dd74ebb84bb) ![20240807223704_1](https://github.com/user-attachments/assets/df38d64a-e195-4b3c-83ad-978adc624ad5)
The percentage does not add up to 100% in the damage report: ![20240807223854_1](https://github.com/user-attachments/assets/889713ba-32cd-4593-a23c-84b71480183d)
No Witch damage report: ![20240807224820_1](https://github.com/user-attachments/assets/2e7f9381-0183-4a10-b85f-c161624479ad) ![20240814001205_1](https://github.com/user-attachments/assets/817950c6-933e-4e99-a407-9c79be6a676e)

Server Operating System (if applicable):

Additional context

SirPlease commented 2 days ago

These issues are somewhat out of scope for the design of the plugins in the Competitive repo, but I agree that they are oversights in the code that can be accounted for.

The percentage not adding up to a 100% in the Witch screenshot is working as expected, as you didn't kill the witch. It's scaled off of the Witch's total health, not the damage total.

Your suggestions for the option of displaying percentages next to eachother will (in my opinion) look really messy due to how long people can have their names. 🤔

SirPlease commented 2 days ago

I've reworked the Witch Damage Announce plugin a bit, give it a go and let me know how it goes 😄 Make sure to check out the alternative solutions for the long prints that I've added and let me know if this helps~

deprid commented 1 day ago

Let us try the new version tomorrow... I just read this and we just done massacring zombies and witches

deprid commented 1 day ago

Nice man you're the hero, now it detects and displays the full report for 5+ players.

By the way, where can I find the cvars tho? I couldn't seem to find them in the cfg folder... is the .cfg file gets automatically created or needs manual edit in the source file?

SirPlease commented 1 day ago

Glad to hear it! You can setup the cvars in the server.cfg or if you're using configs, in their respective plugin cvar files. None of the plugins in the competitive repository contain anything with a generated config due to issues that can arise between matchmodes. If you insist on having an automated cfg file, you can add a single line to OnPluginStart() which would be AutoExecConfig(true); and then compile the file.

You can find the cvars in the sourcefile with their description, but I'll provide them here:

Something to keep in mind, it will only print once per witch by design. If you choose to print when a player gets incapacitated it won't print again when the witch dies.


EDIT: Aiming to update the Tank Plugin with a similar rework either later today or tomorrow~

deprid commented 1 day ago

Alright thanks for the info, didn't know that. And the provided cvar l4d_wda_print_max_lines seems more useful and sensible than my original suggestion.

Looking forward to the updated Tank plugin... and you might want to take a look at MoYu_Server_Stupid_Plugins/The Last Stand/l4d_tank_damage_announce at master · Target5150/MoYu_Server_Stupid_Plugins. Maybe it can helps you a bit.