From 7c09b7533572277116487600745983947c0e9c89 Mon Sep 17 00:00:00 2001 From: Brad Hannah <47454550+bradhannah@users.noreply.github.com> Date: Sun, 7 Jan 2024 20:24:34 -0500 Subject: [PATCH] chore: adding gotoif logic for codex --- Ultima5Redux/DataFiles/CutSceneScripts.csv | 29 +- Ultima5Redux/DataFiles/CutSceneScripts.json | 250 +++++++++++------- .../ScriptTurnResults/Goto.cs | 5 +- Ultima5Redux/Maps/CutSceneMap.cs | 39 ++- Ultima5Redux/State/ShrineStates.cs | 17 +- 5 files changed, 227 insertions(+), 113 deletions(-) diff --git a/Ultima5Redux/DataFiles/CutSceneScripts.csv b/Ultima5Redux/DataFiles/CutSceneScripts.csv index 617db62..d1d6fb9 100644 --- a/Ultima5Redux/DataFiles/CutSceneScripts.csv +++ b/Ultima5Redux/DataFiles/CutSceneScripts.csv @@ -5,7 +5,6 @@ MapNum,FrameNum,Command,StrParam,IntParam,X,Y,Visible,Comment 1,0,Comment,,0,0,0,false,"---- Shrine of Virtue Cut Scene" 1,0,Output,"
Thou dost approach the tranquil Shrine...",0,0,0,false,"" 1,0,CreateMapunit,avatar,332,5,10,false,"off camera" -1,0,CreateMapunit,avatar,65,5,2,true,"Codex of Ultimate Wisdom" 1,1,MoveMapunit,avatar,0,5,10,false,"off camera" 1,1,SoundEffect,WalkOnGrass,1,0,0,false,"Heard off camera" 1,1,Pause,,500,0,0,false,"" @@ -141,16 +140,10 @@ MapNum,FrameNum,Command,StrParam,IntParam,X,Y,Visible,Comment 2,100,OutputModalText,"The Codex of Ultima Wisdom lies before thee...",0,0,0,false 2,101,OutputModalText,"The book is open to the page thou dost seek",0,0,0,false 2,102,OutputModalText,"Upon the hallowed page thou dost read:",0,0,0,false -2,103,OutputModalText,_CodexVirtueText,0,0,0,false, -2,104,ScreenEffect,InvertColors,1,0,0,false,"Invert the Colours" -2,104,SoundEffect,EarthQuake,1,0,0,false,"Start the rumble!" -2,104,ScreenEffect,ShakeScreen,1,0,0,false,"Earthquake!" -2,105,Pause,,3000,0,0,false,"Hold Tight" -2,106,ScreenEffect,InvertColors,0,0,0,false,"Uninvert Colors" -2,106,SoundEffect,EarthQuake,0,0,0,false,"Start the rumble!" -2,106,ScreenEffect,ShakeScreen,0,0,0,false,"Earthquake!" -2,107,OutputModalText,"A STRANGE WIND CAUSES THE PAGE TO TURN!",0,0,0,false -2,108,Goto,,200,0,0,false,"Go to leaving section" +2,102,GotoIf,ShrineStatus_QuestNotStarted_All,500,0,0,false,"If none have started - then you shouldn't be here!" +2,102,GotoIf,ShrineStatus_ShrineOrdainedNoCodex_Any,300,0,0,false,"You can ordain a quest and change to ShrineOrdainedWithCodex" +2,102,GotoIf,ShrineStatus_ShrineOrdainedWithCodex_Any,300,0,0,false,"Just repeat what you said before" +2,102,GotoIf,ShrineStatus_ShrineCompleted_All,500,0,0,false,"If all are complete - then you should not be able to pass guardians!" 2,200,MoveMapunit,avatar,0,5,4,true,"off camera" 2,201,SoundEffect,WalkOnGrass,1,0,0,false,"Leaving" 2,201,Pause,,500,0,0,false,"" @@ -176,3 +169,17 @@ MapNum,FrameNum,Command,StrParam,IntParam,X,Y,Visible,Comment 2,208,SoundEffect,WalkOnGrass,1,0,0,false,"walking in grass" 2,208,Pause,,500,0,0,false,"" 2,209,EndSequence,,0,0,0,false,end of scene2 +2,300,Comment,,0,0,0,false,"You have a shrine that is not ordained!" +2,300,OutputModalText,_CodexVirtueText,0,0,0,false, +2,301,ScreenEffect,InvertColors,1,0,0,false,"Invert the Colours" +2,301,SoundEffect,EarthQuake,1,0,0,false,"Start the rumble!" +2,301,ScreenEffect,ShakeScreen,1,0,0,false,"Earthquake!" +2,302,Pause,,3000,0,0,false,"Hold Tight" +2,303,ScreenEffect,InvertColors,0,0,0,false,"Uninvert Colors" +2,303,SoundEffect,EarthQuake,0,0,0,false,"Start the rumble!" +2,303,ScreenEffect,ShakeScreen,0,0,0,false,"Earthquake!" +2,304,OutputModalText,"A STRANGE WIND CAUSES THE PAGE TO TURN!",0,0,0,false +2,305,Goto,,200,0,0,false,"Go to leaving section" +2,500,Comment,,0,0,0,false,"You shouldn't be here!" +2,500,OutputModalText,"HOW DID YOU GET HERE?",0,0,0,false,"Let them know this is not right!" +2,501,Goto,,200,0,0,false,"time to leave" \ No newline at end of file diff --git a/Ultima5Redux/DataFiles/CutSceneScripts.json b/Ultima5Redux/DataFiles/CutSceneScripts.json index db1cc3b..20ada60 100644 --- a/Ultima5Redux/DataFiles/CutSceneScripts.json +++ b/Ultima5Redux/DataFiles/CutSceneScripts.json @@ -62,16 +62,6 @@ "Visible": false, "Comment": "off camera" }, - { - "FrameNum": 0, - "Command": "CreateMapunit", - "StrParam": "avatar", - "IntParam": 65, - "X": 5, - "Y": 2, - "Visible": true, - "Comment": "Codex of Ultimate Wisdom" - }, { "FrameNum": 1, "Command": "MoveMapunit", @@ -1425,104 +1415,44 @@ "Comment": "" }, { - "FrameNum": 103, - "Command": "OutputModalText", - "StrParam": "_CodexVirtueText", - "IntParam": 0, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "" - }, - { - "FrameNum": 104, - "Command": "ScreenEffect", - "StrParam": "InvertColors", - "IntParam": 1, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "Invert the Colours" - }, - { - "FrameNum": 104, - "Command": "SoundEffect", - "StrParam": "EarthQuake", - "IntParam": 1, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "Start the rumble!" - }, - { - "FrameNum": 104, - "Command": "ScreenEffect", - "StrParam": "ShakeScreen", - "IntParam": 1, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "Earthquake!" - }, - { - "FrameNum": 105, - "Command": "Pause", - "StrParam": "", - "IntParam": 3000, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "Hold Tight" - }, - { - "FrameNum": 106, - "Command": "ScreenEffect", - "StrParam": "InvertColors", - "IntParam": 0, - "X": 0, - "Y": 0, - "Visible": false, - "Comment": "Uninvert Colors" - }, - { - "FrameNum": 106, - "Command": "SoundEffect", - "StrParam": "EarthQuake", - "IntParam": 0, + "FrameNum": 102, + "Command": "GotoIf", + "StrParam": "ShrineStatus_QuestNotStarted_All", + "IntParam": 500, "X": 0, "Y": 0, "Visible": false, - "Comment": "Start the rumble!" + "Comment": "If none have started - then you shouldn't be here!" }, { - "FrameNum": 106, - "Command": "ScreenEffect", - "StrParam": "ShakeScreen", - "IntParam": 0, + "FrameNum": 102, + "Command": "GotoIf", + "StrParam": "ShrineStatus_ShrineOrdainedNoCodex_Any", + "IntParam": 300, "X": 0, "Y": 0, "Visible": false, - "Comment": "Earthquake!" + "Comment": "You can ordain a quest and change to ShrineOrdainedWithCodex" }, { - "FrameNum": 107, - "Command": "OutputModalText", - "StrParam": "A STRANGE WIND CAUSES THE PAGE TO TURN!", - "IntParam": 0, + "FrameNum": 102, + "Command": "GotoIf", + "StrParam": "ShrineStatus_ShrineOrdainedWithCodex_Any", + "IntParam": 300, "X": 0, "Y": 0, "Visible": false, - "Comment": "" + "Comment": "Just repeat what you said before" }, { - "FrameNum": 108, - "Command": "Goto", - "StrParam": "", - "IntParam": 200, + "FrameNum": 102, + "Command": "GotoIf", + "StrParam": "ShrineStatus_ShrineCompleted_All", + "IntParam": 500, "X": 0, "Y": 0, "Visible": false, - "Comment": "Go to leaving section" + "Comment": "If all are complete - then you should not be able to pass guardians!" }, { "FrameNum": 200, @@ -1773,6 +1703,146 @@ "Y": 0, "Visible": false, "Comment": "end of scene2" + }, + { + "FrameNum": 300, + "Command": "Comment", + "StrParam": "", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "You have a shrine that is not ordained!" + }, + { + "FrameNum": 300, + "Command": "OutputModalText", + "StrParam": "_CodexVirtueText", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "" + }, + { + "FrameNum": 301, + "Command": "ScreenEffect", + "StrParam": "InvertColors", + "IntParam": 1, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Invert the Colours" + }, + { + "FrameNum": 301, + "Command": "SoundEffect", + "StrParam": "EarthQuake", + "IntParam": 1, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Start the rumble!" + }, + { + "FrameNum": 301, + "Command": "ScreenEffect", + "StrParam": "ShakeScreen", + "IntParam": 1, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Earthquake!" + }, + { + "FrameNum": 302, + "Command": "Pause", + "StrParam": "", + "IntParam": 3000, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Hold Tight" + }, + { + "FrameNum": 303, + "Command": "ScreenEffect", + "StrParam": "InvertColors", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Uninvert Colors" + }, + { + "FrameNum": 303, + "Command": "SoundEffect", + "StrParam": "EarthQuake", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Start the rumble!" + }, + { + "FrameNum": 303, + "Command": "ScreenEffect", + "StrParam": "ShakeScreen", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Earthquake!" + }, + { + "FrameNum": 304, + "Command": "OutputModalText", + "StrParam": "A STRANGE WIND CAUSES THE PAGE TO TURN!", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "" + }, + { + "FrameNum": 305, + "Command": "Goto", + "StrParam": "", + "IntParam": 200, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Go to leaving section" + }, + { + "FrameNum": 500, + "Command": "Comment", + "StrParam": "", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "You shouldn't be here!" + }, + { + "FrameNum": 500, + "Command": "OutputModalText", + "StrParam": "HOW DID YOU GET HERE?", + "IntParam": 0, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "Let them know this is not right!" + }, + { + "FrameNum": 501, + "Command": "Goto", + "StrParam": "", + "IntParam": 200, + "X": 0, + "Y": 0, + "Visible": false, + "Comment": "time to leave" } ] } \ No newline at end of file diff --git a/Ultima5Redux/MapUnits/TurnResults/SpecificTurnResults/ScriptTurnResults/Goto.cs b/Ultima5Redux/MapUnits/TurnResults/SpecificTurnResults/ScriptTurnResults/Goto.cs index e77da6c..d3617d0 100644 --- a/Ultima5Redux/MapUnits/TurnResults/SpecificTurnResults/ScriptTurnResults/Goto.cs +++ b/Ultima5Redux/MapUnits/TurnResults/SpecificTurnResults/ScriptTurnResults/Goto.cs @@ -11,10 +11,11 @@ public class Goto : CutOrIntroSceneScriptLineTurnResult { [SuppressMessage("ReSharper", "InconsistentNaming")] public enum GotoCondition { None, BadMantra, ShrineStatus_QuestNotStarted, ShrineStatus_ShrineOrdainedNoCodex, - ShrineStatus_ShrineOrdainedWithCodex, ShrineStatus_ShrineCompleted, HasNotEnoughMoney, GaveNoMoney + ShrineStatus_ShrineOrdainedWithCodex, ShrineStatus_ShrineCompleted, HasNotEnoughMoney, GaveNoMoney, + ShrineStatus_QuestNotStarted_All, ShrineStatus_ShrineOrdainedNoCodex_Any, + ShrineStatus_ShrineOrdainedWithCodex_Any, ShrineStatus_ShrineCompleted_All } - public Goto(CutOrIntroSceneScriptLine scriptLine) : base(TurnResultType.Script_GotoIf, TurnResulActionType.ActionRequired, scriptLine) { if (scriptLine.Command is not CutOrIntroSceneScriptLine.CutOrIntroSceneScriptLineCommand.Goto diff --git a/Ultima5Redux/Maps/CutSceneMap.cs b/Ultima5Redux/Maps/CutSceneMap.cs index bf34781..94c2602 100644 --- a/Ultima5Redux/Maps/CutSceneMap.cs +++ b/Ultima5Redux/Maps/CutSceneMap.cs @@ -160,14 +160,23 @@ public class CutSceneMap : Map : null; private int ProcessGoto(Goto gotoResult) { - if ((gotoResult.TheGotoCondition.ToString().StartsWith("ShrineStatus_") && ShrineCutSceneState == null) || - ShrineCutSceneState.CurrentShrine == null) { + string gotoConditionStr = gotoResult.TheGotoCondition.ToString(); + bool bStartsValidPrefix = gotoConditionStr.StartsWith("ShrineStatus_"); + bool bEndRequiresNoShrine = gotoConditionStr.ToLower().EndsWith("_any") || + gotoConditionStr.ToLower().EndsWith("_all"); + + ShrineState shrineState = null; + // TODO: ewwww + if (bStartsValidPrefix && bEndRequiresNoShrine) { + _ = ""; + } + else if ((bStartsValidPrefix && ShrineCutSceneState == null) || ShrineCutSceneState.CurrentShrine == null) { throw new Ultima5ReduxException( "For ShrineStatus_ type GotoCondition, expected shrine state to have already been tracked."); } - - ShrineState shrineState = GetShrineState(ShrineCutSceneState.CurrentShrine - .VirtueRef.Virtue); + else { + shrineState = GetShrineState(ShrineCutSceneState.CurrentShrine.VirtueRef.Virtue); + } switch (gotoResult.TheGotoCondition) { case Goto.GotoCondition.None: @@ -176,7 +185,6 @@ public class CutSceneMap : Map if (ShrineCutSceneState.GoldDonationState == GoldDonationState.ZeroGoldDonated) { return gotoResult.LineNumber; } - break; case Goto.GotoCondition.HasNotEnoughMoney: // if gold was NOT donated, then we know we didn't have enough @@ -197,19 +205,32 @@ public class CutSceneMap : Map if (shrineState?.TheShrineStatus == ShrineState.ShrineStatus.ShrineOrdainedNoCodex) { return gotoResult.LineNumber; } - break; case Goto.GotoCondition.ShrineStatus_ShrineOrdainedWithCodex: if (shrineState?.TheShrineStatus == ShrineState.ShrineStatus.ShrineOrdainedWithCodex) { return gotoResult.LineNumber; } - break; case Goto.GotoCondition.ShrineStatus_ShrineCompleted: if (shrineState?.TheShrineStatus == ShrineState.ShrineStatus.ShrineCompleted) { return gotoResult.LineNumber; } - + break; + case Goto.GotoCondition.ShrineStatus_QuestNotStarted_All: + if (GameStateReference.State.TheShrineStates.AreNoQuestsStartedYet) + return gotoResult.LineNumber; + break; + case Goto.GotoCondition.ShrineStatus_ShrineOrdainedNoCodex_Any: + if (GameStateReference.State.TheShrineStates.AtLeastOneOrdainedNoCodex) + return gotoResult.LineNumber; + break; + case Goto.GotoCondition.ShrineStatus_ShrineOrdainedWithCodex_Any: + if (GameStateReference.State.TheShrineStates.AtLeastOneOrdainedWithCodex) + return gotoResult.LineNumber; + break; + case Goto.GotoCondition.ShrineStatus_ShrineCompleted_All: + if (GameStateReference.State.TheShrineStates.AllShrinesCompleted) + return gotoResult.LineNumber; break; default: throw new ArgumentOutOfRangeException(); diff --git a/Ultima5Redux/State/ShrineStates.cs b/Ultima5Redux/State/ShrineStates.cs index 1c315ff..57d6fe5 100644 --- a/Ultima5Redux/State/ShrineStates.cs +++ b/Ultima5Redux/State/ShrineStates.cs @@ -1,11 +1,14 @@ using System.Collections.Generic; +using System.Linq; using System.Runtime.Serialization; using Newtonsoft.Json; using Ultima5Redux.References; namespace Ultima5Redux.State { [DataContract] public class ShrineState { - public enum ShrineStatus { QuestNotStarted, ShrineOrdainedNoCodex, ShrineOrdainedWithCodex, ShrineCompleted } + public enum ShrineStatus { + QuestNotStarted = 0, ShrineOrdainedNoCodex = 1, ShrineOrdainedWithCodex = 2, ShrineCompleted = 3 + } // [DataMember] public bool ShrineQuestCompleted { get; set; } [DataMember] public ShrineStatus TheShrineStatus { get; set; } @@ -63,5 +66,17 @@ public enum ShrineStatus { QuestNotStarted, ShrineOrdainedNoCodex, ShrineOrdaine _shrines.Add(virtue, shrineState); } } + + public bool AreNoQuestsStartedYet => + _shrines.All(s => s.Value.TheShrineStatus == ShrineState.ShrineStatus.QuestNotStarted); + + public bool AtLeastOneOrdainedNoCodex => + _shrines.Any(s => s.Value.TheShrineStatus == ShrineState.ShrineStatus.ShrineOrdainedNoCodex); + + public bool AtLeastOneOrdainedWithCodex => + _shrines.Any(s => s.Value.TheShrineStatus == ShrineState.ShrineStatus.ShrineOrdainedWithCodex); + + public bool AllShrinesCompleted => + _shrines.All(s => s.Value.TheShrineStatus == ShrineState.ShrineStatus.ShrineCompleted); } } \ No newline at end of file