Kaedrin's Stuff and Companions

That is awesome! I will use that and find out. The Tome of Battle scripted combat system is very similar to what we have in the PRC for NWN1. Problem is, overcoming DR is not even considered by the ToB system. Right now I have it ignoring DR, but that isn’t a good solution.

In our PRC scripted combat system we loop all the IPs (almost all DR are item props on the hide in NWN1) and check for relevant spell effects, and if the weapon should be able to overcome the DR, we pump up physical EffectDamage by an amount adequate to cancel out the DR and let the rest through.

When I look in the NWN2 toolset though, DR appears to be some independent thing (as you indicate, not an IP and not an effect) that exists on the creature. Not to mention it has the extra integer for type now for 3.5 rules. And passing a damage power through EffectDamage still appears to be bugged as it was in NWN1 and it won’t overcome DR.

1 Like

hides are bugged in nwn2 /lol

they shouldn’t be equipped on PCs/Companions … because if the weapon/shield is swapped in/out multiple times the ACP (iirc) goes totally wonky. But they’re fine on NPCs/mobs who don’t do much if any weapon switching

(ill try to find the thread about it)

re. DR
the 2nd value changed from what the DR protects against to what pierces the DR … (unless im totally wonk on that)

probably ;) u really have to test things in nwn2, my advice is to take next to nothing for granted

I’ve never played around with the damagepower parameter. But a trick to get physical damage (not sure if you know this) is to sum the physical type bits →


that is, don’t use

int DAMAGE_TYPE_ALL = 0; // AFW-OEI 06/07/2007: Deprecated. May function correctly for EffectDamage(); results are undefined for EffectDamageImmunity() and EffectDamageResistance().

May function correctly … wtf

1 Like

The 4th integer is now what type of DR it is. So material, damage type, magical, epic, etc. The 2nd integer is still what pierces it, this is the same at NWN1, but it will look at a different set of values depending on what the 4th integer is. So if 4th param says material, 2nd param could be the value for a specific material, if 4th is magical, 2nd will work just like NWN1/3.0 rules.

At least that is what the entry in nwscript for NWN2 indicates. My own testing hasn’t been able to confirm that. Or even if you can grab DRs as effects and use GetEffectInteger on them.

For combining the damage types, can you actually pass that to EffectDamage as you wrote it with all those pipes in there?

yes it’s a legal bitwise operation

iDamageType = 1 + 2 + 4;
iDamageType = 7;

So u could just use 7 but the constants make it explicit

It fixed an issue i was having with EffectDamageIncrease() and have seen it mentioned in notes of the stock scripts, so that’s what i go with …

// since DAMAGE_TYPE_ALL does not work in EffectDamageIncrease()
// try this ->

Wow that is handy. I add all three physical types, grab the type of the weapon, then do EffectDamage in that type. That is much more efficient.

1 Like

Maybe …

Or …

Bottom line: Skins/Hides for PCs do not work.


yes. and I believe there may be one more thread where i reproduced the bug :)

1 Like


I read your comments related to skill increases effects leaving icons you didn’t want shown:

Thankfully, many of the ideas I had that involved using a skin can now be coded using new functions allowing us to directly alter attributes. One aspect that did still need consideration, however, was if a new feat altered a PC’s skills in some way. The problem is that while it is possible to alter PCs skills directly, the same process leaves small icons showing the changes as spell effects, which is not wanted.

I was able to remove the icons with the following code, you just need to find the icon number for skill increase:

        eSpellResistance = EffectSpellResistanceIncrease(maxItemSpellResistance);
        eSpellResistance = SupernaturalEffect(eSpellResistance);
        eSpellResistance = SetEffectSpellId(eSpellResistance, HENCH_SPELL_RESISTANCE_SPELL_ID);
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSpellResistance, oTarget);
        // get rid of icon
		effect eIcon = EffectEffectIcon(41);	// spell resistance increase
		ApplyEffectToObject(DURATION_TYPE_INSTANT, eIcon, oTarget);
		RemoveEffect(oTarget, eIcon);

