Thread: [WIP] LDR's WIPs
View Single Post
Old 10-22-2010, 11:45 PM   #24
Kyr'am Galaar
Junior Member
 
Kyr'am Galaar's Avatar
 
Join Date: Jun 2009
Posts: 428
Quote:
Originally Posted by Darth333
How to spawn a container when I enter an area:

(you can always decompile the script and add the lines to spawn a container or you can use the easy following method which gives the same results at the end)

1. extract the On_enter script for the module. Check the .are file if you are unsure. Per example, when you enter the bar in NAr Shadaa, the script would be: a_306onenter.ncs
2. rename the script you just extracted to something else: exmaple old__a_306onenter.ncs
3. Create a new 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")))
            {
      //replace the (0.00,0.00,0.00) by the xyz coordinates where you want to spawn the container.
      //for TSL, use the whereami armband http://www.starwarsknights.com to get the coordinates. For kotor use the whereami cheat
          oContainer= CreateObject(OBJECT_TYPE_PLACEABLE, "container_templateresref", Location(Vector(0.00,0.00,0.00), 0.0)); 
            }
     // Fire the old onenter script that we renamed at step 2:
     ExecuteScript("old_a_306onenter", OBJECT_SELF); 	
     }

}
4. Save your script as a_306onenter.nss (the original name of the On enter script we extracted) and compile.

How to spawn a npc in an area:

It works exactly the same as a container:
1. extract the On_enter script for the module. Check the .are file if you are unsure. Per example, when you enter the bar in NAr Shadaa, the script would be: a_306onenter.ncs
2. rename the script you just extracted to something else: exmaple old__a_306onenter.ncs
3. Create a new 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, "my_npc_templateresref", Location(Vector(43.41,-0.28,9.66), 0.0));

          // this portion is optional and will only work if you spawn the npc not too far from where you enter the area - careful if there are scripted cutscenes too.
	  // You can also use the On perception event instead of the on enter script for this.
          NoClicksFor(0.5);
	  //Make the NPC walk towards you:
          AssignCommand((GetObjectByTag("my_npc_tag")),ActionMoveToObject(oPC));
	  //Make the npc initiate the converstation after approcahing you:
          AssignCommand ((GetObjectByTag("my_npc_tag")), ActionDoCommand(ActionStartConversation(oPC)));
            }

     ExecuteScript("old_a_306onenter", OBJECT_SELF); 	
     }

}
4. Save your script as a_306onenter.nss (the original name of the On enter script we extracted) and compile
You don't need to add all of the features to the scripts. Just the one to spawn it. If you need more help, either PM or VM me. I'll go into detail then...


Does anyone actually read these?
Kyr'am Galaar is offline   you may: quote & reply,