Jump to content

Home

Tell me if I'm scripting this right...


idontknow3300

Recommended Posts

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);

}

 

}

Link to comment
Share on other sites

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:

 

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);
}

Link to comment
Share on other sites

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:

 

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! :D -RH

Link to comment
Share on other sites

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

 tags.
Link to comment
Share on other sites

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

 

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.

Link to comment
Share on other sites

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:

CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(danm_13(60.97,42.29,5.03), 0.0));

With this one:

CreateObject(OBJECT_TYPE_CREATURE, "dan_dan1", Location(Vector(60.97, 42.29, 5.03), 0.0));

Link to comment
Share on other sites

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:

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);
}

 

 

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.

Link to comment
Share on other sites

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.

 

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.

 

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.

 

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.

 

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:

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);

}

}

}

Link to comment
Share on other sites

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:
    // 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. :)

scripts.zip

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...