Author Sticky: Post Working Scripts Here
Samhaine Posted: Thursday, 27 June 01:28AM
Sivak-Draconian OnDeath Script

A script designed to be put on any NPC that you want to transform into a duplicate of its killer. It will leave a corpse of an exact copy of an NPC killer, or a similar copy of any PC (you'll have to make a number of NPCs that resemble possible PCs for complete versimilitude). I tested it with one PC and an NPC and both seemed to work correctly.

Now, to work on the transforming into downed foes script.

NWScript:
//Sivak Draconian OnDeath Script

//by samhaine@tekh.org

void KillAndReplace(object oMark);

void main ()

{

                                        //Gets the creature that killed the Sivak

                                        //and its Name/Template, Racial Type, and if it's a PC

                                        //also records the current position of the Sivak

object oKiller = (GetLastKiller());

string sKiller = (GetStringLeft(GetName(oKiller), 5));

int nKillerRace = (GetRacialType(oKiller));

int nKillerGender = (GetGender(oKiller));

location lLocation = (GetLocation(OBJECT_SELF));

int nIsPc = GetIsPC(oKiller);

                                         //Finds out if the killer was a PC and then

                                         //goes through a list of PCs that have an exact

                                         //Doppelganger created in the toolset, and creates the

                                         //corpse of that Doppelganger at the Sivak's location.

                                         //If it's an unexpected PC then the Doppelganger

                                         //is chosen from a Male or Female generic Doppelganger.

                                         //It should be simple to make more generic Doppelgangers

                                         //for various Race/Classes and then plug in the code,

                                         //at expense of making it even longer.

     if (nIsPc)

     {

          if (sKiller == "Tanis")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakTanis", lLocation, FALSE));}

          if (sKiller == "Sturm")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakSturm", lLocation, FALSE));}

          if (sKiller == "Raist")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakRaistlin", lLocation, FALSE));}

          if (sKiller == "Caram")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakCaramon", lLocation, FALSE));}

          if (sKiller == "Flint")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakFlint", lLocation, FALSE));}

          if (sKiller == "Tassl")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakTasslehoff", lLocation, FALSE));}

          if (sKiller == "River")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakRiverwind", lLocation, FALSE));}

          if (sKiller == "Goldm")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakGoldmoon", lLocation, FALSE));}

          if (sKiller == "Twili")

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakTwilight", lLocation, FALSE));}

          if (nKillerGender == GENDER_FEMALE)

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakFemaleGeneric", lLocation, FALSE));}

          else

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, "SivakMaleGeneric", lLocation, FALSE));}

      }

                                          //At this point the code has decided that the killer was

                                          //not a PC, and will therefore simply create a duplicate

                                          //of the killer from the toolset palatte and create its corpse.

                                          //It will only do this if the race is a humanoid so that the

                                          //Sivak can reasonably doppelgang it.

                                          //If the killer was not a PC and also not a reasonable choice for

                                          //creating a copy, then the creature dies normally.



       else

       {

          if (nKillerRace == RACIAL_TYPE_DWARF || RACIAL_TYPE_ELF || RACIAL_TYPE_FEY || RACIAL_TYPE_GNOME || RACIAL_TYPE_HALFELF || RACIAL_TYPE_HALFLING || RACIAL_TYPE_HALFORC || RACIAL_TYPE_HUMAN || RACIAL_TYPE_HUMANOID_GOBLINOID || RACIAL_TYPE_HUMANOID_MONSTROUS || RACIAL_TYPE_HUMANOID_ORC || RACIAL_TYPE_HUMANOID_REPTILIAN)

               {KillAndReplace(CreateObject(OBJECT_TYPE_CREATURE, GetTag(oKiller), lLocation, FALSE));}

          else SpeakString("Urk!", TALKVOLUME_TALK);

       }

}

                                           //And here is the KillAndReplace function that it's pulling

                                           //(copied from the Versus World Builder's Guide).

void KillAndReplace(object oMark)

{

     if(GetIsObjectValid(oMark))

     {

          SetPlotFlag(oMark,FALSE);

          AssignCommand(oMark, SetIsDestroyable(FALSE,FALSE));

          AssignCommand(OBJECT_SELF,

                                     ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDeath(), oMark));

     }

}



_________________
~Samhaine
All things are defined by names. Change the name, and you change the thing. Of course there is a lot more to it than that, but paracosmically that is what it boils down to... -Pratchett, Pyramids