1 Like


what if the character has a SpellResistanceIncrease effect (eg) already, for which the icon should show to the player? Wouldn’t that code (potentially) remove a legit icon ?

1 Like

@kevL_s ,

It appears that it removes the last effect icon effect created and leaves others in place. I think the icon shown on the screen shows only one effect icon per type. I have not noticed it failing in the AI routine added to work around the spell resistance bug. I also experimented with other effect types in unreleased code and that seemed to work.

1 Like


(*) See edit below.

Yes, a few years later, I think I finally grasped this as a way of resolving that issue too, as I have a number of places where I now also use the SetEffectSpellId and EffectEffectIcon combination with good effect. Although, I have not yet replaced the “Skill Book” system with such yet, as that serves me in other ways. However, it has certainly helped me in a number of other system setups where certain conditions need more flexibility. E.g. AI on and off, lycanthropy, etc. As an example …

	effect eLYC = EffectEffectIcon(143); 
    eLYC = SetEffectSpellId(eLYC, SPELLID_LYCANTHROPY);  		
	eLYC = EffectLinkEffects(eLYC, SupernaturalEffect(EffectPolymorph(iFORM, TRUE)));

And removed using similar function calls as you mention here.

This was one of those moments of discovery that helped out a great deal. I’m not sure when I learned of it, but it was somewhere between that post of 2010 and a few years back now. :wink: It’s good to mention that again here though, as I had forgotten about it. I have used this method in around a dozen places now, and it seems pretty solid.

Like you say, it appears to me to be a fairly robust way of us being able to build an effect that is “boxed” into its own identity which we can then add or remove reasonably easily.

At least, I assume this is what you mean … :slight_smile:

(*) Edit: Actually, I just realized you were highlighting the removal of the icon here, so now I see what you meant. :+1: Good to know!

P.S. Every time I need to build a new one, I have to keep reminding myself how it is done. I.e. Edit the effecticons.2da etc. But once understood, it does add a great benefit for us as builders.

@kevL_s I thought this may have been something you helped me with once? I’ll see if I can find the original post where someone helped explain it to me. I mean I don’t recall it being something I figured myself. :thinking:

Yes, I think it was here you helped me … Scroll down a few posts.

I have not found this one yet, but I do recall you doing that.

1 Like

ok sounds good enough :)

i hope to try it out on some custom penalties i have …


Very interesting … your code wiped out an icon-of-type if its effect was applied as DURATION_TYPE_PERMANENT but not if it was applied as DURATION_TYPE_TEMPORARY …!

(console) code to apply the initial penalty →

// 'applyreflexdecr'
void main()
	object oTarget = GetPlayerCurrentTarget(OBJECT_SELF);
	if (GetIsObjectValid(oTarget) && GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
		effect eReflexDecrease = EffectSavingThrowDecrease(SAVING_THROW_REFLEX, 3);
//			   eReflexDecrease = SupernaturalEffect(eReflexDecrease);
//			   eReflexDecrease = SetEffectSpellId(eReflexDecrease, -999);

//		ApplyEffectToObject(DURATION_TYPE_PERMANENT, eReflexDecrease, oTarget); // don't work
		ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eReflexDecrease, oTarget, 30.f); // works
	else SendMessageToPC(GetFirstPC(FALSE), "applyreflexdecr : <c=red>Target a creature</c>");

and the code run on Equip/Unequip (after a 0.0 delay) →

		effect eReflexDecrease = EffectSavingThrowDecrease(SAVING_THROW_REFLEX, iAcp);
		eReflexDecrease = SupernaturalEffect(eReflexDecrease);
		eReflexDecrease = SetEffectSpellId(eReflexDecrease, SPELLID_REFLEX_PENALTY);

		ApplyEffectToObject(DURATION_TYPE_PERMANENT, eReflexDecrease, oPC);

		// Tony - get rid of icon
		effect eIcon = EffectEffectIcon(40); // SAVING_THROW_DECREASE
		ApplyEffectToObject(DURATION_TYPE_INSTANT, eIcon, oPC);
		RemoveEffect(oPC, eIcon);


