lfnetwork.com mark read register faq members calendar

Thread: Tell me if I'm scripting this right...
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 03-25-2006, 03:23 PM   #1
idontknow3300
Rookie
 
idontknow3300's Avatar
 
Join Date: Mar 2006
Posts: 15
Tell me if I'm scripting this right...

What I'm trying to do now is spawn a jedi behind a bech on Dantooine. I don't see what I'm doing wrong here, but the jedi is not spawning. The script I'm using is:

void main()
{
object oEntering = GetEnteringObject();
object oPC=GetFirstPC();
if (GetIsPC(oEntering))
{ //check if the object is already there to avoid multiple objects
if (!GetIsObjectValid(GetObjectByTag("o")))
{ //Note that the script uses OBJECT_TYPE_CREATURE instead of OBJECT_TYPE_PLACEABLE - that's the only difference with the container:
CreateObject(OBJECT_TYPE_CREATURE, "dan13_jedi.utc", Location(danm_13(60.97,42.29,5.03), 0.0));
ExecuteScript("old_a_306onenter", OBJECT_SELF);
}

}
idontknow3300 is offline   you may: quote & reply,
Old 03-25-2006, 07:12 PM   #2
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by idontknow3300
What I'm trying to do now is spawn a jedi behind a bech on Dantooine. I don't see what I'm doing wrong here, but the jedi is not spawning. The script I'm using is:
(snip)
There were a few problems with that script, you should have been getting compilation errors if you try to run it through nwnnsscomp:

First, you were missing an ending } for one of your If-statements.

Second, you included the ".utc" extension in the ResRef, which is incorrect. A ResRef is the same as the file name without the extension (max 16 characters and some other limitations too, though that is irrelevant in this case).

Third, your location code was looking a bit odd. You used the name of the module instead of the Vector() function when specifying coordinates.

Also, the GetFirstPC() line was unnessecary since you didn't use it for anything, though that's not really an error.

Try this:

Code:
void main() {
    object oEntering = GetEnteringObject();
    if (GetIsPC(oEntering)) { 
        if (!GetIsObjectValid(GetObjectByTag("o"))) {
            CreateObject(OBJECT_TYPE_CREATURE, "dan13_jedi", Location(Vector(60.97, 42.29, 5.03), 0.0));
        }
    }
    ExecuteScript("old_a_306onenter", OBJECT_SELF);
}


Last edited by stoffe -mkb-; 03-26-2006 at 04:34 PM.
stoffe is offline   you may: quote & reply,
Old 03-26-2006, 01:10 PM   #3
idontknow3300
Rookie
 
idontknow3300's Avatar
 
Join Date: Mar 2006
Posts: 15
Didn't work

I tried your way, but then it didn't work, so I figured it was because there was already one of those npcs in the area, so I then tried to spawn Jolan Aphett there. I used this script:

Code:
void main() {
	object oEntering = GetEnteringObject();
	if (GetIsPC(oEntering)) {
		if (!GetIsObjectValid(GetObjectByTag("o"))) { 
		CreateObject(OBJECT_TYPE_CREATURE, "man26_jolan", Location(Vector(60.97, 42.29, 5.03), 0.0)); 
		ExecuteScript("old_a_306onenter", OBJECT_SELF); 
		} 
	} 
}
Also, how do I put my script in that cool blue box?

Viola! -RH

Last edited by RedHawke; 03-26-2006 at 09:46 PM.
idontknow3300 is offline   you may: quote & reply,
Old 03-26-2006, 03:41 PM   #4
Det. Bart Lasiter
obama.png
 
Det. Bart Lasiter's Avatar
 
