The two scripts below are intended to enable a PC to polymorph into a Dog, Rat or Raven and spy on Hostile npcs whose faction is temporarily rendered friendly to this PC.
This is achieved by the use of a "reference creature" of the hostile faction placed in a DM-only area.
I have created a custom skin which is applied to the polymorphed PC via polymorph.2da (as suggested by Barag), and the OnUnacquire Item script I have written now resets the hostile faction back to hating the PC on either the cancellation of the polymorph or on the end of the spell's duration thanks to GhostOfGod).
However, although the test enemy NPC turns hostile as soon as the spell expires, it DOES NOT attack the PC.
It merely stands there for as long as I care to watch, as if oblivious to the fact that an enemy has appeared in front of it!
BUT, if the PC goes out of visual range and then returns, the test NPC attacks immediately.
Hmmm....
How then, folks, can I jump-start the now-hostile NPC into attacking the PC when he transforms back?
Can something be added to the OnUnacquire to do this, because I don't want to alter all my custom creature event scripts!
I'd be very grateful for any sage advice offered.....
The Spell Script:
//::///////////////////////////////////////////////
//:: Lesser Shapechange
//:: pt_polyself1.nss
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
The PC is able to change their form to one of
the following: Dog, Brown Rat or Raven.
The effect lasts for 10 minutes or until
cancelled or negated.
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Jan 21, 2002
//:://////////////////////////////////////////////
#include "x2_inc_spellhook"
void main()
{
/*
Spellcast Hook Code
Added 2003-06-23 by GeorgZ
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
int nSpell = GetSpellId();
object oTarget = GetSpellTargetObject();
effect eVis = EffectVisualEffect(VFX_IMP_POLYMORPH);
effect ePoly;
int nPoly;
int nDuration = 10;
//Determine Polymorph subradial type
if(nSpell == 1933)
{
nPoly = 98;
}
else if (nSpell == 1934)
{
nPoly = 99;
}
else if (nSpell == 1935)
{
nPoly = 100;
}
ePoly = EffectPolymorph(nPoly);
//Fire cast spell at event for the specified target
SignalEvent(oTarget, EventSpellCastAt(OBJECT_SELF, 1931, FALSE));
//Apply the VFX impact and effects
AssignCommand(oTarget, ClearAllActions()); // prevents an exploit
ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oTarget);
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, ePoly, oTarget, TurnsToSeconds(nDuration));
AdjustReputation(oTarget,GetObjectByTag("factionplaceholderhostile"),100);
}
And now the OnUnacquire script:
#include "habd_include"
void main()
{
// Support for Lesser Shapechange Spell & Item
object oLost = GetModuleItemLost();
if (GetTag(oLost)== "pt_it_emptyskin")
{
object oTarget = GetModuleItemLostBy();
AdjustReputation(oTarget,GetObjectByTag("factionplaceholderhostile"),-100);
}
// HABD support
if (HABDOnUnAcquiredItem(GetModuleItemLostBy(), GetModuleItemLost()))
{
return;
}
}
My thanks for any input, folks.