// overwrite a field script with one imported from an embedded text file public static void ImportScript(FileSource fieldSource, string fieldName, int entity, int script, string importPath) { var field = FieldScript.FromSource(fieldSource, fieldName); field.ReplaceScript(entity, script, App.ReadEmbeddedFile(importPath)); field.SaveToSource(fieldSource, fieldName); }
// delete a single script public static void DeleteScript(FileSource fieldSource, string fieldName, int entity, int script) { var field = FieldScript.FromSource(fieldSource, fieldName); field.ReplaceScript(entity, script, ""); field.SaveToSource(fieldSource, fieldName); }
public static void Apply(FileSource fieldSource, Dictionary <int, int> shuffle) { // take a script from the start field var scriptField = "start0"; var scriptEntity = 0; var scriptId = 0; var script = App.ReadEmbeddedFile(string.Format("Sleepey.Maelstrom.FieldScripts.{0}.{1}.{2}.txt", scriptField, scriptEntity, scriptId)); // move cards to their assigned decks foreach (var card in shuffle.Keys) { script += Environment.NewLine + SetCard(shuffle[card], card); } // save the script var field = FieldScript.FromSource(fieldSource, scriptField); field.ReplaceScript(scriptEntity, scriptId, script); field.SaveToSource(fieldSource, scriptField); }
private static void GiveFieldReward(FileSource fieldSource, int encounterID, int opCode, int[] args, string message) { var boss = Boss.Encounters[encounterID]; var fieldPath = FieldScript.GetFieldPath(boss.FieldID); var innerSource = new FileSource(fieldPath, fieldSource); // add message var msdPath = Path.Combine(fieldPath, boss.FieldID + Globals.MessageFileExtension); var fieldText = MessageFile.FromSource(innerSource, msdPath); var msgID = fieldText.Messages.Count; fieldText.Messages.Add(message); // give reward var field = FieldScript.FromSource(fieldSource, boss.FieldID); var script = field.Entities[boss.FieldEntity].Scripts[boss.FieldScript]; var index = script.Instructions.FindLastIndex(i => i.OpCode == FieldScript.OpCodesReverse["battle"]) + 1; var awardInstructions = new List <FieldScriptInstruction>(); var push = FieldScript.OpCodesReverse["pshn_l"]; foreach (var a in args) { awardInstructions.Add(new FieldScriptInstruction(push, a)); } awardInstructions.Add(new FieldScriptInstruction(opCode)); // show message awardInstructions.Add(new FieldScriptInstruction(push, 0)); awardInstructions.Add(new FieldScriptInstruction(push, msgID)); awardInstructions.Add(new FieldScriptInstruction(push, 70)); awardInstructions.Add(new FieldScriptInstruction(push, 70)); awardInstructions.Add(new FieldScriptInstruction(FieldScript.OpCodesReverse["amesw"])); // apply changes script.Instructions.InsertRange(index, awardInstructions); innerSource.ReplaceFile(msdPath, fieldText.Encode()); innerSource.ReplaceFile(FieldScript.GetFieldPath(boss.FieldID) + "\\" + boss.FieldID + Globals.ScriptFileExtension, field.Encode()); }
public static void Apply(FileSource fieldSource, Dictionary <int, int> shuffle) { var musicOps = new int[] { FieldScript.OpCodesReverse["setbattlemusic"], FieldScript.OpCodesReverse["musicload"] }; // load list of scripts to search for music changes var scripts = MusicLoads.Select(m => new Tuple <string, int, int>(m.FieldName, m.Entity, m.Script)).ToList(); // add any extra changes from free roam boss clouds scripts.AddRange(Boss.Bosses.Where(b => !string.IsNullOrEmpty(b.FieldID)).Select(b => new Tuple <string, int, int>(b.FieldID, b.FieldEntity, b.FieldScript))); // remove duplicates scripts = scripts.Distinct().ToList(); // search all these scripts & replace the music IDs with random ones foreach (var fieldName in scripts.Select(s => s.Item1).Distinct()) { var field = FieldScript.FromSource(fieldSource, fieldName); foreach (var s in scripts.Where(s => s.Item1 == fieldName)) { var script = field.Entities[s.Item2].Scripts[s.Item3]; for (int i = 0; i < script.Instructions.Count; i++) { if (musicOps.Contains(script.Instructions[i].OpCode) && i > 0) { // update the previous instruction (where the track ID is pushed onto the stack) var prevParam = script.Instructions[i - 1].Param; if (shuffle.ContainsKey(prevParam)) { field.Entities[s.Item2].Scripts[s.Item3].Instructions[i - 1].Param = shuffle[prevParam]; } } } } field.SaveToSource(fieldSource, fieldName); } }
public static void Apply(FileSource fieldSource, Dictionary <int, int> shuffle) { // take a script from the start field var scriptField = "start0"; var scriptEntity = 0; var scriptId = 0; var script = App.ReadEmbeddedFile(string.Format("FF8Mod.Maelstrom.FieldScripts.{0}.{1}.{2}.txt", scriptField, scriptEntity, scriptId)); // move cards to their assigned decks foreach (var card in shuffle.Keys) { // if you getcard before you setcard, it reveals the location in the card menu // script += Environment.NewLine + GetCard(i); script += Environment.NewLine + SetCard(shuffle[card], card); } // save the script var field = FieldScript.FromSource(fieldSource, scriptField); field.ReplaceScript(scriptEntity, scriptId, script); StorySkip.SaveToSource(fieldSource, scriptField, field.Encode()); // todo: put this somewhere more sensible }