From addf28a0aba092c03c0e9b3f89d2dff39eeb361b Mon Sep 17 00:00:00 2001 From: Maikel de Vries Date: Sun, 2 Feb 2014 18:03:33 +0100 Subject: [PATCH] Fix issues with Crash.ocs intro (#951) --- .../Missions.ocf/Crash.ocs/System.ocg/Intro.c | 4 ++- .../Crash.ocs/System.ocg/StringTblUS.txt | 2 +- .../Helpers.ocd/Dialogue.ocd/DefCore.txt | 4 +-- .../Helpers.ocd/Dialogue.ocd/Script.c | 33 ++++++++++++++----- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/planet/Missions.ocf/Crash.ocs/System.ocg/Intro.c b/planet/Missions.ocf/Crash.ocs/System.ocg/Intro.c index 8a8d84b40..7e86b5703 100644 --- a/planet/Missions.ocf/Crash.ocs/System.ocg/Intro.c +++ b/planet/Missions.ocf/Crash.ocs/System.ocg/Intro.c @@ -47,6 +47,7 @@ global func FxIntIntroStart(object target, proplist effect) effect.Pilot->SetDir(DIR_Left); effect.Pilot->SetObjectLayer(effect.Pilot); effect.Dialog = effect.Pilot->SetDialogue("Pilot"); + effect.Dialog->SetInteraction(false); effect.Plane->FaceRight(); effect.Plane->StartInstantFlight(90, 15); @@ -106,10 +107,11 @@ global func FxIntIntroTimer(object target, proplist effect, int time) if(effect.Time == 500) for(var i = 0; i < GetPlayerCount(); ++i) GetCursor(GetPlayerByIndex(i))->CloseMenu(); - + if(effect.Time >= 830) { effect.Pilot->SetCommand("MoveTo", effect.Pilot, 120 - effect.Pilot->GetX(), 860 - effect.Pilot->GetY()); + effect.Dialog->SetInteraction(true); return -1; } } diff --git a/planet/Missions.ocf/Crash.ocs/System.ocg/StringTblUS.txt b/planet/Missions.ocf/Crash.ocs/System.ocg/StringTblUS.txt index 1488c6f61..841bf71bc 100644 --- a/planet/Missions.ocf/Crash.ocs/System.ocg/StringTblUS.txt +++ b/planet/Missions.ocf/Crash.ocs/System.ocg/StringTblUS.txt @@ -3,7 +3,7 @@ MsgIntro1=Wow, it's very turbulent here... MsgIntro2=Have a look at that lava lake! MsgIntro3=Come on old girl, hang in there... MsgIntro4=Uh oh... -MsgIntro5=Quick! The ejecter seats! +MsgIntro5=Quick! The ejection seats! # NPC Pilot NamePilot=Pilot diff --git a/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/DefCore.txt b/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/DefCore.txt index 8dcf67f50..29b5bea70 100644 --- a/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/DefCore.txt +++ b/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/DefCore.txt @@ -4,6 +4,4 @@ Version=5,2,0,1 Category=C4D_StaticBack Width=8 Height=20 -Offset=-4,-10 - - +Offset=-4,-10 \ No newline at end of file diff --git a/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/Script.c b/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/Script.c index 75e284474..eb34c9489 100644 --- a/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/Script.c +++ b/planet/Objects.ocd/Helpers.ocd/Dialogue.ocd/Script.c @@ -10,6 +10,7 @@ local dlg_name; local dlg_info; local dlg_progress; local dlg_status; +local dlg_interact; static const DLG_Status_Active = 0; static const DLG_Status_Stop = 1; @@ -50,9 +51,10 @@ protected func Initialize() { // Dialogue progress to one. dlg_progress = 1; - + // Dialogue allows interaction by default. + dlg_interact = true; + // Dialogue is active by default. dlg_status = DLG_Status_Active; - return; } @@ -85,8 +87,12 @@ private func UpdateDialogue() public func SetDialogueInfo() { + return; +} - +public func SetInteraction(bool allow) +{ + dlg_interact = allow; return; } @@ -105,7 +111,7 @@ public func SetDialogueStatus(int status) /*-- Interaction --*/ // Players can talk to NPC via the interaction bar. -public func IsInteractable() { return true; } +public func IsInteractable() { return dlg_interact; } // Adapt appearance in the interaction bar. public func GetInteractionMetaInfo(object clonk) @@ -119,6 +125,10 @@ public func GetInteractionMetaInfo(object clonk) // Called on player interaction. public func Interact(object clonk) { + // Should not happen: not active -> stop interaction + if (!dlg_interact) + return true; + // Currently in a dialogue: abort that dialogue. if (InDialogue(clonk)) clonk->CloseMenu(); @@ -147,9 +157,7 @@ public func Interact(object clonk) var progress = dlg_progress; dlg_progress++; // Then call relevant functions. - Call(Format("Dlg_%s_%d", dlg_name, progress), clonk); - - + Call(Format("Dlg_%s_%d", dlg_name, progress), clonk); return true; } @@ -176,11 +184,11 @@ private func MessageBox(string message, object clonk, object talker) // Add NPC portrait. //var portrait = Format("%i", talker->GetID()); //, Dialogue, talker->GetColor(), "1"); - clonk->AddMenuItem("", "", Dialogue, nil, nil, nil, C4MN_Add_ImgObject, talker); //TextSpec); + clonk->AddMenuItem("", "MenuOK", Dialogue, nil, clonk, nil, C4MN_Add_ImgObject, talker); //TextSpec); // Add NPC message. var msg = Format("%s: %s", talker->GetColor(), talker->GetName(), message); - clonk->AddMenuItem(msg, "", nil, nil, nil, nil, C4MN_Add_ForceNoDesc); + clonk->AddMenuItem(msg, "MenuOK", nil, nil, clonk, nil, C4MN_Add_ForceNoDesc); // Add answers. //for (var i = 0; i < GetLength(message.Answers); i++) @@ -203,6 +211,13 @@ private func MessageBox(string message, object clonk, object talker) return; } +public func MenuOK(proplist menu_id, object clonk) +{ + // prevent the menu from closing when pressing MenuOK + if (dlg_interact) + Interact(clonk); +} + local ActMap = { Dialogue = { Prototype = Action,