Author Topic: Custom Polymorph & Adjust Reputation - a final snag....  (Read 236 times)

Legacy_Monsieur T

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« on: October 14, 2010, 03:12:40 pm »


               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.
Unfortunately, although I have created a custom skin which is applied to the polymorphed PC via polymorph.2da (as suggested by Barag), the OnUnacquire Item script I have written does NOT reset the hostile faction back to hating the PC on either the cancellation of the polymorph or on the end of the spell's duration.
    I would be very grateful if someone could tell me if I have done something wrong!

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"),0);
      }
   // HABD support
   if (HABDOnUnAcquiredItem(GetModuleItemLostBy(), GetModuleItemLost()))
      {
      return;
      }
}

My thanks for any input, folks.
               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #1 on: October 14, 2010, 03:58:00 pm »


               Check to make sure that the hide even exists when the UnAcquire script fires.  I'm fairly sure that's where your problem lies.  Since the hide no longer exists when the UnAcquire event fires you cannot get the tag.



Another option is to adjust the reputation in the spell script back it its original number delayed by nDuration.  This doesn't help if they UnPoly early but it's an option. There's a lot of things you could do from perception (not recommended) events to pseudo-heartbeats so the route you choose is up to you but ultimately the UnAcquire script won't work as you want it to.
               
               

               
            

Legacy_Monsieur T

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #2 on: October 16, 2010, 04:12:12 pm »


               Thank you for that, Dagesh.

I actually had the pc EQUIP the skin via polymorph.2da as an experiment, and it did show up in the inventory, but on vanishing the faction setting still remained the same. Sigh...you are right.

I'm not sure about how to adjust the rep back via a delay on the spell-script - any pointers would be gratefully received.....

Thanks again.
               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #3 on: October 17, 2010, 01:55:00 am »


               You could add this in your spell script:



DelayCommand( TurnsToSeconds(nDuration), AdjustReputation(oTarget,GetObjectByTag("factionplaceholderhostile"),0) );



Adding that would not take effect until the delay was finished so if someone "unpolymorphed" early it would not change the factions until that point.



You could also kick off a psuedo-heartbeat script that checked to see if they were polymorphed and if not, then reset the reputation.  That requires a custom function.  If you don't know how to make one I'd be happy to show you how.  The problem with this option is it uses more CPU because it's firing every X seconds.  It may not be a big deal since I am sure not every PC will be running around with this effect on and it would only be checking to see if the PC has a spell effect (the way I would write it, that is).  Again, this is only another of multiple options.
               
               

               
            

Legacy_Monsieur T

  • Jr. Member
  • **
  • Posts: 62
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #4 on: October 20, 2010, 02:19:06 am »


               Thanks again Dagesh!

I cleaned out my custom OnUnacquired script, and added your line to the bottom of my spell script.

Sadly, on expiration of the spell, the bad guys still seemed to like the PC!

I would very much like to try out your pseudo-heartbeat idea but have no idea how to go about it., so would be grateful indeed for your continued advice.

I really appreciate you giving this issue your time and trouble.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #5 on: October 20, 2010, 03:42:02 am »


               Monsieur, you said that upon the unacquire of the custom skin the pc does not revert to having hostility towards the critters? Does the hostility get set to hostile properly upon acquiring the custom skin? If so mayhap you could add in a bit to the onacquire to check upon reacquiring the default skin. Have a check for hostility against your reference critter upon acquiring the default skin, if not hostile reset to default hostility. Maybe that would work.
               
               

               


                     Modifié par Baragg, 20 octobre 2010 - 02:42 .
                     
                  


            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #6 on: October 21, 2010, 01:53:33 pm »


               We did it on the OnPerciption call of the monster itself. It works a lot easier that way just fyi.



I will post the script when I get back but using the monsters onpercep allows for a better and quicker call except in cases of huge mobs.(Which cause problems anyhow.)
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom Polymorph & Adjust Reputation - a final snag....
« Reply #7 on: October 21, 2010, 05:17:40 pm »


               If you were still curious as to why your OnUnacquire didn't work...it is probably because you did not adjust the reputation at all but left it at 0. So this line:

AdjustReputation(oTarget,GetObjectByTag("factionplaceholderhostile"),0);

Should be like:

AdjustReputation(oTarget,GetObjectByTag("factionplaceholderhostile"),-100);

Pretty sure that was the only thing wrong.