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: 1 of 2
 Darth333
04-06-2004, 3:18 AM
#1
How could I spawn an npc at a specific location at a specific time and make that npc walk towards my pc and initiate conversation?

An example would be the mysterious guy that spawns between the hotel and the Republic Embassy on Manaan after your PC exits the hotel during Sunry's murder inquiry.

Another example: the twilek that spawns on Tatoine and asks for your autoprint when you are the swoop champion.
 tk102
04-06-2004, 6:53 AM
#2
Let's see, sounds like you want to set a Trigger (a .UTT file) at the location where the party will cause the NPC to spawn. In that UTT file, set the ScriptOnEnter field to point to the script that you will write. In that script, you'll probably want to use functions such as CreateObject (#243) to spawn your NPC, ActionMoveToObject (#22) to get your NPC to walk* and ActionStartConversation (#204) to initiate the dialog. (You can look up their syntax in nwscript.nss).

* You'll have to embed this one inside an AssignCommand (#6) function.

Is that enough to go on?
 Darth333
04-06-2004, 2:43 PM
#3
Thanks. That should help. I'll try to do it and if I can't I'll cry out for help :ball:
 Darth333
04-07-2004, 3:09 AM
#4
:ball: :ball: :ball: OK I tried but I'm lost! HELP! :ball: :ball: :ball:

I thought I would be able to do it with what you gave me TK but not yet. Would it be possible to see an example of such script - not only the syntax that is found in the nwscript.nss - to get started? (I'm not sure about how to fill in the blanks properly) See the problem is that a couple of weeks ago C++ sounded more like a brand of orange Juice to me than anything else (OK, I'm exagerating a little but not that much )

I've been playing with some scripts for my Dustil mod and it worked pretty well but I had similar examples in bifs so i was able to make the link with the other elements contained in the game and thus modify the scripts to get what I wanted. However, this this time it seems everything is already compiled (apart that nwscript).
 tk102
04-07-2004, 5:23 AM
#5
void main() {

// in your game, do a 'whereami' cheat to
// determine your location then plug in
// three values here
float x=14.19f;
float y=27.01f;
float z=-1.27f;

//orientation doesn't matter too much
float r=0.0f;

// the following two functions create
// the location for your NPC to spawn at
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);

//spawn! (in this case, a Republic solider from the Endar Spire)
object oNPC=CreateObject(OBJECT_TYPE_CREATURE,"n_repsold001",locNPC);

// now tell the NPC to talk to your PC
object oPC=GetFirstPC();
AssignCommand(oNPC,ActionMoveToObject(oPC));
AssignCommand(oNPC,ActionStartConversation(oPC,"my_dlg"));
}
I tested this at the very first scene on the Endar Spire and it worked alright.


