Author Topic: Making an NPC look like the PC  (Read 450 times)

Legacy_UnrealJedi

  • Full Member
  • ***
  • Posts: 226
  • Karma: +0/-0
Making an NPC look like the PC
« on: October 10, 2011, 09:19:41 pm »


               Hey all,

Remember in HoTU the room in Undermountain that had two rows of mirrors and there were different effects if you broke them? One of them created an exact duplicate of the PC who then attacked. Does anyone know how the scripting for that effect? I'd like to try and implement into my own module.

Thanks!
               
               

               
            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Making an NPC look like the PC
« Reply #1 on: October 10, 2011, 09:50:15 pm »


               

#include "nw_i0_generic"

// lf_copypc
// This makes a duplicate of a PC that uses the Mirror of Opposition
// Put in OnUsed of Placable Mirror

void main()
 {
 object oPC = GetLastUsedBy();
 object oSpot=GetWaypointByTag("WP_Copy");
 location lSpot=GetLocation(oSpot);
 string copytag="copy1";
 if (GetLocalInt(oPC,"OPPOSITION") == 1)
   {
   FloatingTextStringOnCreature("The Mirror appears foggy...",oPC);
   return;
   }
   else
   {
   if (GetIsPC(oPC)==TRUE)
     {
     SetLocalInt(oPC,"OPPOSITION",1);
     FloatingTextStringOnCreature("You gaze into the Mirror and see Yourself...",oPC);
     ApplyEffectAtLocation (DURATION_TYPE_INSTANT, EffectVisualEffect (VFX_FNF_SUMMON_UNDEAD), lSpot);
     object oCopy = CopyObject(oPC, lSpot,OBJECT_INVALID,copytag);
     AssignCommand(oCopy , SetIsDestroyable(FALSE));
     object oOrb = GetObjectByTag( "MirrorofOpposition");
     SetLocalObject(oOrb, "TAG", oCopy);
     AdjustReputation(oPC, oCopy, -100);
     SetIsTemporaryEnemy(oPC, oCopy);
     DelayCommand(2.0,AssignCommand(oCopy,ActionAttack(oPC)));
     AssignCommand(oCopy, DetermineCombatRound(oPC));
     }
   }
 }


OnHeartbeat:

// lf_copypchb
// Meant to run with lf_copypc. This
kicks off the default NWN
// script for a cloned PC so he casts spells, uses
items, etc..
// goes OnHeartbeat of Mirror of Opposition

void main()
  {
  object
oTHING = GetLocalObject( OBJECT_SELF, "TAG");

  if (oTHING != OBJECT_INVALID)
    {
      if
(GetIsDead( oTHING) == TRUE) DeleteLocalObject( OBJECT_SELF, "TAG");

    else

    {


      ExecuteScript( "nw_c2_default3", oTHING);
    }
  }
}


FP!
               
               

               


                     Modifié par Fester Pot, 10 octobre 2011 - 08:52 .
                     
                  


            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Making an NPC look like the PC
« Reply #2 on: October 14, 2011, 02:26:02 pm »


               I actually do this in a boss battle in my PW.

What I do, is when the boss gets to 50% hp, he summons Duplicates of the Attackers Party,
Applies the shadow armor visual to them, to make them look like shadows.

In order to make them as smart as any other npc, you need to give them the script sets that the other npc's have.
I noted that when they are summoned, they just stand there, even if they show up as hostile.

So, what I did, was impliment a 'for statement' (loop), to loop through all the Bosses event scripts, and take note of them, and use nwnx funcs to set the copies event scripts to be the same.

This results in the copies, having the correct AI Scripts.
I think when you use CopyObject on a PC, it copies it, and puts 'default' into all the event scripts.
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Making an NPC look like the PC
« Reply #3 on: October 14, 2011, 03:30:46 pm »


               I believe the "fix" for copying PCs, if you can't use the nwnx method baaleos suggested, was to copy the PC, then dominate them, then copy them again.  That would result in them having the henchman scriptset.