示例#1
0
        public static void SaveToSource(FileSource fieldSource, string fieldName, byte[] fieldCode)
        {
            var fieldPath   = FieldScript.GetFieldPath(fieldName);
            var innerSource = new FileSource(fieldPath, fieldSource);

            innerSource.ReplaceFile(fieldPath + "\\" + fieldName + Globals.ScriptFileExtension, fieldCode);
        }
示例#2
0
        // change the text of a field message
        public static void SetText(FileSource fieldSource, string fieldName, int messageId, string newText)
        {
            var fieldPath   = FieldScript.GetFieldPath(fieldName);
            var msdPath     = Path.Combine(fieldPath, fieldName + Globals.MessageFileExtension);
            var innerSource = new FileSource(fieldPath, fieldSource);
            var fieldText   = MessageFile.FromSource(innerSource, msdPath);

            fieldText.Messages[messageId] = newText;
            innerSource.ReplaceFile(msdPath, fieldText.Encode());
        }
示例#3
0
        public static void CopyParticle(FileSource fieldSource, string srcField, string destField)
        {
            var srcPath    = FieldScript.GetFieldPath(srcField);
            var destPath   = FieldScript.GetFieldPath(destField);
            var srcSource  = new FileSource(srcPath, fieldSource);
            var destSource = new FileSource(destPath, fieldSource);

            destSource.ReplaceFile(Path.Combine(destPath, destField + ".pmd"), srcSource.GetFile(Path.Combine(srcPath, srcField + ".pmd")));
            destSource.ReplaceFile(Path.Combine(destPath, destField + ".pmp"), srcSource.GetFile(Path.Combine(srcPath, srcField + ".pmp")));
            fieldSource.Encode();
        }
示例#4
0
        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());
        }