Aller au contenu

Photo

EffectDamageResistance problem


  • Veuillez vous connecter pour répondre
71 réponses à ce sujet

#1
Loki_999

Loki_999
  • Members
  • 430 messages

Working on a range of feats for new races that give damage resistance. They are auto-activated feats (persistent/active).

 

I set up 3 targets, each one with one of the feats DR 5/Slashing, DR5/Bludgeoning and DR5/Piercing. I dropped 3 weapons in my test module, one of each type of damage and went and attacked the targets.

 

In almost every test it reported Damage resistance absorbs 0 points of damage.  Once or twice it reported reducing the damage but then couldn't get it to duplicate - that happened after i went in as DM, possessed the creature and activated the feat manually... but i feel that may be a red herring.

 

I thought i spotted the problem in that i had iType and iSpecific backwards in my EffectDamageResistance function - but tried changing them around and same results occurred. I've not tested the other types yet either so not sure if they are working.

 

So, before i break my head against this and get into more in-depth debugging, let me ask: anyone got any experience with this function, especially with using physical damage types?  Spot anything that i'm doing stupid?

/* Feat created by Agony_Aunt/Loki_999 for SCoD PW
adds DR effect to target */


//#include "nw_i0_spells"
#include "x2_inc_spellhook"

const int FEAT_DR_CI10 = 2290;
const int FEAT_DR_EVIL10 = 2291;
const int FEAT_DR_MAGIC10 = 2292;
const int FEAT_DR_MAGIC15 = 2293;
const int FEAT_DR_BLUDG15 = 2294;
const int FEAT_DR_LAW15 = 2295;
const int FEAT_DR_AS5 = 2296;
const int FEAT_DR_AS10 = 2297;
const int FEAT_DR_BLUDG5 = 2298;
const int FEAT_DR_SLASH5 = 2299;
const int FEAT_DR_PIERCE5 = 2321;


void main()
{
	//SpeakString("Firing Aura");
    if (!X2PreSpellCastCode())
    {
	// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
        return;
    }

    object oTarget = GetSpellTargetObject();

    if (!GetHasSpellEffect(GetSpellId(), oTarget))
	{
		int iFeat = GetSpellFeatId();
		int iAmount;
		int iType;
		int iSpecific;
		
		switch(iFeat)
		{
			case FEAT_DR_CI10: iAmount=10; iType=DR_TYPE_GMATERIAL; iSpecific = GMATERIAL_METAL_COLD_IRON; break;
			case FEAT_DR_EVIL10: iAmount=10; iType=DR_TYPE_ALIGNMENT; iSpecific = ALIGNMENT_EVIL; break;
			case FEAT_DR_MAGIC10: iAmount=10; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_MAGICAL; break;
			case FEAT_DR_MAGIC15: iAmount=15; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_MAGICAL; break; // check this to be used and not IP_CONST
			case FEAT_DR_BLUDG15: iAmount=15; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_ALL; break; // bug in definitions, ALL = BLUDGEONING and vice versa
			case FEAT_DR_LAW15: iAmount=15; iType=DR_TYPE_ALIGNMENT; iSpecific = ALIGNMENT_LAWFUL; break;
			case FEAT_DR_AS5: iAmount=5; iType=DR_TYPE_GMATERIAL; iSpecific = GMATERIAL_METAL_ALCHEMICAL_SILVER; break;
			case FEAT_DR_AS10: iAmount=10; iType=DR_TYPE_GMATERIAL; iSpecific = GMATERIAL_METAL_ALCHEMICAL_SILVER; break;
			case FEAT_DR_BLUDG5: iAmount=5; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_ALL; break; // bug in definitions, ALL = BLUDGEONING and vice versa
			case FEAT_DR_SLASH5: iAmount=5; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_SLASHING; break; 
			case FEAT_DR_PIERCE5: iAmount=5; iType=DR_TYPE_DMGTYPE; iSpecific = DAMAGE_TYPE_PIERCING; break; 
		}
		
		effect eRes = EffectDamageReduction(iAmount, iSpecific, 0, iType);
		eRes = SupernaturalEffect(eRes);
		ApplyEffectToObject(DURATION_TYPE_PERMANENT, eRes, oTarget);
	}	
}


#2
kevL

kevL
  • Members
  • 4 061 messages

[edit] oh, you are using Reduction .. ignore all this ...

 

have you seen Damage Resistance ?

unfortunately the link there at the wiki, to a detailed discussion, is to the legacy-legacy forum ... But here's what i gather: NwN2 moved physical Damage Resistance to "Damage Reduction" (not sure what functions there are for that) and so leaves physical resistance deprecated.

from Broken Functions:

 

ItemPropertyDamageResistance
DAMAGE_TYPE_SLASHING/ PIERCING/BLUDGEONING Do not work (are ignored, UI chat logs indicates absorption, underlying HP values do not)