Edit:
I decided to tweak it a bit and use end_trask01.dlg in the last line. After tweaking that .dlg a bit (removing a bund of Speaker: end_trask fields, the spawned republic soldier came up to me and started speaking Trask's lines with his voice and with lipsync. Screenshot (http://img4.imageshack.us/my.php?loc=img4&image=repsold2.jpg)
 Darth333
04-07-2004, 2:40 PM
#6
Oh great TK!

I was really wondering how this location thing worked. You answered all my questions (for now).

I don't know how to thank you enough!

Oh! I know...This is for you: http://magasin.iga.net/common/img/product/big/6672101565.jpg) :D
 Darth333
04-07-2004, 11:55 PM
#7
I tried the script and it works...well it spawns NPCs for sure. I tested the script with the Deadeye Duncan dlg file on Manaan and i spawned Duncan as you can see...

http://mars.walagata.com/w/darth333/deadeye.JPG) :laughing:

In fact 3 new Deadeye Duncan (one for each party member) appear at every step I make near the location where Duncan spawns. I now have an entire army of Deadeye Duncans (not sure such army would be very effective).

The dialog part works fine and I know how to make the script to them walk away. But I'd like to have only one Duncan spawning and only once. How do I do this?
 tk102
04-08-2004, 4:45 AM
#8
You'll need to set a flag somewhere. Then in your script, check at the very beginning whether that flag has been set. If not, then execute the rest of the script. Otherwise exit. Then, at the end of your script, set the flag.

Now, you have to figure out whether or not you plan on checking that flag elsewhere in the game. You might want to use it to trigger some other event. In that case, you'll need to set a Global variable using either SetGlobalBoolean or SetGlobalNumber functions. The downside to this is that you have to find an existing Global variable or you have to modify the globalcat.2da file to add a new one. Don't worry -- you should be able to reuse ones from the Endar Spire for example without much consequence. (Feel free to use my Global Variable Comparison tool to see how globals change throughout the game.)

If you don't want to use the flag again, but you just don't want an army of DeadEye Duncans, you can get away with setting a Local Boolean with the SetLocalBoolean function on the trigger object itself.

Here are examples of both ways:



// This method uses a Global Numeric value
void main() {

if (GetGlobalNumber("End_TraskTalk") == 333) { return; }

// insert thre rest of the script here...
// ...
// and then at the end add:
SetGlobalNumber("End_TraskTalk",333);
}



// This method uses a Local Boolean value
void main () {
object oTrigger = GetObjectByTag("your_trigger_objects_tag");

if (GetLocalBoolean(oTrigger,0) == TRUE) { return; }

// insert thre rest of the script here...
// ...
// and then at the end add:
SetLocalBoolean(oTrigger,0,TRUE);
}
 T7nowhere
04-08-2004, 5:53 AM
#9
Can the Local Boolean be used to have an npc say a eclusive line of dialog once and only once.

How is the flag stored is it attached to the npc or PC? :confused:
 tk102
04-08-2004, 6:24 AM
#10
You can use a local boolean that way if you like, T7. In that case, you would probably want to make the object the NPC who is speaking the dialog although the local variable could be any object you like I suppose.

To make the NPC say something once and only once, you would first write a script that goes something like:


int StartingConditional() {
if (GetLocalBoolean(OBJECT_SELF,0) == FALSE) { return TRUE; }

return FALSE;
}


Then in the appropriate EntriesList struct, you would reference your script in the Active field. That way, the script is fired in order to check whether or not the NPC says the Entry referenced in the Index field.

Then, in the Entry List where your one-time text is mentioned, you would set a reference to another script in the Script field. This script would go something like:

void main() {
SetLocalBoolean(OBJECT_SELF,0,TRUE);
}
In this way, the local flag is set once the dialog is spoken, so it won't be spoken again. Of course, you have to design your dialog tree so there's no other points of re-entry also.

The flag is stored in the NPC (courtesy of the OBJECT_SELF pre-defined variable).
 Darth_ToMeR
05-23-2004, 1:07 PM
#11
[QUOTE]Originally posted by tk102
[B]
void main() {

// in your game, do a 'whereami' cheat to
// determine your location then plug in
// three values here
float x=14.19f;
float y=27.01f;
float z=-1.27f;

//orientation doesn't matter too much
float r=0.0f;

// the following two functions create
// the location for your NPC to spawn at
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);

//spawn! (in this case, a Republic solider from the Endar Spire)
object oNPC=CreateObject(OBJECT_TYPE_CREATURE,"n_repsold001",locNPC);

// now tell the NPC to talk to your PC
object oPC=GetFirstPC();
AssignCommand(oNPC,ActionMoveToObject(oPC));
AssignCommand(oNPC,ActionStartConversation(oPC,"my_dlg"));
}

"vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);"

What do i need to write in in those rows?

Edit: Or if i don't need to to anything with those rows, where do i need to write the area module?
 tk102
05-23-2004, 2:27 PM
#12
"vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);"

What do i need to write in in those rows?


First go into the module where the spawning will occur. Walk to the position that you'd like to spawn the NPC. Do the cheat 'whereami' and write down the 3 coordinates. Put those into the lines:
float x=...
float y=...
float z=...

And you can play with the value of r to make the NPC face the direction you like.
 Darth_ToMeR
05-23-2004, 3:38 PM
#13
Originally posted by tk102
First go into the module where the spawning will occur. Walk to the position that you'd like to spawn the NPC. Do the cheat 'whereami' and write down the 3 coordinates. Put those into the lines:
float x=...
float y=...
float z=...

And you can play with the value of r to make the NPC face the direction you like. I did it and it didn't work. In the Lines i wrote, i don't need to write anything?
 Darth333
05-23-2004, 4:41 PM
#14
Originally posted by Darth_ToMeR
I did it and it didn't work. In the Lines i wrote, i don't need to write anything?

Is the utc file of the npc available in the module where you want to spawn it?
 tk102
05-23-2004, 5:36 PM
#15
Maybe you could post your code or send it to me or Darth333 for proofreading via PM.
 Mav
