Jump to content

Home

Scripts for NPC action. TSL


darthriddick

Recommended Posts

EDIT: i swear no one looks at the (need help) threads anymore... whatever happened to common decency?

(sorry i'm just grumpy.)

EDIT#2: STOFFE RULES!!! ^_^

 

Hi, i'm working on a small storyline mod, and i am having some trouble with a certain NPC spawning, and then exiting, and destroying itself.

anyway, i need a script that can do this:

 

Check to see if item blahblah is the PC's inventory.

If it is in the inventory, spawn NPC.

If it is not, do nothing.

Once the PC has spoken with the NPC,

Remove item blahblah from inventory,

make NPC exit and destroy itself, and add an entry to the Journal.

 

any ideas?

 

~DR

Link to comment
Share on other sites

EDIT: i swear no one looks at the (need help) threads anymore... whatever happened to common decency?

(sorry i'm just grumpy.)

 

People do have lives outside answering questions on internet forums you know. Expecting a reply within a few hours may be overly optimistic. :) Informing people that they suck because they don't answer quickly enough won't exactly encourage people to take time to help you at all. Patience is a virtue. :)

 

 

Hi, i'm working on a small storyline mod, and i am having some trouble with a certain NPC spawning, and then exiting, and destroying itself.

anyway, i need a script that can do this:

 

Check to see if item blahblah is the PC's inventory.

If it is in the inventory, spawn NPC.

If it is not, do nothing.

Once the PC has spoken with the NPC,

Remove item blahblah from inventory,

make NPC exit and destroy itself, and add an entry to the Journal.

 

That sounds like two different scripts, one that does the NPC spawning, and one that runs from the end of that NPC's dialog file making them leave.

 

The spawn script:

object ST_Spawn(string sResRef, float x, float y, float fFace) {
   return  CreateObject(OBJECT_TYPE_CREATURE, sResRef, Location(Vector(x, y, 0.0), fFace));
}


void main() {
   object oPC = GetFirstPC();

   if (GetIsObjectValid( GetItemPossessedBy(oPC, "[color=Red]blahblah[/color]") ) && !GetLocalBoolean(OBJECT_SELF, 40)) {
       ST_Spawn("[color=Yellow]NpcToSpawn[/color]", [color=Plum]1.0, 2.0[/color], [color=Orange]90.0[/color]);
       SetLocalBoolean(OBJECT_SELF, 40, TRUE);
   }   
}

 

Change blahblah to the tag of the item to look for.

Change NpcToSpawn to the name of the UTC file with the NPCs template (without the .utc extension).

Change 1.0, 2.0 to the X, Y coordinates of where in the area to spawn the NPC.

Change 90.0 to the angle the NPC should be facing when spawned (0-360 degrees).

 

 

The exit script:

void ST_Exit(object oActor = OBJECT_SELF) {
   object oExit = GetWaypointByTag("SW_EXIT");

   AssignCommand(oActor, ActionForceMoveToObject(oExit));
   AssignCommand(oActor, ActionDoCommand(SetCommandable(TRUE)));
   AssignCommand(oActor, ActionDoCommand(DestroyObject(oActor)));
   AssignCommand(oActor, SetCommandable(FALSE) );
}

void main() {
   object oPC = GetFirstPC();

   DestroyObject( GetObjectByTag("[color=Red]blahblah[/color]") );
   AddJournalQuestEntry("[color=Yellow]JournalTag[/color]", [color=Plum]20[/color]);
   ST_Exit( GetObjectByTag("[color=Green]NpcTag[/color]") );
}

 

Change blahblah to the tag of the item to remove.

Change JournalTag to the tag/name of the journal entry to set.

Change 20 to the quest stage to set the journal entry to.

Change NpcTag to the tag of the NPC to leave the area.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...