Jump to content

Home

Finally, i add a merchant to the game.


SoNico717

Recommended Posts

Thanks to stoffe's tutorial ( Link ) i could add a merchant ro the game... well sort of, instead of spawning one merchant i spawn i don't know see it for yourself here.

 

That happen because i activate the spawn script in a script (a_hatchopen) that seems to be working all the time. None the less i feel really happy that finally i could add something to the game :) thanks to KT, stoffe's tutorial and all the people that realese their mods with their source :).

 

This was only a test, don't think i going to add a custom merchant in the middle of peragus alone, though that will be funny.

Link to comment
Share on other sites

Where did you attach your script?

 

If you are using the OnEnter event of a module or a trigger, make sure you use the GetIsPC(oEntering)) function and check if the object is already there !GetIsObjectValid

 

Here is an example:

void main()
{
 object oEntering = GetEnteringObject();
 object oPC=GetFirstPC();
 if (GetIsPC(oEntering))
     {
     if  (!GetIsObjectValid(GetObjectByTag("d3_duros")))
           {
         CreateObject(OBJECT_TYPE_CREATURE, "d3_duros", Location(Vector(43.41,-0.28,9.66), 0.0));
         NoClicksFor(0.5);
         AssignCommand((GetObjectByTag("d3_duros")),ActionMoveToObject(oPC));
         AssignCommand((GetObjectByTag("d3_duros")), ActionDoCommand(ActionStartConversation(oPC)));
           }

    ExecuteScript("old_a_306onenter", GetModule()); 	
    }

}

Link to comment
Share on other sites

That is fairly easy to correct, just add a conditional at the top of your script that will only run your spawn script if the NPC isn't there... once he is spawned it will simply exit and do nothing.

 

For example;

void main()
{
       // Check if the Placeable or NPC exists - if it does not then create it
// This stops the script from running more than once.
       if (GetIsObjectValid(GetObjectByTag("InsertNPCTagHere")) == FALSE)
       {
            	float x=0.00f;  //NPC Spawn coordinates go here
	float y=0.00f;
	float z=0.00f;
	float r=0.0f;
	vector vecNPC=Vector(x,y,z);
	location locNPC=Location(vecNPC, r);
	CreateObject(OBJECT_TYPE_CREATURE,"InsertNPCTagHere",locNPC);
       }     
}

I hope this helps! :D

 

EDIT: I see Darth333 was slightly quicker than me! :lol:

Link to comment
Share on other sites

Originally posted by SoNico717

That happen because i activate the spawn script in a script (a_hatchopen) that seems to be working all the time.

 

The a_hatch_open script is the OnEnter script for the Peragus Admin area, thus it is run whenever a creature (PC or NPC) is spawned into that area.

 

What happens is that when you spawn your first merchant, it triggers the script again as it appears (ie enters the area), which creates another one, which triggers the script again, and so on. Thus you are creating an infinite loop where whenever a merchant spawns, it runs the script that spawns another. :)

 

When you add things to existing scripts you have to be careful where you put the things you add, since those scripts can be triggered in many different ways. The a_hatchopen script for example does different things when you enter the area depending on how far along you've gotten in the game.

 

In this case you'd have to make sure you add your new code in the section of the script that only runs when you enter the area for the first time (ie is spawned in the tank).

Link to comment
Share on other sites

Originally posted by stoffe -mkb-

The a_hatch_open script is the OnEnter script for the Peragus Admin area, thus it is run whenever a creature (PC or NPC) is spawned into that area.

 

What happens is that when you spawn your first merchant, it triggers the script again as it appears (ie enters the area), which creates another one, which triggers the script again, and so on. Thus you are creating an infinite loop where whenever a merchant spawns, it runs the script that spawns another. :)

 

When you add things to existing scripts you have to be careful where you put the things you add, since those scripts can be triggered in many different ways. The a_hatchopen script for example does different things when you enter the area depending on how far along you've gotten in the game.

 

In this case you'd have to make sure you add your new code in the section of the script that only runs when you enter the area for the first time (ie is spawned in the tank).

 

Now i get it, thanks for your explanation :).

 

It will take me time to understand the fuction that kotor 2 engine use to make things happens, in the past i script mods in morrowind but the fuctions of this game where to easy to learn and remember.

 

Someone knows where i can download a list of the fuctions that kotor 2 use so i can read it?

 

Thanks again.

Link to comment
Share on other sites

Originally posted by SoNico717

Thanks to stoffe's tutorial ( Link ) i could add a merchant ro the game... well sort of, instead of spawning one merchant i spawn i don't know see it for yourself here.

 

That happen because i activate the spawn script in a script (a_hatchopen) that seems to be working all the time. None the less i feel really happy that finally i could add something to the game :) thanks to KT, stoffe's tutorial and all the people that realese their mods with their source :).

 

This was only a test, don't think i going to add a custom merchant in the middle of peragus alone, though that will be funny.

I like it that way. Can you talk to each droid? They could have been some weird broken down droids...and one was re-programmed....who then went on programming the others....

 

...how perverse. :D

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...