05-23-2004, 5:46 PM
#16
hey tk are you some kind of genius man?

If I ever want to learn how to script I'm coming to you.
 tk102
05-23-2004, 5:56 PM
#17
I'm a bigger geek than most, perhaps. But thanks for the compliment. Scripting isn't too bad once you get a crash course in C++. And that doesn't take too long either. :)
 Darth_ToMeR
05-24-2004, 12:26 PM
#18
Originally posted by Darth333
Is the utc file of the npc available in the module where you want to spawn it? To spawn someone i need to "replace" someone that exist in the game in the place i want to spwan him?
 Darth333
05-24-2004, 12:32 PM
#19
Originally posted by Darth_ToMeR
To spawn someone i need to "replace" someone that exist in the game in the place i want to spwan him?

No. You can simply add someone if you want. If the .utc of the npc you want to spawn is already in the module (example Deadeye Duncan on Manaan - http://www.pcgamemods.com/5410/) ) you can even attach the script to a dlg to fire the script.

If not, you'll need to edit the .git file to make the npc available.
 Darth_ToMeR
05-24-2004, 12:37 PM
#20
Originally posted by Darth333
No. You can simply add someone if you want. If the .utc of the npc you want to spawn is already in the module (example Deadeye Duncan on Manaan - http://www.pcgamemods.com/5410/) ) you can even attach the script to a dlg to fire the script.

If not, you'll need to edit the .git file to make the npc available. Sorry about my questions, but this is the first time i try modding. Can you tell me where are the .git files and what i suppose to do with them?
 Darth333
05-24-2004, 12:41 PM
#21
.git files are located in RIMs>modules>.rim>Dynamic Area Info

You can create a trigger or edit the creatures list. If you want, we can transfer this discussion via pm and post a summary when it's done.
 Darth_ToMeR
05-24-2004, 12:45 PM
#22
Originally posted by Darth333
.git files are located in RIMs>modules>.rim>Dynamic Area Info

You can create a trigger or edit the creatures list. If you want, we can transfer this discussion via pm and post a summary when it's done.
I think i understand it. I will send you PM if i'll have a problem. Thanks.
 Darth333
05-24-2004, 1:03 PM
#23
Ok, I'll be glad to help anytime. :)
 Doom_Dealer
06-14-2004, 10:31 AM
#24
OK all, i need some help.

Im trying to spawn an npc so that they come and talk to you (im testing it with holowspire). BUT ive come across a problem, the character doesnt talk to me when i use the local boolean code, but i still only want one to spawn.
i.e. When i do not use the localboolean code, there are multiple spawns, the one that just spawns does not speak to me, however when a new one spawns, the previous one that spawned comes and talks to me with the set dialogue (called dd_mono,) and after it is finsihed he reverts back to his orininal dialogue of (dd_doomdealer) when i speak to him
however, as i only want one of the character to spawn, i use a localboolean code, and the one spawn does not come and speak to me.

any help would be greatly appreciated :
heres what ive got at the moment (the single spawn one)


void main()
{
object oTrigger = GetObjectByTag("spawn1");
if (GetLocalBoolean(oTrigger,0) == TRUE) { return; }
float x=33.34;
float y=147.71;
float z=0.00;
float r=0.0f;
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);
object oNPC=GetObjectByTag("DoomDealer");
object oTarget=CreateObject(OBJECT_TYPE_CREATURE,"dd_doomdealer",locNPC);
object oPC=GetFirstPC();
AssignCommand(oNPC,ActionMoveToObject(oPC));
AssignCommand(oNPC,ActionStartConversation(oPC,"dd_mono"));
SetLocalBoolean(oTrigger,0,TRUE);
}
 Darth Khasei
06-14-2004, 7:05 PM
#25
Hey guys I would really appreciate some help with this one. All I want to do is be able to spawn custom made NPC's(1-3) to the same area as the main PC and have the NPC attack the PC. This is much like the Dark Jedi's that appear throughout the game from time to time.

My idea was to make a nice number of individual NPC's that the user can spawn to fight at anytime any place in the gameat will. It would work as a user called side quest as the NPC's would progess in level of difficulty and challenge for the player.

Yes there is KOTOR area and the Matrix mods, but those just don't serve this exact purpose that I wanted. "ANY" help would be welcomed. Thx.
 Darth Khasei
06-14-2004, 8:03 PM
#26
Well with just a little fiddling with the GREAT Replicator force power I was able to get enemy NPC's to spawn on command, YIPPIE.

Now I need to try to refine the positioning as they are way too close to the PC at the moment. Also they leave too soon. I'll keep working at it. Ideas are welcomed.
 Darth Khasei
06-15-2004, 12:46 AM
#27
Ok good after going through the NW script page I did not see a reference to a command that lets you spawn a NPC and then allows you to set the NPC at x location in reference to the PC.

So, the best I was able to come up with as a quick fix for me was to just delay the response time of the spawned enemy NPC's, which allows me to move away from them to a more realistic distance before the fight begins. It, works pretty well actually. I wonder what would happen if I spawn them on Manaan? I will have to test it. :D Oh no ANOTHER trial.

Well, at least I was able to get it working right. :D. Well, I am just in awe of the makers of the Kotor Arena and Survival/Matrix mods. I really wanted to make a full on K-1 style mod using several locations in the game. Obviously Kotor Arena,area but the Arena Area on the Unknown Planet as well as a couple of other good outdoor locations. Basically, you would fight a progressive list of other talented K-1 fighters until you make it to the championship. The levels of the fighters would go hand in hand with your progression skills in the game.

Maybe 30-50 unique fighters. I was thinking about the top ten Jedi/Sith to put in there for the end of the game levels. Who should be on that list? Any thoughts comments?
 Darth333
06-15-2004, 1:35 AM
#28
Here is a sample of what I use:
Doom Dealer, the script has to be attached somewhere. This scrip below was attached to the OnEnter filed of an .are file. You can also easily attached scripts to a conversation. I f the script is attached to a conversation bracnh that is not reapeated, you don't need to set a Global or a local bolean. That's what I did in for the Deadeye Duncan mod. For a full example with the source available, check svosh's Revan Redemption mod here: http://www.lucasforums.com/showthread.php?s=&threadid=129196)


void main () {
object oTrigger = GetObjectByTag("dustil");

if (GetLocalBoolean(oTrigger,0)) { return; }
float x=117.92f;
float y=108.27f;
float z=18.00f;
float r=0.0f;
vector vecNPC=Vector(x,y,z);
location locNPC=Location(vecNPC, r);
object oNPC=CreateObject(OBJECT_TYPE_CREATURE,"dustil",locNPC);
object oPC=GetFirstPC();
AssignCommand(oNPC,ActionMoveToObject(oPC));
AssignCommand(oNPC,ActionStartConversation(oPC,"new_dustil"));
SetLocalBoolean(oTrigger,0,TRUE);
}


The npc can be spawned at any location within the same module with this: there is no maximum of minimum distance. Just change the coordinates.

You can also use a trigger to spawn npcs (utt and .git file). It's also possible to make the npcs spawn at certain conditions only.
This is an example where the npc would spawn only after the 4th starmap has been discovered and after the Dustil plot reached a certain point.


void main()
{
int nStar = GetGlobalNumber("K_STAR_MAP");
int nResult = GetGlobalNumber("KOR_DANEL");
if ((nResult == 6) && (nStar==50))
{
rest of the script...
}
}

Hope this helps :)
 Darth Khasei
