DarthRevan101 104 Posted March 1, 2016 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")); } Quote Share this post Link to post Share on other sites
DarthParametric 3,777 Posted March 1, 2016 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. 1 Quote Share this post Link to post Share on other sites
DarthRevan101 104 Posted March 1, 2016 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? Quote Share this post Link to post Share on other sites
DarthParametric 3,777 Posted March 1, 2016 It depends on whether the script has a unique name. If it doesn't, you'll need to use a MOD to avoid it being loaded in the wrong place. Quote Share this post Link to post Share on other sites
Fair Strides 509 Posted March 1, 2016 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. Quote Share this post Link to post Share on other sites
DarthRevan101 104 Posted March 1, 2016 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! Quote Share this post Link to post Share on other sites