Author Topic: Fixing negative damage sometimes damages undead  (Read 1696 times)

Desident

  • Red Vardo Traders Front
  • Undead Master
  • ****
  • Posts: 417
Re: Fixing negative damage sometimes damages undead
« Reply #25 on: April 28, 2024, 09:10:53 PM »
No push back here. If it works to heal undead, and the staff thinks it's a good move for the server, I have no objections. This thoughtful offering of code, whether it fits or not is far more productive than 90% of the suggestions that don't do any of the labor for the team, and thus is qualitatively better and deserves more consideration, IMO.

Merry Munchkin

  • Dark Power
  • ******
  • Posts: 1105
Re: Fixing negative damage sometimes damages undead
« Reply #26 on: April 29, 2024, 09:41:03 AM »
Straight from the Wiki on negative energy damage:

"While undead are thought to be immune to negative energy since it is this energy that maintains their unnatural existence, they are only immune when the relevant script includes a race check. Spells generally have this check, so will heal undead instead of applying negative damage. Similarly for traps (starting in patch 1.69). Weapons do not have scripts, so a negative energy damage bonus will damage undead. Other sources of negative energy damage may vary as to whether or not they include a race check."

https://nwn.fandom.com/wiki/Negative_energy_damage



Burleigh Burrowell - RIP

Water

  • Lord of the Dead
  • Society of the Erudite
  • Dark Power
  • ******
  • Posts: 1083
  • The Bereaved & Defunct.
Re: Fixing negative damage sometimes damages undead
« Reply #27 on: April 29, 2024, 12:07:35 PM »
I think we should add positive energy healing on hit against living targets.

Wyldhunt

  • Outlander
  • **
  • Posts: 54
Re: Fixing negative damage sometimes damages undead
« Reply #28 on: April 29, 2024, 01:31:46 PM »
Straight from the Wiki on negative energy damage:

"While undead are thought to be immune to negative energy since it is this energy that maintains their unnatural existence, they are only immune when the relevant script includes a race check. Spells generally have this check, so will heal undead instead of applying negative damage. Similarly for traps (starting in patch 1.69). Weapons do not have scripts, so a negative energy damage bonus will damage undead. Other sources of negative energy damage may vary as to whether or not they include a race check."

https://nwn.fandom.com/wiki/Negative_energy_damage
You just described the reason for this post. Thank you.
The damaging armor spells can only be applied or removed. There is no option to script the actual damage that they inflict in a per-hit fashion. So, a positive/negative damage shield will universally inflict that damage to everyone regardless of any desired exceptions. You can't say 'inflict negative damage, but heal undead'. It's always just negative damage. Because world builders can't make those exceptions properly, this code is provided to allow them to make the exception after the fact.
I don't know what code they already use or what exceptions they might want to make. That's up to them and they are obviously excellent coders. I offered a template script snippet to save them time. They can easily alter it to only check for negative damage from a character with a damaging shield spell if they want to keep the ability to use negative damage to damage undead.

Wyldhunt

  • Outlander
  • **
  • Posts: 54
Re: Fixing negative damage sometimes damages undead
« Reply #29 on: April 29, 2024, 02:01:25 PM »
I think we should add positive energy healing on hit against living targets.
My code allows the devs to control damage that is hardcoded. It is up to them to use it as they see fit in Ravenloft. It's a code snippet. It's designed to be modified to meet their needs.

But, this post isn't really about discussing positive/negative damage in a general sense. It's about offering the devs the option to control damage from a hardcoded source that they otherwise can't control because they specifically mentioned that it worked the way it does due to hardcoded limitations.

Revenant

  • Noot Noot
  • Dark Lord
  • *****
  • Posts: 917
  • Stealth/Detection Cognoscenti
Re: Fixing negative damage sometimes damages undead
« Reply #30 on: April 29, 2024, 05:09:53 PM »
Here's RAW from the Monster Manual glossary about Undead Type:

Quote from: D&D 3.5e Monster Manual 1, pg. 317
—Cannot heal damage on its own if it has no Intelligence score, although it can be healed. Negative energy (such as an inflict spell) can heal undead creatures. The fast healing special quality works regardless of the creature’s Intelligence score.

3e spells were quite explicit about their effects. While it's most commonly written on each spell that deals Negative damage that it heals undead, that's not an inherent feature of Negative damage. We can hazard a guess that Rules As Intended is that Negative energy always heals Undead, no matter the form, but RAW says that it "can" heal Undead. Not "does."

As mentioned, Positive energy works the same way. Disrupt Undead is the easy example - wizards can't heal people by shooting them with a beam of positive energy, not even in PnP.

edit: beyond any rules/spirit of play arguments though (dropping meat in a fire vs slow-cooking it, etc), I'm not even going to touch adding more complexity to every instance of an Undead being hit. 
« Last Edit: April 29, 2024, 05:11:50 PM by Revenant »
Vicerimus Mortem.

