Record of bug on nwn wiki as far back as 2008, though the bug presumably existed in 2005:
- http://nwn.wikia.com/wiki/Magic_vestment
Basically, this script fixes the default functionality of Magic Vestment, which was never corrected by Bioware / Beamdog, and makes it so casting Magic Vestment on a person carrying a shield targets the shield first, so that a person doesn't have to put down their shield on the ground to receive magic vestment on their Shield.
If the person does not have a shield, the spell will then target their worn armor.
This has been tested as is by myself -- but the script may or may not require Arelith Specific alterations. There's a modification in this script (presented in its original format from the vault)-- of the spell being changed to 1 per 4 levels. Do not copy-pasta, obviously... the only part of the script that I feel should be relevant though is the targeting script-- which is the bugged part in NWN Vanilla code.
I do not take credit for this code contribution, as it came from nwvault.com and was added sometime last year:
- https://neverwintervault.org/project/nw ... nt-upgrade
The relevant part is the:
Code: Select all
// custom target selection script
object GetTargetArmor(int nAmount)
{
object oTarget = GetSpellTargetObject();
if (GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
return oTarget;
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST);
object oShield = GetItemInSlot(INVENTORY_SLOT_LEFTHAND);
if (!GetIsObjectValid(oShield))
return oArmor;
switch (GetBaseItemType(oShield))
{
case BASE_ITEM_LARGESHIELD :
case BASE_ITEM_SMALLSHIELD :
case BASE_ITEM_TOWERSHIELD :
return oShield;
break;
}
return oArmor;
}
Code: Select all
//::///////////////////////////////////////////////
//:: Magic Vestment
//:: X2_S0_MagcVest
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Grants a +1 AC bonus to armor touched per 4 caster
levels (maximum of +5).
Allows enchanting armor and shield, similar to enchanting
weapons where the player must equip them one at a time.
Cast on a creature with a shield equipped enchants the
shield, without a shield equipped enchants the armor.
*/
//:://////////////////////////////////////////////
//:: Created By: Andrew Nobbs
//:: Created On: Nov 28, 2002
//:://////////////////////////////////////////////
//:: Updated by Andrew Nobbs May 09, 2003
//:: 2003-07-29: Rewritten, Georg Zoeller
// Updated (JLR - OEI) 07/12/05 NWN2 3.5
// Edited by Eric M to allow enchanting equipped shields.
#include "nw_i0_spells"
#include "x2_i0_spells"
#include "x2_inc_spellhook"
// custom target selection script
object GetTargetArmor(int nAmount)
{
object oTarget = GetSpellTargetObject();
if (GetObjectType(oTarget) != OBJECT_TYPE_CREATURE)
return oTarget;
object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST);
object oShield = GetItemInSlot(INVENTORY_SLOT_LEFTHAND);
if (!GetIsObjectValid(oShield))
return oArmor;
switch (GetBaseItemType(oShield))
{
case BASE_ITEM_LARGESHIELD :
case BASE_ITEM_SMALLSHIELD :
case BASE_ITEM_TOWERSHIELD :
return oShield;
break;
}
return oArmor;
}
void AddACBonusToArmor(object oMyArmor, float fDuration, int nAmount)
{
IPSafeAddItemProperty(oMyArmor,ItemPropertyACBonus(nAmount), fDuration, X2_IP_ADDPROP_POLICY_REPLACE_EXISTING ,FALSE,TRUE);
return;
}
void main()
{
/*
Spellcast Hook Code
Added 2003-07-07 by Georg Zoeller
If you want to make changes to all spells,
check x2_inc_spellhook.nss to find out more
*/
if (!X2PreSpellCastCode())
{
// If code within the PreSpellCastHook (i.e. UMD) reports FALSE, do not run this spell
return;
}
// End of Spell Cast Hook
//Declare major variables
//effect eVis = EffectVisualEffect(VFX_IMP_GLOBE_USE);
effect eDur = EffectVisualEffect( VFX_DUR_SPELL_MAGIC_VESTMENT );
int nDuration = GetCasterLevel(OBJECT_SELF);
int nMetaMagic = GetMetaMagicFeat();
int nAmount = GetCasterLevel(OBJECT_SELF)/4; // JLR - OEI 07/12/05 NWN2 3.5
if (nAmount <0)
{
nAmount =1;
}
else if (nAmount>5)
{
nAmount =5;
}
object oMyArmor = GetTargetArmor(nAmount); // edited to use the new target function
if (nMetaMagic == METAMAGIC_EXTEND)
{
nDuration = nDuration * 2; //Duration is +100%
}
if(GetIsObjectValid(oMyArmor) )
{
SignalEvent(GetItemPossessor(oMyArmor ), EventSpellCastAt(OBJECT_SELF, GetSpellId(), FALSE));
if (nDuration>0)
{
location lLoc = GetLocation(GetSpellTargetObject());
//DelayCommand(1.3f, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, GetItemPossessor(oMyArmor)));
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eDur, GetItemPossessor(oMyArmor), HoursToSeconds(nDuration));
AddACBonusToArmor(oMyArmor, HoursToSeconds(nDuration),nAmount);
}
return;
}
else
{
FloatingTextStrRefOnCreature(83826, OBJECT_SELF);
return;
}
}
Edits: Formatting/phrasing/grammar/spell-checking