EffectDamageResistance
DAMAGE_TYPE_SLASHING/ PIERCING/BLUDGEONING Do not work (are ignored, UI chat logs indicates absorption, underlying HP values do not)


As you probly know, Reduction is implemented uniquely via character properties (ie. it's neither an effect nor an itemproperty :blink:). There also seems to be funny-stuff re. the DAMAGE_TYPE_* constants; you noted that _ALL and _BLUDGEONING are reversed, but they also seem to have this feature ( tho that may be for damages dealt only, it might be useful elsewhere )


i'd be interested in anything you find/test about this,



#3
kevL

kevL
  • Members
  • 4 061 messages

ps. Did you check if the weapons are really doing the damage_type advertised? there's also a mysterious Slashing&Piercing type that shows up occasionally



#4
Loki_999

Loki_999
  • Members
  • 430 messages

Thanks kevL

 

Yeah, i'd done quite a bit of reading on the topic. I also found as thread where someone said that you should use the IP_ damage type constants, but that doesn't fit with what most people were saying.

 

And yeah, weapons are definitely doing correct type of damage, just using basic weapons such as spear, club, and longsword.

 

Thanks for the responses. Guess ill have to do some more testing.  Will try out some of the non-physical DRs i've got set up first. See if they behave as expected.

 

I do have a backup plan, which is making creature hides and adding those to the races on creation, was trying to avoid that though.

 

Will let know results of further testing.



#5
kevL

kevL
  • Members
  • 4 061 messages

IP_CONST_DAMAGETYPE_*

... if you don't get it to work properly, see if it works improperly


might be worth a shot, wither now or later,

- perhaps i'll jump in later once i get some blast-propagation stuff worked out elsewhere, which could take a while .......



#6
Loki_999

Loki_999
  • Members
  • 430 messages

Just done a bit of testing. Script is working ok for Cold Iron resistance, so its definitely something with the physical types.

 

The IP const values don't make sense due to bitwise nature of the regular types for combining... however, it briefly worked with piercing correctly, which has a different value.

 

The crazy thing is... i've now had it briefly work with both bludgeoning and slashing... walked away, attacked again, and it stopped resisting.

 

Its almost like the property only applies sometimes, or until DR is overcome.  That could even be it.  Let's say DR5... you hit for 2 damage, it remains. You hit for 6 damage and the DR disappears.  Maybe i'm just going mad.

 

Will test this theory a bit later.



#7
kevL

kevL
  • Members
  • 4 061 messages

here's a script that might help out

It examines an effect on a creature (comprehensively, i think)

// 'testeffect'

//
void Tell(string sTell) { SendMessageToPC(GetFirstPC(FALSE), sTell); }

// ___________
// ** MAIN ***
void main(int iEffType)
{
    object oTest = GetPlayerCurrentTarget(OBJECT_SELF);
    if (!GetIsObjectValid(oTest)
        || GetObjectType(oTest) != OBJECT_TYPE_CREATURE)
    {
        oTest = OBJECT_SELF;
    }

    Tell("\nrun ( testeffect ) on " + GetName(oTest));

    effect eEffect = GetFirstEffect(oTest);
    while (GetIsEffectValid(eEffect))
    {
        if (GetEffectType(eEffect) == iEffType)
        {
            Tell(". Creator : "            + GetName(GetEffectCreator(eEffect)) + " ( "
                                            + GetTag(GetEffectCreator(eEffect)) + " )");
            Tell(". Type : "            + IntToString(GetEffectType(eEffect)));
            Tell(". Sub Type : "        + IntToString(GetEffectSubType(eEffect)));
            Tell(". Duration Type : "    + IntToString(GetEffectDurationType(eEffect)));
            Tell(". Spell ID : "        + IntToString(GetEffectSpellId(eEffect)));
            Tell(". Integer 0 : "        + IntToString(GetEffectInteger(eEffect, 0)));
            Tell(". Integer 1 : "        + IntToString(GetEffectInteger(eEffect, 1)));
            Tell(". Integer 2 : "        + IntToString(GetEffectInteger(eEffect, 2)));
            Tell(". Integer 3 : "        + IntToString(GetEffectInteger(eEffect, 3)));
            Tell(". Integer 4 : "        + IntToString(GetEffectInteger(eEffect, 4)));
            Tell(". Integer 5 : "        + IntToString(GetEffectInteger(eEffect, 5)));
            Tell(". Integer 6 : "        + IntToString(GetEffectInteger(eEffect, 6)));
            Tell(". Integer 7 : "        + IntToString(GetEffectInteger(eEffect, 7)) + "\n");
        }
        else
        {
            Tell(". found Other Effect : " + IntToString(GetEffectType(eEffect)) + "\n");
        }

        eEffect = GetNextEffect(oTest);
    }
}


just right-click on your MOB, then run

rs testeffect(7)

( 7 == EFFECT_TYPE_DAMAGE_REDUCTION )

#8
Loki_999

Loki_999
  • Members
  • 430 messages

Great work kevL.  Your script helped me spot an issue i had in spells.2da with two of my feats referencing the wrong feats, which is why one sometimes appeared to work depending on what state my script was in.

 

And i can confirm, for EffectDamageResistance to work with physical types, you have to use the IP_CONST values!

 

Ill be updating the wiki momentarily to confirm this.

 

Its also why people thought DAMAGE_TYPE_ALL was actually DAMAGE_TYPE_BLUDGEONING - because DAMAGE_TYPE_ALL = 0 and IP_CONST_DAMAGETYPE_BLUDGEONING = 0.

 

Everything now works as expected! Cheers for the help.



#9
Loki_999

Loki_999
  • Members
  • 430 messages

Hells bells, Obsidian really dropped the ball on this one.

 

Did further testing with multiple types of physical DR and a range of weapon types including the morningstar which does both Piercing and Bludgeoning.

 

How they screwed this up so badly i have no idea as it lacks consistency.

 

If you add two types of physical DR to the same creature (eg: Slashing and Bludgeoning) it will block piercing, but either a slashing or bludgeoning weapon will bypass the DR.  So far so good, its acting like OR base DR... although this indicates no option to make AND based DR (unless that works with mixed types, which will be my next test: eg material type and weapon type).

 

If you have two types and attack with a weapon that does both types - in my test morningstar attacking creature with bludgeoning and piercing - then damage gets resisted! In other words, at least one is activating... and i say perhaps it may only be one because of what came next.

 

I had two targets both with just one type of DR. One had piercing, one had bludgeoning.  I then attacked both with the morningstar.

 

The one with piercing damage resisted and *drum roll* the one with bludgeoning didnt!

 

I wonder if weapons with mixed types have a primary damage type...

 

Next test will be with halberd to see if that has similar problems as the morningstar and also with cold iron weapons and stacking of DR.... report soon. 



#10
kevL

kevL
  • Members
  • 4 061 messages

is this Damage Resistance you're talking about, or Damage Reduction?

 

you mention EffectDamageResistance 2 posts up, while "DR" I take to mean Damage Reduction ...

 

 

other than keeping that clear, yeah keep goin! ( will need time to ingest things.. )



#11
Loki_999

Loki_999
  • Members
  • 430 messages

Hmm, something not quite right with my earlier test, so will double check that.

 

However, combining Material with Physical types of DR results in an AND situation.  So Cold Iron and Slashing means both have to be overcome.

 

More soon...



#12
Loki_999

Loki_999
  • Members
  • 430 messages

hehe, yeah, i keep getting the words wrong.

 

Just to be clear is the one that is not used for elements and is not written like Fire 5/-

 

The effect being used is EffectDamageReduction



#13
kevL

kevL
  • Members
  • 4 061 messages

cool.

 

& just as i'm narrowing down on blast propagations i get a CTD,  <_<

 

 

So if Im reading right, you're using EffectDamageReduction() with the IP_CONST _* definitions ??? for all tests ?



#14
Loki_999

Loki_999
  • Members
  • 430 messages

Ok, just had a wierd result... longsword bypassed piercing DR ... but that appeared to be working fine before.

 

Oh boy.  Going to have to continue testing, maybe later, but maybe something wrong with my effect pierce DR value.



#15
Loki_999

Loki_999
  • Members
  • 430 messages

Yeah, it should be working.

 

Got a series of tests lined up, but RL interruption.



#16
Loki_999

Loki_999
  • Members
  • 430 messages
Methodical testing time... different weapons (types) vs different combinations of DR.
 
Weapon(Type) | DR Type | Bypass Y/N
Longsword (S) | BSP | N
Longsword (S) | B | N
Longsword (S) | S | Y
Longsword (S) | P | Y
Longsword (S) | BP | N
Longsword (S) | BS | N
Longsword (S) | SP | Y
Club (B) | BSP | N 
Club (B) | B | Y
Club (B) | S | N
Club (B) | P | N
Club (B) | BP | N
Club (B) | BS | N
Club (B) | SP | N
Spear (B) | BSP | N 
Spear (S) | B | N
Spear (S) | S | N
Spear (S) | P | Y
Spear (S) | BP | N
Spear (S) | BS | N
Spear (S) | SP | N
Halberd (PS) | BSP | N 
Halberd (PS) | B | N
Halberd (PS) | S | Y
Halberd (PS) | P | Y
Halberd (PS) | BP | N
Halberd (PS) | BS | N
Halberd (PS) | SP | Y
Morningstar (BP) | BSP | N
Morningstar (BP) | B | Y
Morningstar (BP) | S | N
Morningstar (BP) | P | N
Morningstar (BP) | BP | N
Morningstar (BP) | BS | N
Morningstar (PS) | SP | N
 
Analysis summary: DR type Piercing is faulty as Slashing bypasses it. It also does not get bypassed by Morningstar which is Piercing & Bludgeoning
 
This could make sense as I expect Bugsidian's QA team may not have tested it, since in the campaign's i can't think of a creature with DR/Piercing.  Skellies have DR/Bludgeoning and Zombies DR/Slashing so faults in those would have been spotted.
 
Final test - itemproperty on hide with DR/piercing.


#17
Loki_999

Loki_999
  • Members
  • 430 messages

Gah! No edit button on these forums?



#18
Loki_999

Loki_999
  • Members
  • 430 messages

Oh yeah, and combined types normally require both types of DR to bypass which again shows Piercing is borked when the longsword could bypass Piercing and slashing.

 

Fairly sure i've got the right values now as spear worked correctly with piercing DR.



#19
kevL

kevL
  • Members
  • 4 061 messages
[ remove Table, superceded below ]
bizarre ...

#20
Loki_999

Loki_999
  • Members
  • 430 messages

Confirmed, setting DR/Piercing on the creature itself (can't be set on creature hide item as you can only set untyped DR/- on hides) exhibits the same behaviour.

 

It also means that morningstars behave more or less like Bludgeoning weapons for purposes of bypassing DR.  Halberds and Scythes are cool though as they bypass two types.



#21
Loki_999

Loki_999
  • Members
  • 430 messages

Hehe, thanks for the edit kevL... you missed that i screwed up the spear type.

Weapon      (Type)  | DR Type   | Bypass Y/N
--------------------------------------------
Longsword   (S)     | BSP       | N
Longsword   (S)     | B         | N
Longsword   (S)     | S         | Y
Longsword   (S)     | P         | Y
Longsword   (S)     | BP        | N
Longsword   (S)     | BS        | N
Longsword   (S)     | SP        | Y

Club        (B)     | BSP       | N 
Club        (B)     | B         | Y
Club        (B)     | S         | N
Club        (B)     | P         | N
Club        (B)     | BP        | N
Club        (B)     | BS        | N
Club        (B)     | SP        | N

Spear       (P)     | BSP       | N 
Spear       (P)     | B         | N
Spear       (P)     | S         | N
Spear       (P)     | P         | Y
Spear       (P)     | BP        | N
Spear       (P)     | BS        | N
Spear       (P)     | SP        | N

Halberd     (PS)    | BSP       | N 
Halberd     (PS)    | B         | N
Halberd     (PS)    | S         | Y
Halberd     (PS)    | P         | Y
Halberd     (PS)    | BP        | N
Halberd     (PS)    | BS        | N
Halberd     (PS)    | SP        | Y

Morningstar (BP)    | BSP       | N
Morningstar (BP)    | B         | Y
Morningstar (BP)    | S         | N
Morningstar (BP)    | P         | N
Morningstar (BP)    | BP        | N
Morningstar (BP)    | BS        | N
Morningstar (PS)    | SP        | N

And fixed.

 

I've edited the wiki page as well. I'll just add a reference to this thread as well.



#22
4760

4760
  • Members
  • 1 207 messages

Gah! No edit button on these forums?

Yes, but it's not immediate. You have to wait a bit, and refresh...



#23
Loki_999

Loki_999
  • Members
  • 430 messages

Yes, but it's not immediate. You have to wait a bit, and refresh...

 

Yeah, spotted it later... annoying.



#24
Psionic-Entity

Psionic-Entity
  • Members
  • 195 messages

Confirmed, setting DR/Piercing on the creature itself (can't be set on creature hide item as you can only set untyped DR/- on hides) exhibits the same behaviour.

 

It also means that morningstars behave more or less like Bludgeoning weapons for purposes of bypassing DR.  Halberds and Scythes are cool though as they bypass two types.

 

If I remember correctly the morningstar just deals bludgeoning damage, but I may be wrong.

 

The way I originally tested it was using EffectDamageImmunity, which appears to work for physical damage types (but not DAMAGE_TYPE_ALL). With sufficiently high damage bonuses and divergent immunities you can check that Obsidian actually made slashing/piercing weapons pick the lowest damage immunity and (I think) that morningstars and other weapons set to bludgeoning and piercing don't work.



#25
kevL

kevL
  • Members
  • 4 061 messages

the more i look at that Table the more i like it, akzooly.

It seems Slashing weapons are really Piercing & Slashing,
and Bludgeoning & Piercing weapons are really Bludgeoning


as PE points out, there's still the curiosity of DAMAGE_TYPE_ALL/ DamageImmunity, and whether or not ie. how the trick i noted in BrokenFunctions ( combining consts for two Types to result at a weapon's inherent Type ) relates .....

/ but coffee CTD