Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Script help needed: spawning npcs

Page: 2 of 2
 tk102
12-02-2004, 8:01 AM
#51
ExecuteScript cross-references to this (http://www.lucasforums.com/showthread.php?s=&threadid=137370) thread.
 Xavier2
12-02-2004, 8:49 AM
#52
Originally posted by Darth333
I sent you an identical script the other day to spawn a door that uses the Execute Script function with detailed instructions. Have a look at it ;)
Dear Darth333

You are too kind and friendly, but...Have pit on me.:D Right now my head is so fuelled with scripts, area, dialog, skins, models... I don't think my brain can handle much more :D. Here is the script you sent me:
void main()
{
//again we get the variable we want to check
int nResult = GetGlobalNumber("RECRUIT_ABC");

// and now we check for plot advancement and make sure XYZ spawns only once:
if ((nResult == 2) && (!GetIsObjectValid(GetObjectByTag("XYZ"))))

{
// the coordinates where you want XYZ to spawn:
float x=248.54f;
float y=191.10f;
float z=0.27f;
float r=0.0f;
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);

//spawn XYZ
object oNPC=CreateObject(OBJECT_TYPE_CREATURE,"XYZ",locNPC);

I got the picture, kind of, but my real doubt is where to attach the script. The area where i want to spawn him is a NEW_AREA, so there isn't, at least there i know of, a default OnEnter script (like k_ptat17ab_enter.nss for Tattoine docking bay).

I understand how the script will spawn the npc. I understand the plot advancement detection. What i do not understand is where should i attach it. So the npc gets spawned when the NEW_AREA loads.
 RedHawke
12-02-2004, 5:49 PM
#53
Originally posted by Xavier2
What i do not understand is where should i attach it. So the npc gets spawned when the NEW_AREA loads.
Originally posted by Xavier2
hmmm...The OnEnter already has the Default script from the AREA which NEW_AREA is based on. Would it corrupt something?:confused:
Try your script in the OnEnter field instead of the default script and see if it works, worse comes to worse, you can add an execute script function line on your script to fire the default script after yours.

I don't see how it could corrupt anything...

:D
 Darth333
12-02-2004, 6:05 PM
#54
Take the OnEnter script of your area, rename it to blabla.ncs. Then paste this in notepad (change the tags as appropriate) and save it with the name of your old OnEnter script and compile:


void main()
{
int nPlot = GetGlobalNumber("MY_PLOT");
object oEnter = GetEnteringObject();

if (GetIsPC(oEnter))
{
if (nPlot == 4)
{
// this line checks if your custom npcs are already there:
if(!GetIsObjectValid(GetObjectByTag("my_npc")))
// do a whereami cheat to get the coordinates where you want to spawn
// the npcs and replace the 0.00 by those coordinates:
CreateObject(OBJECT_TYPE_CREATURE, "my_npc_tag", Location(Vector(00.00, 00.00, 0.00), 0.0));
}
}
// This fires the original OnEnter script that we renamed
ExecuteScript("blabla", GetModule());
}
 Xavier2
12-02-2004, 6:11 PM
#55
Originally posted by Darth333
Take the OnEnter script of your area, rename it to blabla.ncs. Then paste this in notepad (change the tags as appropriate) and save it with the name of your old OnEnter script and compile:
Sometimes the answer is just in front of you...And i used this sort of solution before...:p Thanks;)
 Darth333
12-02-2004, 6:15 PM
#56
check my post above, I did some cleaning but what you have should work.
 Xavier2
12-02-2004, 7:19 PM
#57
Originally posted by Darth333
check my post above, I did some cleaning nut what you have should work.
IT WORKS!!!:bounce1: A Hail to the queen:queen of scripts! May thy kingdom last forever.
Page: 2 of 2