Join Date: Mar 2005
Location: `(.)~
Posts: 7,997
Current Game: all
Forum Veteran LF Jester 
You have to use code tags. Just click the button with the pound sign (#) above the text box to see how. This forum needs "noparse" tags...



"No, Mama. You can bet your sweet ass and half a titty whoever put that hit on you already got the cops in their back pocket." ~Black Dynamite
Det. Bart Lasiter is offline   you may: quote & reply,
Old 03-26-2006, 04:33 PM   #5
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by idontknow3300
I tried your way, but then it didn't work, so I figured it was because there was already one of those npcs in the area, so I then tried to spawn Jolan Aphett there. I used this script:
(snip)
CreateObject(OBJECT_TYPE_CREATURE, "man26_jolan",
(snip)
Also, how do I put my script in that cool blue box?
That wouldn't work either unless you have copied man26_jolan.utc to the override folder, since that creature template only exists in the Ahto West Central module, and thus he can only be spawned there normally.

If there's already a creature with the specified tag in the area the script might well work since it's written not to spawn another? Destroy the existing one (or change the tag of the NPC to something unique) to test it more reliably.

In any case I'd recommend moving the ExecuteScript call outside your conditional checked block, since you'd want it to run the original OnEnter script every time and not just whenever your creature should be spawned.

As for the code boxes, enclose the source code in [/CODE] and [CODE] tags.

stoffe is offline   you may: quote & reply,
Old 03-26-2006, 05:25 PM   #6
idontknow3300
Rookie
 
idontknow3300's Avatar
 
Join Date: Mar 2006
Posts: 15
Still Not working, but I think I'm getting closer

It's still not working, but I think I'm getting closer. I'm now using this script:

Code:
void main() 
{ 
object oEntering = GetEnteringObject(); 
object oPC=GetFirstPC();
 if (GetIsPC(oEntering))
{ //check if the object is already there to avoid multiple objects 
if (!GetIsObjectValid(GetObjectByTag("o"))) 
{ //Note that the script uses OBJECT_TYPE_CREATURE instead of OBJECT_TYPE_PLACEABLE - that's the only difference with the container: 
CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(danm_13(60.97,42.29,5.03), 0.0));
 ExecuteScript("old_a_306onenter", OBJECT_SELF);
   } 

}
Now, the .utc file "dan_dan1" is in the override, but the creature is still not spawning. you said something about an OnEnter script, what was that? I think I already did that, but just in case, I want to know.
idontknow3300 is offline   you may: quote & reply,
Old 03-26-2006, 05:35 PM   #7
Det. Bart Lasiter
obama.png
 
Det. Bart Lasiter's Avatar
 
Join Date: Mar 2005
Location: `(.)~
Posts: 7,997
Current Game: all
Forum Veteran LF Jester 
Quote:
Originally Posted by idontknow3300
It's still not working, but I think I'm getting closer. I'm now using this script:

{snip}

Now, the .utc file "dan_dan1" is in the override, but the creature is still not spawning. you said something about an OnEnter script, what was that? I think I already did that, but just in case, I want to know.
Replace this line:
Code:
CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(danm_13(60.97,42.29,5.03), 0.0));
With this one:
Code:
CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(Vector(60.97, 42.29, 5.03), 0.0));



"No, Mama. You can bet your sweet ass and half a titty whoever put that hit on you already got the cops in their back pocket." ~Black Dynamite
Det. Bart Lasiter is offline   you may: quote & reply,
Old 03-26-2006, 05:50 PM   #8
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by idontknow3300
It's still not working, but I think I'm getting closer. I'm now using this script:
(snip)
Now, the .utc file "dan_dan1" is in the override, but the creature is still not spawning.
Perhaps a stupid question, but are you actually compiling the NSS file into a NCS file before putting it in the override folder? Your script has compilation errors and as such no NCS file should have been produced. The game engine uses the NCS files, the NSS files are meant for humans and are not used for anything by the game itself.

As for the script: Same errors as the last time... The module name in place of the Vector() function, missing ending } for one of your if-statement blocks, and an ExecuteScript call to the original script that placed in a location where it may potentially cause trouble.

Also, is the tag of the creature, set in the UTC file, really just o?

This should compile and work, as long as the Tag and ResRef of the creature are correct, and the script is properly triggered:
Code:
void main()  { 
    if (GetEnteringObject() == GetFirstPC()) { 
        //check if the object is already there to avoid multiple objects 
        if (!GetIsObjectValid(GetObjectByTag("o"))) {
            CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(Vector(60.97, 42.29, 5.03), 0.0));
        } 
    }
    ExecuteScript("old_a_306onenter", OBJECT_SELF);
}

Quote:
Originally Posted by idontknow3300
you said something about an OnEnter script, what was that? I think I already did that, but just in case, I want to know.
What name have you given your script? I got the impression that your script was intended to replace the original Area OnEnter script for the area you are intending to modify by making a script with the same name as the original one, and then run a renamed copy of the original script afterwards ("a_306onenter")?

Upon closer inspection, the only a_306onenter.ncs file I can locate though is the OnEnter script for the Nar Shaddaa Entertainment Promenade area in KotOR2:TSL. I'm starting to suspect that your script is, in fact, not run at all since you've likely not named it properly.

If you intend to modify the Enclave Courtyard area on Dantooine (in KotOR1), the name of the OnEnter script for that area is k_pdan_14a_area. You'd have to name your script that, extract a copy of the original script with KotorTool from that module, rename it to something (like "old_pdan14a_area" if following the naming convention used in your script, max 16 characters!) and make the ExecuteScript call in your custom script run this renamed script.

The line:
ExecuteScript("old_a_306onenter", OBJECT_SELF);
...is intended to run the original OnEnter script of the area that has been replaced by the script in question, to allow the game to do what it usually does when someone enter the area.


Last edited by stoffe -mkb-; 03-26-2006 at 06:02 PM.
stoffe is offline   you may: quote & reply,
Old 03-26-2006, 06:29 PM   #9
idontknow3300
Rookie
 
idontknow3300's Avatar
 
Join Date: Mar 2006
Posts: 15
Quote:
Perhaps a stupid question, but are you actually compiling the NSS file into a NCS file before putting it in the override folder?
I'm not sure what that means, so I'll have to say no.

Quote:
Also, is the tag of the creature, set in the UTC file, really just o?
Er...no, that's weird. I'll change that. That tag is the same as the .utc's name, dan_dan1.

