Jump to content

Home

Cutscene/Dialog problem


Miltiades

Recommended Posts

I'm having problems with a certain situation, namely wanting a "cutscene" to trigger when the PC comes near two NPCs fighting. The triggering part already works (using a script that determines how far the PC is from one of the two NPCs, which I got in another thread).

 

I have spawned two NPCs with an On_Enter script into a module, and in that same script, I made it so they fight each other. I've got a script attached to the On_Heartbeat field of one of the two NPCS so that when the PC comes near, a dialog file starts. Now I've got two problems: The script keeps triggering as long as I'm close to the NPC (and since the NPC doesn't die, the script will remain active), so the dialog keeps triggering too. I need something that stops the script but at the same time assigns the NPC its default On_Heartbeat script.

 

Secondly, the dialog, no matter how many lines I put in there, only goes for a few seconds. Because the dialog file is mainly used for a cutscene, the nodes remain empty, but I the scripts I fill in in the nodes don't work. Have I done something wrong in the dialog file, or is this linked to the script?

 

I'd appreciate any help. It's frustrating. :p

Link to comment
Share on other sites

Miltiades wrote:

I have spawned two NPCs with an On_Enter script into a module, and in that same script, I made it so they fight each other. I've got a script attached to the On_Heartbeat field of one of the two NPCS so that when the PC comes near, a dialog file starts. Now I've got two problems: The script keeps triggering as long as I'm close to the NPC (and since the NPC doesn't die, the script will remain active), so the dialog keeps triggering too. I need something that stops the script but at the same time assigns the NPC its default On_Heartbeat script.

You need a global or local variable that is used as a condition along with the distance when the dialog is triggered. This should be changed to another value when the dialog is first run to prevent it from happening again. Here is an example:

void main() {
   object oPC = GetFirstPC();
   if ((GetIsInCombat(oPC) == FALSE) && (GetDistanceToObject(oPC) < 5.0)
       && (GetIsConversationActive() == FALSE) && (GetGlobalNumber("whateveryouchoose") == 0)) {
       ClearAllActions();
       SetGlobalNumber("whateveryouchoose", 1)
       ActionStartConversation(oPC, "dlg_name", FALSE, CONVERSATION_TYPE_CINEMATIC, TRUE);
   }
   if (GetGlobalNumber("whateveryouchoose") == 1) {
       ExecuteScript("k_def_heartbt01", OBJECT_SELF);
   }
   else {
       // The NPC's hertbeat script before the conversation here.
   }
}

You can also use a boolean or an NPC's local number as the conditional.

Miltiades wrote:

Secondly, the dialog, no matter how many lines I put in there, only goes for a few seconds. Because the dialog file is mainly used for a cutscene, the nodes remain empty, but I the scripts I fill in in the nodes don't work. Have I done something wrong in the dialog file, or is this linked to the script?

Probably the dialog because even if the script doesn't work the dialog usually continues. I can't say for sure though.
Link to comment
Share on other sites

Miltiades wrote:

I assume that this script keeps triggering as long as one of the four conditions is still true? Because now, the script's basically in a loop because the PC hasn't started combat (still need to make it stop in the dialog), right?

Nope. It should trigger the dialog only if all four conditions are true. I'm assuming that the global variable you choose will be 0 (or FALSE) before the dialog. The variable is changed to 1 when the dialog triggers. After the dialog the script should trigger the second option which is the default heartbeat script k_def_heartbt01. Before the dialog while one or more of the four conditions is not true it will run the third option which should contain your heartbeat script for that character. One that will make him fight the other character. If you want the NPCs continue their fight after the dialog you can remove the second if-structure.

 

The loop may be because you've not defined the global variable you use in the globalcat.2da. I think the game assumes a variable that does not exist to be 0 or FALSE. In that case all four conditions still apply after the dialog. If this is TSL you can use the character's local booleans instead of global variables as described here. That way you don't need to edit the 2da file.

Link to comment
Share on other sites

No, I haven't ,but I'll try the character's local booleans. One other thing: Since the fight is started in the On_enter script, the heartbeat script essentially is just the default one, right? So I should just trigger the k_def_heartbt01 as a third option just like the second, right? Or is starting the fight in the On_enter script a bad thing to do?

Link to comment
Share on other sites

Miltiades wrote:

Since the fight is started in the On_enter script, the heartbeat script essentially is just the default one, right? So I should just trigger the k_def_heartbt01 as a third option just like the second, right?

Yes. In this case you can just remove the second option.

Miltiades wrote:

Or is starting the fight in the On_enter script a bad thing to do?

Not really but you should cancel combat, clear all actions and swith the NPCs to the same faction before the dialog starts. The characters being hostile to each other and in combat may be why the dialog ends before it should.
Link to comment
Share on other sites

Not really but you should cancel combat, clear all actions and swith the NPCs to the same faction before the dialog starts. The characters being hostile to each other and in combat may be why the dialog ends before it should.

Problem is, they should continue fighting for some moments in the dialog before stopping. Or is it best to cancel combat and then resume it in the dialog again?

 

Anyway, the Local Boolean worked, so no loop anymore. Thanks for that! :)

Link to comment
Share on other sites

Miltiades wrote:

Problem is, they should continue fighting for some moments in the dialog before stopping. Or is it best to cancel combat and then resume it in the dialog again?

I'm not sure if this will work but you could have something else than one of the fighting NPCs be the conversation owner, a placeable perhaps? That way the dialog might work even if the NPCs are still fighting. Just be sure to cancel combat with a script before any nodes that have the combatants speak or perform dialog animations. If that doesn't work you'll have to cancel combat and resume it in the dialog with scripted attacks.

 

Scripting fights can be difficult but I've found that cutscene attacks or functions from the include script k_inc_fakecombat produce more reliable results than standard attacks. It could be good idea to have something else than the fighting NPCs be the conversation owner in this case too.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...