예제 #1
0
        public ToonState GetState()
        {
            var statePtrVal = MemoryReader.ReadIntPtr(EngineAddr + gameStateOffset);

            var state = new ToonState();

            state.GlobalData   = MemoryReader.ReadInt16Array(statePtrVal + gameGlobalDataOffset, GameGlobalDataSize);
            state.flagData     = MemoryReader.ReadBytes(statePtrVal + gameFlagOffset, GameFlagDataSize);
            state.CurrentScene = MemoryReader.ReadInt16(statePtrVal + currentSceneOffset);
            var numInventoryItems = MemoryReader.ReadInt32(statePtrVal + numInventoryItemsOffset);

            state.Inventory = MemoryReader.ReadInt16Array(statePtrVal + inventoryOffset, (uint)numInventoryItems);
            var numConfiscatedItems = MemoryReader.ReadInt32(statePtrVal + numConfiscatedInventoryItemsOffset);

            state.ConfiscatedInventory = MemoryReader.ReadInt16Array(statePtrVal + confiscatedInventoryOffset, (uint)numConfiscatedItems);
            return(state);
        }
예제 #2
0
        private void process()
        {
            string line = "";
            string arg  = "";

            while (this.Reader.Peek() > 0)
            {
                line = this.Reader.ReadLine().TrimStart(new char[] { '\t', ' ' });
                if (line.StartsWith("#"))
                {
                    try
                    {
                        arg = line.Substring(line.IndexOf('<') + 1, line.IndexOf('>') - line.IndexOf('<') - 1);
                    }
                    catch (Exception)
                    {
                    }                     // preprocess that don't have args
                }
                #region ifclass
                if (line.StartsWith("#ifclass "))
                {
                    if (!this.conditions.Peek())
                    {
                        this.conditions.Push(false);
                        continue;
                    }

                    //this.conditions.Push(arg.ToLower().Equals(MyPlayer.Me.PlayerClass.ToString().ToLower()));
                    string strCurrentClass = ObjectManager.Instance.Player.Class.ToString().ToUpper();
                    bool   push            = false;

                    if (arg.IndexOf(",") > -1)
                    {
                        string[] sconditions = arg.Split(','); //<class1,class2,class3,ect>

                        foreach (string strClass in sconditions)
                        {
                            if (strClass.Trim().ToUpper() == strCurrentClass)
                            {
                                push = true;
                            }
                        }
                    }
                    else
                    {
                        if (arg.Trim().ToUpper() == strCurrentClass) //<class>
                        {
                            push = true;
                        }
                    }

                    this.conditions.Push(push);
                }
                #endregion
                #region ifrace
                else if (line.StartsWith("#ifrace "))
                {
                    if (!this.conditions.Peek())
                    {
                        this.conditions.Push(false);
                        continue;
                    }

                    //this.conditions.Push(arg.ToLower().Equals(MyPlayer.Me.PlayerRace.ToString().ToLower()));

                    string strCurrentRace = ObjectManager.Instance.Player.Race.ToUpper();
                    bool   push           = false;

                    if (arg.IndexOf(",") > -1)
                    {
                        string[] sconditions = arg.Split(','); //<zone1,zone2,zone3,ect>

                        foreach (string strRace in sconditions)
                        {
                            if (strRace.Trim().ToUpper() == strCurrentRace)
                            {
                                push = true;
                            }
                        }
                    }
                    else
                    {
                        if (arg.Trim().ToUpper() == strCurrentRace) //<zone>
                        {
                            push = true;
                        }
                    }

                    this.conditions.Push(push);
                }
                #endregion
                #region iflevelrange
                else if (line.StartsWith("#iflevelrange "))
                {
                    if (!this.conditions.Peek())
                    {
                        this.conditions.Push(false);
                        continue;
                    }

                    string[] slevels = arg.Split(','); // <min,max>
                    bool     push    = false;

                    if (slevels.Length == 2)
                    {
                        int[] levels = { int.Parse(slevels[0]), int.Parse(slevels[1]) };
                        if (levels[1] > levels[0])
                        {
                            if (ObjectManager.Instance.Player.Level >= levels[0] &&
                                ObjectManager.Instance.Player.Level <= levels[1])
                            {
                                push = true;
                            }
                        }
                    }

                    this.conditions.Push(push);
                }
                #endregion
                #region ifkeyequals
                else if (line.StartsWith("#ifkeyequals "))
                {
                    if (!this.conditions.Peek())
                    {
                        this.conditions.Push(false);
                        continue;
                    }

                    ToonState state = new ToonState();
                    bool      push  = false;

                    if (arg.IndexOf(",") > -1)
                    {
                        string[] sconditions  = arg.Split(','); // <Key,Status[|Status]>
                        string   strKey       = sconditions[0];
                        string   strKeyStatus = state.Get(strKey.Trim());
                        if (strKeyStatus != null)
                        {
                            if (sconditions[1].IndexOf("|") > -1)
                            {
                                string[] strKeyStatuses = sconditions[1].Split('|');

                                for (int i = 0; i <= strKeyStatuses.Length - 1; i++)
                                {
                                    if (strKeyStatuses[i].Trim() == strKeyStatus)
                                    {
                                        push = true;
                                    }
                                }
                            }
                            else
                            {
                                if (strKeyStatus.Trim() == sconditions[1].Trim())
                                {
                                    push = true;
                                }
                            }
                        }
                        else
                        {
                            if (sconditions[1].Trim() == "NotExists")
                            {
                                push = true;
                            }
                        }
                    }
                    else
                    {
                        if (state.Get(arg.Trim()) != null)
                        {
                            push = true;
                        }
                    }

                    this.conditions.Push(push);
                }
                #endregion
                #region ifzone
                else if (line.StartsWith("#ifzone "))
                {
                    if (!this.conditions.Peek())
                    {
                        this.conditions.Push(false);
                        continue;
                    }

                    string strCurrentZone = ObjectManager.Instance.Player.RealZoneText.Trim().ToUpper();
                    bool   push           = false;

                    if (arg.IndexOf(",") > -1)
                    {
                        string[] sconditions = arg.Split(','); //<zone1,zone2,zone3,ect>

                        foreach (string strZone in sconditions)
                        {
                            if (strZone.Trim().ToUpper() == strCurrentZone)
                            {
                                push = true;
                            }
                        }
                    }
                    else
                    {
                        if (arg.Trim().ToUpper() == strCurrentZone) //<zone>
                        {
                            push = true;
                        }
                    }

                    this.conditions.Push(push);
                }
                #endregion
                else if (this.conditions.Peek() && line.StartsWith("#include "))
                {
                    new Preprocessor(arg, this.lines, this.conditions);
                }
                else if (line.Equals("#endif"))
                {
                    this.conditions.Pop();
                }
                else if (this.conditions.Peek())
                {
                    this.lines.Add(line);
                }
            }
        }