06-15-2004, 6:49 AM
#29
Good news. You can fight the Sith on Manaan with no trial penalty! Just spawn the enemy and killing them has no penalty. Heck any Shelkath around and they will join in on your side:D
 Maxstate
08-25-2004, 8:56 AM
#30
:D

In JA you could spawn any NPC with something like npc spawn (name), is that possible in kotor.

i'm using D333's spawn on demand armband a lot (even though everything under dark master jha'din doesn't work -- no problemo) cuz i like fighting when I want to fight:p

but i would like to spawn someone else too.


is that possible in-game?
 tk102
08-25-2004, 10:53 AM
#31
In JA you could spawn any NPC with something like npc spawn (name), is that possible in kotor. If it was that easy there wouldn't be a thread like this one. :)

but i would like to spawn someone else too.

is that possible in-game?
Of course -- via scripting -- that's what this is all about. :rolleyes:
 Darth333
08-25-2004, 10:54 AM
#32
Originally posted by Maxstate
:D
In JA you could spawn any NPC with something like npc spawn (name), is that possible in kotor.

Unfortunately, there is no way you can do this in Kotor: you have to plant a script somewhere.


i'm using D333's spawn on demand armband a lot (even though everything under dark master jha'din doesn't work -- no problemo) cuz i like fighting when I want to fight:p