1 Like


I suppose the icon removal is more useful for permanent effects anyway. For if the effect is only temporary, then the icon plays its part for the effect duration.

It’s good to know we can remove the icon on newly appointed permanent effects, as that effectively offers a new means to add “combined” permanent effects if I understand you correctly. Or does this only work if removing a single icon type at a time only? (See example where both an attribute and a skill boost icon may be present.)

So … just so I’m clear here, if it is only the icon that is removed by this method, and the effect otherwise left intact, is it still now possible to remove the new effect, or would the only way to remove it be to reverse the effect using a negative application?

E.g. We have a permanent “boon” effect we call “Lucky” that gives +1 to charisma and +1 to appraise. We apply the new “permanent” benefit and use this method to remove any icons.

Now can we still remove “Lucky” as its own single named group effect, or do we have to apply a new permanent negative effect with its own icon removal?

(Not at main computer.)

PS Are your “works” comments the right way around, as it sounds contradictory to your post?


EDIT: As you say … Pretty cool! I did a quick test with Spell Resistance, and casting the same spell between a permanent effect this method, and the icon did behave as desired. :slight_smile: I.e. It appeared when the scroll was cast and remained when applying the additional permanent award, and disappeared when its time was up, leaving the appropriate permanent 2 points I had selected. :+1: (I’m going to try with a couple of other scenarios with multiple icons.)

“don’t work” means … using Tony’s code to keep a pre-existing icon when an effect-for-which-you-don’t-want-to-apply-an-icon is applied doesn’t work, if the pre-existing icon’s effect is PERMANENT – the pre-existing icon got removed.
“works” means … a pre-existing icon remains visible as desired when an effect-for-which-you-don’t-want-to-apply-an-icon is applied, if the pre-existing icon’s effect is TEMPORARY.

/hope that made sense ;)

1 Like

I am trying to get my head around what you have written here and will answer in a bit … :grin: :thinking:

OK …

My brain is really slowing up lately :grimacing: … so let me try clearing my understanding this way …

What situation is there where an icon is present for a permanent effect? (This, I suppose, my main question.)

Because, I thought we wanted no icons for “permanent effects”, or what I would call “permanent adjustments”? At least, that was my understanding.

Or, let me try explaining my logic this way …

I thought by “worked” you meant the icon was not shown for a permanent effect (which is also what I understood as “working”). So when you say …

… That sounds like you also pointed out how it “worked” when applied permanently. But in your comments in the script, where you say …

… it is the other way around.

I’m just going to look into a mirror now, to see if that helps me reverse my logical understanding. :wink:

EDIT: Here is my working example, which I just tested again, which I believe may help explain …

    1. Used a lever to add a “permanent” +2 spell resistance to a PC, and used “no icon” code to ensure the permanent effect did not add an icon. “No icon: Worked.”
    1. Used Spell Resistance scroll on same PC and their SR increased and an icon (for the temporary spell duration) applied as expected. “Icon: Worked.”
    1. I passed time, and the icon went at spell end, and the SR dropped to the 2 permanent points without any icon present. “No icon: Worked.”

@Lance_Botelle ,

