Author Topic: How is this script not working?  (Read 344 times)

Legacy_JM Scion

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
How is this script not working?
« on: December 17, 2011, 06:27:02 am »


               Ok, this is a pretty strange issue. I'm working on a script that is relatively simple. It's a quick cutscene in which an NPC unlocks a door, walks into a room, and locks the door behind him. Shortly after that, the player hears the sound of screaming, and once the cutscene ends the player knows they need to find another way into that locked room.

For some reason, right after the door closes and the "Roy" NPC is removed, the script stops dead in its tracks. The sound object does not play, the speakstring is not spoken, and the cutscene does not end, leaving the player trapped in cutscene mode with nothing happening.

What's strange is that the script compiles just fine. In fact I even tried commenting out the lines for the sound object and speakstring and the script still freezes. Really don't know where to start on this one. I don't think the problem is in the Gestalt Cutscene scripts since I have several other Gestalt-based cutscenes in the mod that work just fine.

Here's the code below.

#include "in_g_cutscene"

void main()
{
object oPC = GetFirstPC();
object oActor = GetObjectByTag("officer");
object oDoor = GetObjectByTag("st_psb1_dr_locker");
object oWP;
object oSound = GetObjectByTag("st_wtfbang");

GestaltStartCutscene(oPC, "movie_lockerroom1");


//Unlock the door.
SetLocked(oDoor, 0);

//Roy opens the door.
DelayCommand(1.0, AssignCommand(oActor, ActionOpenDoor(oDoor)));

//Roy enters the locker room.
oWP = GetWaypointByTag("officer_goal");
GestaltActionMove(1.1, oActor, oWP);

//Roy closes the door behind him.
DelayCommand(4.5, AssignCommand(oDoor, ActionCloseDoor(oDoor)));

//Lock the door behind him.
DelayCommand(5.5, SetLocked(oDoor, 1));

//Get rid of Roy.
GestaltDestroy(5.0, oActor);

[Right here is where the script seems to lock up]

//Play a sound object.
DelayCommand(10.0, SoundObjectPlay(oSound));

//PC says a line.
DelayCommand(15.0, AssignCommand(oPC, SpeakString("...Roy?")));

//Return control to PC.
GestaltStopCutscene(15.5, oPC);
}
               
               

               


                     Modifié par JM Scion, 17 décembre 2011 - 06:27 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How is this script not working?
« Reply #1 on: December 17, 2011, 06:48:43 am »


               in_g_cutscene is not a standard script and your script "lock up" appears right after you call a function in it (GestaltDestroy()).  If there is a script error then it would be coming from the function GestaltDestroy()
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How is this script not working?
« Reply #2 on: December 17, 2011, 07:03:30 am »


               ummm,  Just a quick guess without looking very deep into the script.  with what WhiZard said:
Are you by chance running the script on oActor?
               
               

               
            

Legacy_JM Scion

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
How is this script not working?
« Reply #3 on: December 17, 2011, 07:30:38 am »


               Ok, I took the long road and commented out all lines of code, then uncommented each line until the script froze up again. Sure enough, destroying the "Roy" NPC causes the script to lock up. I tried switching the GestaltDestroy command to a regular DestroyObject command, but no change. For some reason, NWN cannot remove this NPC by destroying it. Trying to destroy the NPC in a separate script just causes the same problem in that script. Very odd, never had that happen before.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How is this script not working?
« Reply #4 on: December 17, 2011, 07:38:37 am »


               So I ask again.  Is the script running on oTarget.  If it is all of the commands that are not assigned get destroyed along with oTarget.
               
               

               
            

Legacy_JM Scion

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
How is this script not working?
« Reply #5 on: December 17, 2011, 07:58:34 am »


               The script is running from the end of a conversation with the NPC. The script is attached to a PC dialog choice. Would that script then fire from the NPC just for firing from within the NPC's conversation file?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
How is this script not working?
« Reply #6 on: December 17, 2011, 09:17:21 am »


               

JM Scion wrote...

The script is running from the end of a conversation with the NPC. The script is attached to a PC dialog choice. Would that script then fire from the NPC just for firing from within the NPC's conversation file?


The dialog is attached to the NPC you are conversing with.  Do a check for OBJECT_SELF within the script (e.g. if(oActor == OBJECT_SELF) SendMessageToPC(GetFirstPC(), "Script is firing on object to be destroyed")'<img'>.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
How is this script not working?
« Reply #7 on: December 17, 2011, 05:18:22 pm »


               

JM Scion wrote...

The script is running from the end of a conversation with the NPC. The script is attached to a PC dialog choice. Would that script then fire from the NPC just for firing from within the NPC's conversation file?


Yes,  When you  Click on an NPC to talk to them, It is the OnConversation event on the NPC that fires.  The OnConversation Event Starts the conversation if the Listening Pattern was -1(Meaning the event started with nothing being heard,  ie a conversaton request).  That means that every script in the conversation is running on the NPC, unless it is specifically told to run elswhere.
               
               

               
            

Legacy_JM Scion

  • Jr. Member
  • **
  • Posts: 77
  • Karma: +0/-0
How is this script not working?
« Reply #8 on: December 18, 2011, 06:48:16 am »


               Ah, geez. I would never have caught onto that on my own. Thanks WhiZard and Lightfoot8!