Quote:
What name have you given your script? I got the impression that your script was intended to replace the original Area OnEnter script for the area you are intending to modify by making a script with the same name as the original one, and then run a renamed copy of the original script afterwards ("a_306onenter")?
Uh, wait...the name of the .nss is "spawn_dude". I wasn't trying to replace anything.

Quote:
Upon closer inspection, the only a_306onenter.ncs file I can locate though is the OnEnter script for the Nar Shaddaa Entertainment Promenade area in KotOR2:TSL. I'm starting to suspect that your script is, in fact, not run at all since you've likely not named it properly.
Alright, that's interesting. Darth333 really messed me up here. They told how to spawn a tach in the Nar Shaddaa thing, but I didn't know what was going on so I just copied part of that script.

Quote:
If you intend to modify the Enclave Courtyard area on Dantooine (in KotOR1), the name of the OnEnter script for that area is k_pdan_14a_area. You'd have to name your script that, extract a copy of the original script with KotorTool from that module, rename it to something (like "old_pdan14a_area" if following the naming convention used in your script, max 16 characters!) and make the ExecuteScript call in your custom script run this renamed script.
So. I'd have to name the script "k_pdan_14a_area", then name it something else and make the ExecuteScript do that? Actually, I don't know what I just said. Can you clear that part up for me?

Just for the record, I'm now using this script:
Quote:
void main()
{
object dan_dan1Entering = GetEnteringObject();
object dan_dan1PC=GetFirstPC();
if (GetIsPC(dan_dan1Entering))
{ //check if the object is already there to avoid multiple objects
if (!GetIsObjectValid(GetObjectByTag("dan_dan1")))
{ //Note that the script uses OBJECT_TYPE_CREATURE instead of OBJECT_TYPE_PLACEABLE - that's the only difference with the container:
CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(Vector(60.97, 42.29, 5.03), 0.0));
ExecuteScript("spawn_dude", OBJECT_SELF);
}
}
}
idontknow3300 is offline   you may: quote & reply,
Old 03-26-2006, 07:02 PM   #10
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by idontknow3300
I'm not sure what that means, so I'll have to say no.
Actually, I don't know what I just said. Can you clear that part up for me?
  1. Create a new NSS file and name it exactly k_pdan_14a_area.nss. Save this in your KotorTool folder. Paste this source code into that file:
    Code:
    // ST: k_pdan_14a_area.nss
    void main()  { 
        // ST Make sure only the player entering the area triggers this.
        if (GetEnteringObject() == GetFirstPC()) { 
            // ST: Only create the creature if it does not already exist.
            if (!GetIsObjectValid(GetObjectByTag("dan_dan1"))) {
                // ST: Spawn creature from dan_dan1.utc at coordinates x=60.97, y=42.29, facing north.
                CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(Vector(60.97, 42.29, 5.03), 0.0));
            } 
        }
        // ST: Run the original OnEnter script for the Courtyard area.
        ExecuteScript("old_pdan14a_area", OBJECT_SELF);
    }
  2. Make sure the spawn coordinates in the script above are valid. If not, load the game, go to the Dantooine Courtyard, stand where you want the NPC to appear, activate the console prompt and type "whereami". Take note of the X,Y,Z coordinates displayed on screen and input them inside the Vector function in the script instead of the 3 numbers currently there.

  3. Open KotorTool and open Kotor1 --> RIMs --> danm14aa --> Script, Compiled and extract the file named k_pdan_14a_area.ncs found there to your KotorTool folder.

  4. Browse to your KotorTool folder in the Windows Explorer and rename the file you just extracted to old_pdan14a_area.ncs.

  5. Use nwnnsscomp.exe (which should have come with KotorTool) to compile the script you created in (1) above. Nwnnsscomp.exe is a commandline utility. If you are unfamiliar with how to use the Windows commandline I think some of the later KotorTool versions offer a more user-friendly front-end for compiling scripts via its built-in text editor. My current version is fairly old so I cannot give you exact instructions how that is done.

    If you do know how to use the commandline, open a new commandline window, navigate to the KotorTool folder and run nwnsscomp.exe. This command should work to compile the script:
    nwnnsscomp.exe -c k_pdan_14a_area.nss

  6. If everything worked out fine and you got no compilation errors, it should have created a new file named k_pdan_14a_area.ncs. This is your compiled script that the game will use. Put the k_pdan_14a_area.ncs file and the old_pdan14a_area.ncs file in your override folder.

  7. Go to the Courtyard outside the Dantooine Jedi Academy, and your NPC should spawn at the specified coordinates.

Here are the files in question if you still don't understand what I'm trying to explain.
Attached Files
File Type: zip scripts.zip (1.8 KB, 42 views)

stoffe is offline   you may: quote & reply,
Old 03-27-2006, 08:29 PM   #11
idontknow3300
Rookie
 
idontknow3300's Avatar
 
Join Date: Mar 2006
Posts: 15
allright, that time it worked. thanks a bunch.
idontknow3300 is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Tell me if I'm scripting this right...

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:23 PM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.