It's there a way to absorb a DAMAGE_TYPE_* and convert it into heal?

I’m trying to make it so that when you are hit by negative damage, you get healed instead of damaged, as if you were an undead.

I was thinking on the “On Damaged Script” and Trolls as an example but i don’t know how to control or access that through scripting.

I don’t think so. At least not in the OnDamaged script; because there’s no way to convert effects after they’ve been constructed, or bypass effects after they’ve been applied. Undead heal/harm is handled well before it gets to the OnDamaged script: basically a spellscript (eg. CureLightWounds or InflictLightWounds) will check if its effect is going to be applied to an undead creature and it constructs an appropriate opposite-effect there.

So i imagine that what you’re suggesting would sorta need to do the same thing. That is, in any script that a negative damage effect is going to be constructed and applied, do EffectHeal() instead.

Here, paste this in the “On Damaged” and give it a try:

void main()
int iAmount = GetDamageDealtByType(DAMAGE_TYPE_NEGATIVE);
if (iAmount <= 0) return;
	else ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(iAmount), OBJECT_SELF, 0.0f);

@Vermillion nope

creature still takes neg damage, possibly killing it

good try tho  ;)

1 Like

Hmmm. Thats true…

Ok, thanks. I noticed that i misinterpreted the ability that i’m trying to create now that you mentioned the heal/harm scripts from the healing/cure wounds spells. It was very late when i was doing this abilities(the player gets some lich’s powers temporarily).

The ability reads as follow:
Undead Healing: Negative energy (such as that of an inflict spell) heals you rather than damaging you. If you are a living creature, positive energy (such as a cure spell) still heals you as well.

I just need to edit those script.


This is very promising. Also works with weapons that have Negative Energy damage. I left the debug code for those that wish to check my work.

// ondamaged_neg 
	Place this on the creature's OnDamaged event.
	Set the creature to immortal TRUE.

void main()
	object oCreature = OBJECT_SELF;
	int nHP = GetCurrentHitPoints();
	int nTotalDMG = GetTotalDamageDealt();
	int nNeg = GetDamageDealtByType(nDTN) < 0 ? 0 :GetDamageDealtByType(nDTN);
	int nHeal = nNeg * 2;
//	object oPC = GetFirstPC();	
//	SendMessageToPC(oPC, "TotalDamage: " + IntToString(nTotalDMG));
//	SendMessageToPC(oPC, "CurrentHP: " + IntToString(nHP));
//	SendMessageToPC(oPC, "NegativeDMG: " + IntToString(nNeg));
	// Kill the creature if its HP is 1 and non-DAMAGE_TYPE_NEGATIVE is more than what could be healed. 		
	if (nHP == 1 && nTotalDMG - nHeal > 0)
		SetImmortal(oCreature, FALSE);
		ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oCreature);
	// Heal the creature if it takes DAMAGE_TYPE_NEGATIVE.
	if (nNeg)
		ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(nHeal), oCreature);
		AssignCommand(oCreature, SpeakString("Negative Energy damage healed this creature!"));	
//		SendMessageToPC(oPC, "Healed: " + IntToString(nHeal));
//	SendMessageToPC(oPC, "NewHP: " + IntToString(GetCurrentHitPoints()));		
	ExecuteScript("nw_c2_default6", oCreature);