Some of Darth Khasei's scripts would work only with a female PC. I corrected this problem in version 2.0.1 released during the weekend.

You can donwload it here: http://www.pcgamemods.com/6832)


but i would like to spawn someone else too.
is that possible in-game?

if it was possible for the armband, then it is...:D
The source code for the All-In-One FPM is here: http://www.lucasforums.com/showthread.php?s=&threadid=132116) (check 1st post)
 Xavier2
11-21-2004, 5:13 PM
#33
I am having a spawning problems:
1. I have succesfully spawned 2 npcs in Tatooine docking bay using this script by Darth333:
void main()
{
object oEnter = GetEnteringObject();
object oNPC1 = GetObjectByTag("tat17_NPC1");
object oNPC2 = GetObjectByTag("tat17_NPC2");
if (GetIsPC(oEnter))
{
// this line checks if your custom npcs are already there:
if ((GetIsObjectValid(oNPC1) == FALSE) && (GetIsObjectValid(oNPC2) == FALSE))
{
// 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, "tat17_NPC1", Location(Vector(-22.80, -4.40, 0.13), 0.90));
CreateObject(OBJECT_TYPE_CREATURE, "tat17_NPC2", Location(Vector(-21.00, -4.30, 0.13), 01.0));
}
}
// This fires the original script that we renamed
ExecuteScript("enter_dock", GetModule());
}
The problem is that the NPC2 dialog is not trggering. The NPC1 dialog, a civilian dialog (baloons) works ok. What am i missing?
 tk102
11-21-2004, 5:36 PM
#34
First of all, I love the code font you used. I'm doing that from now on.

Second, nowhere in the script do I see where dialog is forced to begin for NPC1 or 2... do you mean that when you go up to NPC2 to talk, he's not talking back?
 Xavier2
11-21-2004, 5:45 PM
#35
Originally posted by tk102
First of all, I love the code font you used. I'm doing that from now on.

Second, nowhere in the script do I see where dialog is forced to begin for NPC1 or 2... do you mean that when you go up to NPC2 to talk, he's not talking back?
Yep. The idea isn't to make the npc go to you but rather make him reply to your attempt to talk. NPC1 replies with civilian conversation but NPC2 that has a more complex dialog that fires global script doesn't.

And the font was just my way to save space...;)

The code is very neat. It makes perfect sense even for a modder with zero knowledge of programming like myself. As expected Darth333 is the clever mind behind that.:)
 tk102
11-21-2004, 6:41 PM
#36
Ah well then, the problem is with the dialog, the NPC's .utc, or the conditional scripts used by the dialog.
 Darkkender
