Jump to content

Home

Help with script spawning NPCs (was: will this....)


Master Orran

Recommended Posts

if i use this script will this spawn atton, kreia and t3m4 in the same location in one script?

 

// Generated by jmac7142's KotOR Script Generator 
// Spawn Creature / Open Merchant 

#include "k_inc_debug" 
#include "k_inc_utility" 

void main() 
{ 
   float x = 0; 
   float y = 0; 
   float z = 0; 
   float r = Orientation; 

   vector vCre = Vector(x, y, z); 
   location lCre = Location(r, vCre); 

   if (GetIsPC(GetEnteringObject())) 
   { 
       object oCre = CreateObject(OBJECT_TYPE_CREATURE, "p_Atton, p_Kreia, p_T3M4", lCre); 
   } 
   else 
   { 
       return; 
   } 

}

 

or

 

// Generated by jmac7142's KotOR Script Generator 
// Spawn Creature / Open Merchant 

#include "k_inc_debug" 
#include "k_inc_utility" 

void main() 
{ 
   float x = 0; 
   float y = 0; 
   float z = 0; 
   float r = Orientation; 

   vector vCre = Vector(x, y, z); 
   location lCre = Location(r, vCre); 

   if (GetIsPC(GetEnteringObject())) 
   { 
       object oCre = CreateObject(OBJECT_TYPE_CREATURE, "p_Atton", lCre);
       object oCre = CreateObject(OBJECT_TYPE_CREATURE, "p_Kreia", lCre);
       object oCre = CreateObject(OBJECT_TYPE_CREATURE, "p_T3M4", lCre); 
   } 
   else 
   { 
       return; 
   } 

}

 

Moderator note: Changed thread title. Using more descriptive thread titles will increase the chance that someone who can answer your questions will read the thread. Please do so. :) ~M

Link to comment
Share on other sites

if i use this script will this spawn atton, kreia and t3m4 in the same location in one script?

 

No, since neither of them will compile. You assign Orientation to the variable r but it has never been declared, and you try to assign the integer value 0 to the three float variables x, y and z. You'll either have to explicitly say it's a float, or add a decimal separator (0f or 0.0).

 

Further you have the parameters to the Location() function call in the wrong order, you should specify a coordinate vector as the first parameter and a facing angle as the second.

 

Also the first script wouldn't spawn anything since there is no creature template with the ResRef p_Atton, p_Kreia, p_T3M4 since it is an invalid ResRef (it's too long and contains non-alphanumerical characters).

 

Unless you intend to spawn the characters at coordinates 0, 0, 0 you'll need to set where in the area they should spawn as well.

 

The script also contains a bunch of unnecessary code, which while it's not an error its... unnecessary. :)

  • You don't need either of the two include files you include since you don't use any functions or globals defined within them.
  • You declare lots of variables (x, y, z, r, vCre) that you only use once and might just as well put the constant values as function parameters directly.
  • You assign the created NPCs to the oCre variable but you never use it for anything. And you declare the variable three times in the same scope in the second script.
  • You don't check if the creature triggering the script should run it until you've already declared a bunch of variables and assigned values to them. And you don't need the else statement of the PC check, since the script would just end there anyway.

 

Finally, the script as it is laid out would only work as an OnEnter script, since the GetEnteringObject() doesn't work in other types of scripts. If that's what you need it for then that's OK though. :)

 

You could do the same like:

void main() {
   [color=PaleGreen]// ST: These two lines are only needed for OnEnter event scripts.[/color]
   if (GetEnteringObject() != GetFirstPC())
       return;

   [color=PaleGreen]// ST: Destination coordinates (x,y,z) within the area need to be set here.[/color]
   location lCre = Location(Vector(0.0, 0.0, 0.0), 0.0);
   CreateObject(OBJECT_TYPE_CREATURE, "p_atton", lCre);
   CreateObject(OBJECT_TYPE_CREATURE, "p_kreia", lCre);
   CreateObject(OBJECT_TYPE_CREATURE, "p_t3m4", lCre);
}

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...