Wyldhunt

  • Outlander
  • **
  • Posts: 54
Re: Fixing negative damage sometimes damages undead
« Reply #31 on: April 30, 2024, 03:36:49 PM »
I'm not even going to touch adding more complexity to every instance of an Undead being hit.
I'm skipping most of your post because I'm trying to focus on the code and implementation. The choices of when, or under what circumstances, it runs is entirely up to the world builders, and I really have no dog in that fight. So, I don't disagree. It's just not something I have an opinion on.

This last line, however, is very much about the code, and a very important consideration.
OnDamaged runs every time a creature takes damage. A character fighting an enemy of a proper CR for his level typically won't land every attack. However, high level melee classes will still land multiple damaging blows per round. On a server that regularly reaches 100 active players and a huge number of dungeons, Keeping OnDamaged lightweight becomes critical.
OnDeath typically runs once in each creatures (un)life, and tends to be a heavier script since it runs so rarely. It already handles all of the spawning/despawning of corpses/lootbags, treasure drop calculations, etc. Most of the points I'll make for my OnDamaged code remain true of my OnDeath code. Given that and the fact that my code cancels the rest of the script when it runs (Didn't die), I'm going to stick to just the OnHit.
So, I'm going to give my analysis on the performance hit of the code given some possible usage cases.

If they were to paste in the code as it stands now (Affects all forms of negative damage)(Extremely unlikely)
When a creature takes damage, it checks to see if they are undead (They might already have this check running. If so, this is free.). Checking the state of a true/false boolean is one of the fastest things the engine can do. Typical AI scripts can run hundreds of this kind of check on every creature on the server every round. If this returns false (Not undead), then it's safe to say that the snippet will have effectively no effect on performance.
Next, we check for the amount of negative damage inflicted. This is also a very fast check, as it's just retrieving variables. In the background, however, it has to retrieve the value for each damage type of the attack that just hit us, and then add all the negative sources together. I would estimate that this check is roughly equivalent to running the GetRacialType check about 15 times. So, its effect isn't 0. However, it's still quite fast. As long as the damaged returned is 0, the impact on the server probably wouldn't be noticeable. This is where the developers would add their own checks if they wanted to limit the script to only affect certain sources of damage.
Only if we made it this far, then we run the more expensive code. The main body of the code has to construct an effect and apply it. While not the slowest operation, it does take a  measurable amount of time. Most AI scripts try to limit using this more than 3 or 4 times in a single round. Most spells use this multiple times in their code. Fireball has to apply the visual effect and the damage effect to every creature in its radius at the same time, for instance. So, it can be used safely as long as it's not abused. This code uses a single effect, so it should be safe as long as there isn't an unusually large number of undead taking negative damage at the same time. If (Server wide) a total of 20 negative damage causing  events happened to undead every round for several rounds, you would likely be able to see a barely noticeable lag from my code. While I believe 20 fairly specific damaging events of this type in a single round, repeatedly, are going to be very rare, I won't say that it couldn't happen.

If, however, they alter my snippet to check for people causing damage with a negative energy shield, as per my suggestion, then you would need undead successfully damaging someone with an active damaging shield 20 times per round for a few rounds straight to see any effect. While characters might make the mistake of casting Death armor before an undead fight once, I doubt such shields would be a common practice in undead dungeons. I am confident that there would never be any noticeable effect if the devs decide to only use my code snippet to make specific changes to the specific effects that they might want to control.
I can't imagine them actually wanting to reverse every unscripted source of Negative Damage. It would change the balance of the entire server. So, I stand behind my code as essentially lag free.

EO

  • Assistant Head DM/Developer
  • Head DMs
  • Dark Power
  • ******
  • Posts: 23579
  • The one and only, the one everyone wants to be!
Re: Fixing negative damage sometimes damages undead
« Reply #32 on: May 01, 2024, 12:58:44 PM »
The code itself has issues, it would basically make it impossible to kill an undead as long as negative damage is dealt to it; it can probably be adjusted to account for other sources of damage but that adds overhead.

All that being said, as Revenant posted, nowhere does it say in the rules that negative energy heals undead. It's circumstantial, much like positive energy. A living creature will die on the positive energy plane after some time.

Wyldhunt

  • Outlander
  • **
  • Posts: 54
Re: Fixing negative damage sometimes damages undead
« Reply #33 on: May 01, 2024, 04:57:52 PM »
If and when to use it is up to you, of course. I would just like to point out that it's a code snippet. It's designed to be modified to meet your needs.
If you do want to change the hardcoded damage for the death armor spells specifically, you could just use
Code: [Select]
if (iNegDamage > 0 && GetHasSpellEffect(SPELL_DEATH_ARMOR, GetLastDamager()))Adding one check for a spell effect when an undead is damaged or dies from neg damage would not have any appreciable effect on lag.

That being said, I'll take this as a no and consider this issue resolved.
« Last Edit: May 01, 2024, 05:12:51 PM by Wyldhunt »