11-22-2004, 5:55 AM
#37
If I was to guess I would say that you either don't have the dialogue that will be used typed right in the utc file, or the dialogue itself has some sorta of mixup in it's tree(i've had this happen), or if the dialogue is supposed to be triggered by the event of you walking in then you probably need to set a universal trigger.
 Xavier2
11-22-2004, 7:02 AM
#38
Originally posted by darkkender
If I was to guess I would say that you either don't have the dialogue that will be used typed right in the utc file, or the dialogue itself has some sorta of mixup in it's tree(i've had this happen), or if the dialogue is supposed to be triggered by the event of you walking in then you probably need to set a universal trigger.
The dialog uses the same name of the .utc minus the last letter. I checked that and it is set right in the npc. There isn't any script triggering it to start. The only scripts there are two "SetGlobal" ones, that fires at the end of certain dialog branches...Both .utc and .dlg are in Override...

I thought of one possibility. The .utc becomes a part of the area duo to the script above. Should i use the same techinique for the dialog? or should be enough just to place it's tag in the conversation field of the .utc file as it is now?
 Darth333
11-22-2004, 7:16 AM
#39
You don't need a script to get this working unless you want your npc to walk up to your PC and automatically start the dialogue (I did not put this in the script above but it can be added).

It is very likely a problem with the .dlg file. Check your starting list and your conditional scripts as tk102 mentionned above.
 Xavier2
11-23-2004, 5:18 PM
#40
Originally posted by Darth333
You don't need a script to get this working unless you want your npc to walk up to your PC and automatically start the dialogue (I did not put this in the script above but it can be added).

It is very likely a problem with the .dlg file. Check your starting list and your conditional scripts as tk102 mentionned above.
Just to give this subject some closure i thought i'd let you know the problem. It happens the dialog file was corrupted. I am happy to say it is working perfect now.:)
 Xavier2
11-29-2004, 8:07 PM
#41
Is there a script to spawn a certain npc in a new modded area, but only if he hasn't been killed in a previous one?
 Darth333
11-29-2004, 8:30 PM
#42
ok, I assume you now know how to track a plot with Global Variables.
The script would be something like this:

{
int nPlot = GetGlobalNumber("MY_PLOT");
if (nPlot == 1)

{

if(!GetIsObjectValid(GetObjectByTag("my_npc_tag")))
CreateObject(OBJECT_TYPE_CREATURE, "my_npc_tag", Location(Vector(00.00, 00.00, 0.00), 0.0));
}
}
 tk102
11-29-2004, 8:32 PM
#43
Is there a script to spawn a certain npc in a new modded area, but only if he hasn't been killed in a previous one?There is not a script per se, but this is exactly what Global Variables are used for. Many plot elements use numeric globals to keep track of where the PC is in the game... like Canderous' sidequest... Jagi spawns only if you haven't met him (and killed him) yet.

So you .utc could have an OnDeath user-defined event that could write to a global variable, and your .utt or .are could have a script that checks that variable, and spawns the NPC if he hasn't been killed.
 Xavier2
11-29-2004, 8:45 PM
#44
Originally posted by Darth333
ok, I assume you now know how to track a plot with Global Variables.
The script would be something like this:

{
int nPlot = GetGlobalNumber("MY_PLOT");
if (nPlot == 1)

{

if(!GetIsObjectValid(GetObjectByTag("my_npc_tag")))
CreateObject(OBJECT_TYPE_CREATURE, "my_npc_tag", Location(Vector(00.00, 00.00, 0.00), 0.0));
}
}

Thanks Darth333

Where do you think should be the best place to attach this script since "MY_PLOT" is set in a new area? The npc.utc or is there a specific node or entry in the area.git i should place it?...:)
 Darth333
11-29-2004, 8:57 PM
#45
Use the ExecuteScript function.
You'll find a tutorial here: http://www.lucasforums.com/showthread.php?s=&threadid=137370)

I also sent you a script to spawn a door that was using this a few weeks ago.
 Xavier2
11-29-2004, 9:09 PM
#46
Originally posted by Darth333
Use the ExecuteScript function.
You'll find a tutorial here: http://www.lucasforums.com/showthread.php?s=&threadid=137370)

I also sent you a script to spawn a door that was using this a few weeks ago.
Forgive me if its a stupid question...I noticed it was the same kind of script, but since the area where the npc should spawn (or if he is already dead shouldn't) is a custom area and there isn't a pre- made On Enter script, is this the one i should use?

void main()
{
StartNewModule("NEW_AREA");
}

EDIT: Also, should i remove this particular npc from the creature list in the NEW_AREA.git?
 Xavier2
12-01-2004, 9:09 PM
#47
Originally posted by tk102
There is not a script per se, but this is exactly what Global Variables are used for. Many plot elements use numeric globals to keep track of where the PC is in the game... like Canderous' sidequest... Jagi spawns only if you haven't met him (and killed him) yet.

So you .utc could have an OnDeath user-defined event that could write to a global variable, and your .utt or .are could have a script that checks that variable, and spawns the NPC if he hasn't been killed.
Ok i have this script:
void main()
{
int nPlot = GetGlobalNumber("MY_PLOT");
if (nPlot == 4)

{

if(!GetIsObjectValid(GetObjectByTag("thug")))
CreateObject(OBJECT_TYPE_CREATURE, "thug", Location(Vector(107.68, 76.06, 0.00), 0.0));
}
}
I placed it in the OnUserDefine script field in the NEW_AREA.are, but the thug doesn't spawn.:( . I checkede and MY_PLOT is set to 4 allright. Which one is the right field to place this script in the AREA.are? and is there another place to put it besides the .are?
 Darth333
12-02-2004, 5:27 AM
#48
Put it in the OnEnter field.
 Xavier2
12-02-2004, 7:07 AM
#49
Originally posted by Darth333
Put it in the OnEnter field.
hmmm...The OnEnter already has the Default script from the AREA which NEW_AREA is based on. Would it corrupt something?:confused:
 Darth333
12-02-2004, 7:12 AM
#50
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:

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 ;)
Page: 1 of 2