DarthRevan101

Question about a script

Recommended Posts

For a mod, during a certain part of a quest, a mob is supposed to appear on Tatooine when the player arrives. While that works, it appears at any time during the game and they'll appear again when you re-enter the module. I'm not great at the coding, but can someone tell me what this code should look like?

void main() {
	
	object oEntering = GetEnteringObject();
	object oCreature = GetObjectByTag("glysh");
	if (GetIsPC(oEntering))
	if (GetIsObjectValid(oCreature) == FALSE)
        if (GetGlobalNumber("MAX_QUEST") == 3)
        if ((IsNPCPartyMember(NPC_T3_M4) == TRUE))
        CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32, -44.53, 0.0), 90.0));
        CreateObject (OBJECT_TYPE_CREATURE, "glysh", Location(Vector (8.99, -43.21, 0.0), 90.00));
        CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32, -44.68, 0.0), 90.0));
        CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (10.36, -44.41, 0.0), 90.0)); 
        CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (11.84, -43.19, 0.0), 90.0));
        object oNPC=GetObjectByTag("glysh");
        AssignCommand ((oNPC), ActionStartConversation(GetFirstPC(),"bad_glysh"));

}

Share this post


Link to post
Share on other sites

You may want to check out this thread - http://www.lucasforums.com/showthread.php?t=143536

 

In particular, the part regarding setting a global boolean in order to only spawn an NPC once would appear to be what you are chasing. Regarding limiting it to a specific module, you'll presumably have to hijack that module's onenter script, which means injecting it into a MOD file, not just dumping it in the Override.

  • Like 1

Share this post


Link to post
Share on other sites

You may want to check out this thread - http://www.lucasforums.com/showthread.php?t=143536

 

In particular, the part regarding setting a global boolean in order to only spawn an NPC once would appear to be what you are chasing. Regarding limiting it to a specific module, you'll presumably have to hijack that module's onenter script, which means injecting it into a MOD file, not just dumping it in the Override.

To make sure it happens only on the one module, I followed more or less this tutorial: http://www.lucasforums.com/showthread.php?t=199447 

 

Will that work okay or is injecting it in to a .mod file a better way of doing it?

Share this post


Link to post
Share on other sites

Also, I assume all the if parts are supposed to all count towards spawning the NPCs, correct?

 

If so, you'll need something more like this as an extra safety measure:

 

 

 

void main()
{
	object oEntering = GetEnteringObject();
	object oCreature = GetObjectByTag("glysh");

	if (GetIsPC(oEntering) &&
	(GetIsObjectValid(oCreature) == FALSE) &&
	(GetGlobalNumber("MAX_QUEST") == 3) &&
	(IsNPCPartyMember(NPC_T3_M4) == TRUE))
	{
		// At this point, you would do as Darth Parametric suggested and trigger some sort of variable so that this doesn't happen again.
		// Easiest solution would be to set the global number "MAX QUEST" to 4, but not sure how that will affect what you have set up after the quest...

		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32,  -44.53, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "glysh",      Location(Vector (8.99,  -43.21, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32,  -44.68, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (10.36, -44.41, 0.0), 90.0)); 
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (11.84, -43.19, 0.0), 90.0));

		object oNPC = GetObjectByTag("glysh");
		AssignCommand (oNPC, ActionStartConversation(GetFirstPC(),"bad_glysh"));
	}
}

 

 

 

Since all of your if statements weren't connected and dependent on each other, they weren't working together to pin down when this action occurred. That would at least explain why it was always triggering.

 

As to whether it's repeatable, you would have to try the code above and see if it repeats. If it does, then I will advise you to look at the comment at the beginning of the spawning section.

 

Also, if you need me to explain anything about my changes, just let me know.

Share this post


Link to post
Share on other sites

Also, I assume all the if parts are supposed to all count towards spawning the NPCs, correct?

 

If so, you'll need something more like this as an extra safety measure:

 

 

 

void main()
{
	object oEntering = GetEnteringObject();
	object oCreature = GetObjectByTag("glysh");

	if (GetIsPC(oEntering) &&
	(GetIsObjectValid(oCreature) == FALSE) &&
	(GetGlobalNumber("MAX_QUEST") == 3) &&
	(IsNPCPartyMember(NPC_T3_M4) == TRUE))
	{
		// At this point, you would do as Darth Parametric suggested and trigger some sort of variable so that this doesn't happen again.
		// Easiest solution would be to set the global number "MAX QUEST" to 4, but not sure how that will affect what you have set up after the quest...

		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32,  -44.53, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "glysh",      Location(Vector (8.99,  -43.21, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (7.32,  -44.68, 0.0), 90.0));
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (10.36, -44.41, 0.0), 90.0)); 
		CreateObject (OBJECT_TYPE_CREATURE, "test_trand", Location(Vector (11.84, -43.19, 0.0), 90.0));

		object oNPC = GetObjectByTag("glysh");
		AssignCommand (oNPC, ActionStartConversation(GetFirstPC(),"bad_glysh"));
	}
}

 

 

 

Since all of your if statements weren't connected and dependent on each other, they weren't working together to pin down when this action occurred. That would at least explain why it was always triggering.

 

As to whether it's repeatable, you would have to try the code above and see if it repeats. If it does, then I will advise you to look at the comment at the beginning of the spawning section.

 

Also, if you need me to explain anything about my changes, just let me know.

 

Works perfectly now, thanks!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.