예제 #1
0
 public Cmd(CustomStringReader sR)
 {
     for (int i = 0; i < unk_count; i++)
     {
         byte   index   = byte.Parse(sR.ReadWord());
         ushort hi_prob = ushort.Parse(sR.ReadWord());
         ushort lw_prob = ushort.Parse(sR.ReadWord());
         unks[i] = new Unk(index, hi_prob, lw_prob);
     }
 }
예제 #2
0
        public attack_data(uint cmn_subs, uint spc_subs, string attackDir)
        {
            common_subactions  = cmn_subs;
            special_subactions = spc_subs;
            CustomStringReader sReader = new CustomStringReader(File.ReadAllText(attackDir), "attack_data.txt");

            try
            {
                List <attack> atks = new List <attack>();
                while (true)
                {
                    attack atk          = new attack();
                    string subactionStr = sReader.ReadWord();
                    if (subactionStr == null)
                    {
                        break;
                    }
                    atk.subaction = ushort.Parse(subactionStr);
                    sReader.ReadUntilAnyOfChars("[", true);
                    atk.start = ushort.Parse(sReader.ReadWord());
                    sReader.ReadUntilAnyOfChars(",", true);
                    atk.end = ushort.Parse(sReader.ReadWord());
                    sReader.ReadUntilAnyOfChars("[", true);
                    atk.x1 = float.Parse(sReader.ReadWord());
                    sReader.ReadUntilAnyOfChars(",", true);
                    atk.x2 = float.Parse(sReader.ReadWord());
                    sReader.ReadUntilAnyOfChars(",", true);
                    atk.y1 = float.Parse(sReader.ReadWord());
                    sReader.ReadUntilAnyOfChars(",", true);
                    atk.y2 = float.Parse(sReader.ReadWord());
                    sReader.SkipToEndLine();
                    atks.Add(atk);
                }
                attacks = atks.ToArray();
                count   = (uint)attacks.Length;
            }
            catch (Exception e)
            {
                throw new Exception(sReader.ExceptionMsg(e.Message), e);
            }
        }
예제 #3
0
            public Situation(CustomStringReader sReader)
            {
                flags = 0;
                string word = sReader.ReadWord();

                if (word == null)
                {
                    string pre = sReader.ReadChar();
                    if (pre == "!")
                    {
                        flags |= 0x1;
                        word   = sReader.ReadWord();
                    }
                }
                condition0 = (byte)checks.IndexOf(word);
                string op = sReader.ReadIfSymbols();

                if (op != "&&")
                {
                    if (op == "||")
                    {
                        flags |= 0x4;
                    }
                    else
                    {
                        throw new Exception("ERROR: invalid logical operator '" + op + "'");
                    }
                }
                word = sReader.ReadWord();
                if (word == null)
                {
                    string pre = sReader.ReadChar();
                    if (pre == "!")
                    {
                        flags |= 0x2;
                        word   = sReader.ReadWord();
                    }
                }
                condition1 = (byte)checks.IndexOf(word);
                string post = sReader.ReadChar();

                if (post != ":")
                {
                    if (post == ";")
                    {
                        flags |= 0x8;
                    }
                    else
                    {
                        throw new Exception("ERROR: invalid character '" + post + "'");
                    }
                }
                //actions:
                List <action> ls = new List <action>();

                while (true)
                {
                    action action      = new action();
                    int    oldPosition = sReader.Position;
                    string firstWord   = sReader.ReadWord();
                    if (byte.TryParse(firstWord, out action.hi_rank_prob))
                    {
                        action.lw_rank_prob = byte.Parse(sReader.ReadWord());
                        action.max_rank     = byte.Parse(sReader.ReadWord());
                        action.min_rank     = byte.Parse(sReader.ReadWord());
                        action.act          = ushort.Parse(sReader.ReadWord(), System.Globalization.NumberStyles.HexNumber);
                        ls.Add(action);
                    }
                    else
                    {
                        sReader.Position = oldPosition;
                        break;
                    }
                }
                actions = ls.ToArray();
                count   = (byte)actions.Length;
            }
예제 #4
0
        public param(string val_dir, string flg_dir, string cmd_dir, string sit1_dir, string sit2_dir, string sit3_dir)
        {
            unk_size = 0xf;//this is the same for all files so I'm not adding it to disassembly until I know what it is
            string[] values = File.ReadAllLines(val_dir);
            for (int i = 0; i < val_count; i++)
            {
                vals[i] = sbyte.Parse(values[i]);
            }
            string[] flags = File.ReadAllLines(flg_dir);
            for (int i = 0; i < flg_count; i++)
            {
                this.flags[i] = byte.Parse(flags[i]);
            }
            //parse cmd file
            CustomStringReader sReader = new CustomStringReader(File.ReadAllText(cmd_dir), "section_3.txt");

            try
            {
                for (int i = 0; i < cmd_count; i++)
                {
                    string word = sReader.ReadWord();
                    sReader.SkipToEndLine();
                    cmds[i] = new Cmd(sReader);
                }
                //parse situation files
                List <Situation> ls        = new List <Situation>();
                byte             sit_index = 0;
                foreach (string sit_dir in new string[] { sit1_dir, sit2_dir, sit3_dir })
                {
                    if (sit_dir == sit1_dir)
                    {
                        sit_return_start = sit_index;
                    }
                    else if (sit_dir == sit2_dir)
                    {
                        sit_attack_start = sit_index;
                    }
                    else if (sit_dir == sit3_dir)
                    {
                        sit_defend_start = sit_index;
                    }
                    sReader.Source = File.ReadAllText(sit_dir);
                    sReader.name   = sit_dir;
                    while (true)
                    {
                        string word = sReader.ReadWord();
                        if (word != "if")
                        {
                            if (word == null)
                            {
                                break;              //end of file
                            }
                            else
                            {
                                throw new Exception("ERROR: expected 'if', received '" + word + "'");
                            }
                        }
                        ls.Add(new Situation(sReader));
                        sit_index++;
                    }
                    if (sit_dir == sit1_dir)
                    {
                        sit_return_end = (byte)(sit_index - 1);
                    }
                    else if (sit_dir == sit2_dir)
                    {
                        sit_attack_end = (byte)(sit_index - 1);
                    }
                    else if (sit_dir == sit3_dir)
                    {
                        sit_defend_end = (byte)(sit_index - 1);
                    }
                }
                sits = ls.ToArray();
            }
            catch (Exception e)
            {
                throw new Exception(sReader.ExceptionMsg(e.Message), e);
            }
        }