This idea works for removing multiple icons. I found the code that I worked on over a decade ago for multiple summons to rework how incorporeal effects are applied. I did various tests at the time dumping out all effects before and after and the effects were retained without the icons.

		effect eConceal = EffectConcealment(50, MISS_CHANCE_TYPE_NORMAL);
		effect eGhost = EffectCutsceneGhost();
		effect eImmuneToNonMagicWeapons = EffectDamageReduction(1000, DAMAGE_POWER_PLUS_ONE, 0, DR_TYPE_MAGICBONUS);
		eConceal = EffectLinkEffects(eConceal, eGhost);
		eConceal = EffectLinkEffects(eConceal, eImmuneToNonMagicWeapons);
		eConceal = ExtraordinaryEffect(eConceal);
		int nDeflection = GetAbilityModifier(ABILITY_CHARISMA);
		if (nDeflection < 1)
			nDeflection = 1;
		effect eDeflectionBonus = EffectACIncrease(nDeflection, AC_DEFLECTION_BONUS);
		eDeflectionBonus = ExtraordinaryEffect(eDeflectionBonus);
		ApplyEffectToObject(DURATION_TYPE_PERMANENT, eDeflectionBonus, OBJECT_SELF);
		// get rid of icons	
		effect eIcons = EffectEffectIcon(3);	// immunity
		eIcons = EffectLinkEffects(EffectEffectIcon(108), eIcons);	// concealment
		eIcons = EffectLinkEffects(EffectEffectIcon(35), eIcons);	// AC	
		RemoveEffect(OBJECT_SELF , eIcons);

This year I started to rework this code to fix incorporeal creatures in their spawn script - fixing lack of move silently skill, defection bonus instead of natural AC, and the icons not showing. I might add it as an optional thing to download as part of the AI.



That’s good to know! :+1:

So basically, we can just link the effect icons and remove them as a a set of linked icons in a similar manner.

I just did some testing of my own, and I was pleasantly surprised to find that this does still appear to work even when a temporary version is applied after a combined permanent, even without using SetEffectSpellId.

Neat! :slight_smile:

I tested setup of the initial permanent effect with …

effect eDeflectionBonus = EffectACIncrease(3, AC_DEFLECTION_BONUS);
		effect eSpellResistance = EffectSpellResistanceIncrease(2);
		eSpellResistance = EffectLinkEffects(eDeflectionBonus, eSpellResistance);
        eSpellResistance = SupernaturalEffect(eSpellResistance);
        //eSpellResistance = SetEffectSpellId(eSpellResistance, 1001);
        ApplyEffectToObject(DURATION_TYPE_PERMANENT, eSpellResistance, oPlayer);
        // get rid of icon
		effect eIcon = EffectEffectIcon(41);	// spell resistance increase
		eIcon = EffectLinkEffects(EffectEffectIcon(35), eIcon);	// AC Deflection	
		ApplyEffectToObject(DURATION_TYPE_INSTANT, eIcon, oPlayer);
		RemoveEffect(oPlayer, eIcon);

And then tested to see if this setup could be broken/exploited with this …

effect eDeflectionBonus = EffectACIncrease(1, AC_DEFLECTION_BONUS);
		eDeflectionBonus = ExtraordinaryEffect(eDeflectionBonus);
		ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDeflectionBonus, oPlayer, 3.0);

After the temporary effect was applied, it had its icon present for 3 secs, and then disappeared leaving the permanent effect in place without icons.

I also just tested with a temporary of 4 AC increase, and it applied the extra 1 for the 3 seconds and then dropped back to the permanent 3 without icon.

well, you see, i applied a permanent effect, for which I wanted to keep an icon visible. Then I applied another permanent effect (of the same type), for which I did not want to keep a visible icon. But unfortunately when the second effect was applied it wiped not only its own icon but the one I wanted to keep.

If, however, the first effect was applied as temporary, then applying the second effect indeed kept the original icon as desired.

Ah, so that is how I first understood it … I just removed an edit how I thought you may have otherwise meant it. :slight_smile:

So what situation do you have where you need a permanent icon for a permanent effect?

I.e. I thought icons would only want to be shown for temporary effects anyway?

none offhand. But it’s conceivable that an effect might be applied as permanent, but only be designed to be temporary. Such as if a builder applied a certain effect (as permanent) on entering an area, but for it to be removed on exiting that area. You might want the icon to stay visible (and not risk being removed) while in that area …