public AOFunctions CreateKnuBotFunction(int knubotAction)
 {
     AOFunctions aof = new AOFunctions();
     aof.Arguments.Values.Add(knubotAction);
     aof.TickCount = 1;
     aof.TickInterval = 0;
     aof.FunctionType = this.FunctionNumber;
     return aof;
 }
        public override void CalcTrickle()
        {
            if ((this.Parent is Character) || (this.Parent is NonPlayerCharacterClass))
            {
                Character character = (Character)this.Parent;

                // calculating Nano and Heal Delta and interval
                int healinterval = 29 - Math.Min(character.Stats.Stamina.Value / 30, 27);

                character.Stats.HealInterval.StatBaseValue = (uint)healinterval; // Healinterval

                character.PurgeTimer(0);
                AOFunctions aof = new AOFunctions();
                character.AddTimer(0, DateTime.Now + TimeSpan.FromSeconds(healinterval * 1000), aof, true);

                int sitBonusInterval = 0;
                int healDelta = character.Stats.HealDelta.Value;
                if (character.MoveMode == MoveModes.Sit)
                {
                    sitBonusInterval = 1000;
                    int healDelta2 = healDelta >> 1;
                    healDelta = healDelta + healDelta2;
                }

                character.PurgeTimer(0);
                AOTimers at = new AOTimers();
                at.Strain = 0;
                at.Timestamp = DateTime.Now
                               + TimeSpan.FromMilliseconds(character.Stats.HealInterval.Value * 1000 - sitBonusInterval);
                at.Function.Target = this.Parent.Id; // changed from ItemHandler.itemtarget_self;
                at.Function.TickCount = -2;
                at.Function.TickInterval = (uint)(character.Stats.HealInterval.Value * 1000 - sitBonusInterval);
                at.Function.FunctionType = Constants.FunctiontypeHit;
                at.Function.Arguments.Values.Add(27);
                at.Function.Arguments.Values.Add(healDelta);
                at.Function.Arguments.Values.Add(healDelta);
                at.Function.Arguments.Values.Add(0);
                character.Timers.Add(at);

                if (!this.Parent.Starting)
                {
                    this.AffectStats();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Copy Function
        /// </summary>
        /// <returns>new copy</returns>
        public AOFunctions ShallowCopy()
        {
            AOFunctions newAOF = new AOFunctions();

            foreach (AORequirements aor in this.Requirements)
            {
                AORequirements newAOR = new AORequirements();
                newAOR.ChildOperator = aor.ChildOperator;
                newAOR.Operator      = aor.Operator;
                newAOR.Statnumber    = aor.Statnumber;
                newAOR.Target        = aor.Target;
                newAOR.Value         = aor.Value;
                newAOF.Requirements.Add(newAOR);
            }

            foreach (object ob in Arguments.Values)
            {
                if (ob.GetType() == typeof(string))
                {
                    string z = (string)ob;
                    newAOF.Arguments.Values.Add(z);
                }
                if (ob.GetType() == typeof(int))
                {
                    int i = (int)ob;
                    newAOF.Arguments.Values.Add(i);
                }
                if (ob.GetType() == typeof(Single))
                {
                    Single s = (Single)ob;
                    newAOF.Arguments.Values.Add(s);
                }
            }
            newAOF.dolocalstats = dolocalstats;
            newAOF.FunctionType = FunctionType;
            newAOF.Target       = Target;
            newAOF.TickCount    = TickCount;
            newAOF.TickInterval = TickInterval;

            return(newAOF);
        }
예제 #4
0
        /// <summary>
        /// Copy Function
        /// </summary>
        /// <returns>new copy</returns>
        public AOFunctions ShallowCopy()
        {
            AOFunctions newAOF = new AOFunctions();
            foreach (AORequirements aor in Requirements)
            {
                AORequirements newAOR = new AORequirements();
                newAOR.ChildOperator = aor.ChildOperator;
                newAOR.Operator = aor.Operator;
                newAOR.Statnumber = aor.Statnumber;
                newAOR.Target = aor.Target;
                newAOR.Value = aor.Value;
                newAOF.Requirements.Add(newAOR);
            }

            foreach (object ob in Arguments)
            {
                if (ob.GetType() == typeof (string))
                {
                    string z = (string) ob;
                    newAOF.Arguments.Add(z);
                }
                if (ob.GetType() == typeof (int))
                {
                    int i = (int) ob;
                    newAOF.Arguments.Add(i);
                }
                if (ob.GetType() == typeof (Single))
                {
                    Single s = (Single) ob;
                    newAOF.Arguments.Add(s);
                }
            }
            newAOF.dolocalstats = dolocalstats;
            newAOF.FunctionType = FunctionType;
            newAOF.Target = Target;
            newAOF.TickCount = TickCount;
            newAOF.TickInterval = TickInterval;

            return newAOF;
        }
예제 #5
0
 public void Teleport(int x, int z, int y, int pf, uint delay)
 {
     AOFunctions aof = new AOFunctions();
     aof.Target = this.TalkingTo.Id;
     aof.TickCount = 0;
     aof.TickInterval = 1;
     aof.FunctionType = Constants.FunctiontypeTeleport;
     aof.Arguments.Add(x);
     aof.Arguments.Add(y);
     aof.Arguments.Add(z);
     aof.Arguments.Add(pf);
     this.TalkingTo.AddTimer(20001, DateTime.Now + TimeSpan.FromMilliseconds(delay), aof, false);
 }
예제 #6
0
 public AOFunctions CreateKnuBotFunction(int knubotAction)
 {
     AOFunctions aof = new AOFunctions();
     aof.Arguments.Add(knubotAction);
     aof.TickCount = 1;
     aof.TickInterval = 0;
     aof.FunctionType = 2; // KnuBotActionTimer
     aof.Target = this.Parent.Id;
     return aof;
 }
예제 #7
0
파일: Program.cs 프로젝트: semirs/CellAO
        public static void Convertitems()
        {

            SqlWrapper sql = new SqlWrapper();
            DataTable dt_items = sql.ReadDatatable("SELECT * FROM Items order by aoid asc");

            Stream sf = new FileStream("items.dat", FileMode.Create);

            ZOutputStream ds = new ZOutputStream(sf, zlibConst.Z_BEST_COMPRESSION);
            MemoryStream sm = new MemoryStream();

            //DeflateStream sm = new DeflateStream(sf, CompressionMode.Compress);



            BinaryFormatter bf = new BinaryFormatter();

            Console.WriteLine("Processing data... This will take a while!");
            List<AOItem> ITEMS = new List<AOItem>();
            int count = dt_items.Rows.Count;
            int oldperc = 0;
            int countall = 0;
            byte[] buffer = BitConverter.GetBytes(maxnum);
            sm.Write(buffer, 0, buffer.Length);
            if (File.Exists("items2.dat"))
            {
                ItemHandler.CacheAllItems("items2.dat");
                foreach (AOItem aoi in ItemHandler.ItemList)
                {
                    ITEMS.Add(aoi);
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            else
            {
                foreach (DataRow itemrow in dt_items.Rows)
                {
                    AOItem _item = new AOItem();
                    _item.LowID = (Int32)itemrow[0];
                    _item.HighID = (Int32)itemrow[0];
                    _item.Quality = (Int32)itemrow[2];
                    _item.ItemType = (Int32)itemrow[3];

                    DataTable dt_itemevents = sql.ReadDatatable("SELECT * FROM item_events WHERE itemid=" + _item.LowID + " ORDER BY eventid asc");

                    foreach (DataRow eventrow in dt_itemevents.Rows)
                    {
                        AOEvents aoe = new AOEvents();
                        aoe.EventType = (Int32)eventrow[2];
                        int eventid = (Int32)eventrow["eventid"];

                        DataTable dt_itemeventfunctions = sql.ReadDatatable("SELECT * FROM item_functions WHERE itemid=" + _item.LowID + " AND eventid=" + eventid + " ORDER BY functionid asc");

                        foreach (DataRow eventfunctionrow in dt_itemeventfunctions.Rows)
                        {
                            int eventfuncid = (Int32)eventfunctionrow["functionid"];
                            AOFunctions aof = new AOFunctions();
                            aof.FunctionType = (Int32)eventfunctionrow[3];
                            aof.Target = (Int32)eventfunctionrow[4];
                            aof.TickCount = (Int32)eventfunctionrow[5];
                            aof.TickInterval = (uint)(Int32)eventfunctionrow[6];

                            DataTable functionargs = sql.ReadDatatable("SELECT * FROM item_function_arguments WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND itemid=" + _item.LowID + " ORDER BY attrid asc");

                            foreach (DataRow attrs in functionargs.Rows)
                            {
                                if (!(attrs["argvalint"] is DBNull))
                                {
                                    aof.Arguments.Add((Int32)attrs["argvalint"]);
                                }
                                else
                                    if (!(attrs["argvalsingle"] is DBNull))
                                    {
                                        aof.Arguments.Add((Single)(float)attrs["argvalsingle"]);
                                    }
                                    else
                                        if (!(attrs["argvalstring"] is DBNull))
                                        {
                                            string s = attrs["argvalstring"].ToString();
                                            aof.Arguments.Add(s);
                                        }
                                        else
                                            throw (new NotSupportedException("No Argument value given, all NULL: " + _item.LowID));
                            }

                            DataTable reqs = sql.ReadDatatable("SELECT * from  item_function_reqs WHERE functionid=" + eventfuncid + " AND eventid=" + eventid + " AND itemid=" + _item.LowID + " ORDER BY reqid asc");

                            foreach (DataRow rrow in reqs.Rows)
                            {
                                AORequirements aor = new AORequirements();
                                aor.Statnumber = (Int32)rrow["attrnum"];
                                aor.Value = (Int32)rrow["attrval"];
                                aor.Target = (Int32)rrow["target"];
                                aor.Operator = (Int32)rrow["operator"];
                                aor.ChildOperator = (Int32)rrow["child_op"];
                                aof.Requirements.Add(aor);
                            }

                            aoe.Functions.Add(aof);
                        }

                        _item.Events.Add(aoe);
                    }

                    DataTable dt_actions = sql.ReadDatatable("SELECT * FROM item_actions WHERE itemid=" + _item.LowID);

                    foreach (DataRow acrow in dt_actions.Rows)
                    {
                        AOActions aoa = new AOActions();
                        aoa.ActionType = (Int32)acrow["actionnum"];

                        DataTable reqs = sql.ReadDatatable("SELECT * FROM item_action_reqs WHERE itemid=" + _item.LowID + " AND actionid=" + ((Int32)acrow["actionid"]) + " ORDER BY reqid ASC");

                        foreach (DataRow rrow in reqs.Rows)
                        {
                            AORequirements aor = new AORequirements();
                            aor.Statnumber = (Int32)rrow["attrnum"];
                            aor.Value = (Int32)rrow["attrval"];
                            aor.Target = (Int32)rrow["target"];
                            aor.Operator = (Int32)rrow["operator"];
                            aor.ChildOperator = (Int32)rrow["child_op"];
                            aoa.Requirements.Add(aor);
                        }
                        _item.Actions.Add(aoa);
                    }

                    DataTable dtdef = sql.ReadDatatable("SELECT * FROM item_defense_attributes where itemid=" + _item.LowID + " ORDER BY defenseid asc");

                    foreach (DataRow defrow in dtdef.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable dtatt = sql.ReadDatatable("select * FROM item_attack_attributes where itemid=" + _item.LowID + " ORDER BY attackid asc");
                    foreach (DataRow defrow in dtatt.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)defrow["num"];
                        aoia.Value = (Int32)defrow["value"];
                        _item.Defend.Add(aoia);
                    }

                    DataTable attributes = sql.ReadDatatable("SELECT * FROM item_attributes WHERE itemid=" + _item.LowID + " ORDER BY attributeid asc");
                    foreach (DataRow atrow in attributes.Rows)
                    {
                        AOItemAttribute aoia = new AOItemAttribute();
                        aoia.Stat = (Int32)atrow["num"];
                        aoia.Value = (Int32)atrow["value"];
                        _item.Stats.Add(aoia);
                    }


                    ITEMS.Add(_item);

                    int perc = Convert.ToInt32(Math.Floor((double)(ITEMS.Count + countall) / count * 100.0));
                    if (perc != oldperc)
                    {
                        Console.Write("\rDone " + perc.ToString().PadLeft(3) + "%");
                        oldperc = perc;
                    }
                    if (ITEMS.Count == maxnum)
                    {
                        bf.Serialize(sm, ITEMS);
                        sm.Flush();
                        ITEMS.Clear();
                        countall += maxnum;
                    }
                }
            }
            bf.Serialize(sm, ITEMS);
            sm.Seek(0, SeekOrigin.Begin);
            Console.WriteLine();
            CopyStream(sm, ds);
            sm.Close();
            ds.Close();
        }
예제 #8
0
파일: AOItem.cs 프로젝트: semirs/CellAO
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AOItem ShallowCopy()
        {
            AOItem it = new AOItem();
            it.LowID = this.LowID;
            it.HighID = this.HighID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator = aor.Operator;
                        newAOR.Statnumber = aor.Statnumber;
                        newAOR.Target = aor.Target;
                        newAOR.Value = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments)
                    {
                        if (ob.GetType() == typeof (string))
                        {
                            string z = (string) ob;
                            newAOF.Arguments.Add(z);
                        }
                        if (ob.GetType() == typeof (int))
                        {
                            int i = (int) ob;
                            newAOF.Arguments.Add(i);
                        }
                        if (ob.GetType() == typeof (Single))
                        {
                            Single s = (Single) ob;
                            newAOF.Arguments.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target = aof.Target;
                    newAOF.TickCount = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.Flags = this.Flags;
            it.Instance = Instance;
            it.ItemType = ItemType;
            it.MultipleCount = this.MultipleCount;
            it.Nothing = Nothing;
            it.Quality = Quality;

            return it;
        }
예제 #9
0
 /// <summary>
 /// Deserialization, internal use only
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 public AOTimers(SerializationInfo info, StreamingContext context)
 {
     Strain    = (Int32)info.GetValue("Strain", typeof(Int32));
     Timestamp = (DateTime)info.GetValue("Timestamp", typeof(DateTime));
     Function  = (AOFunctions)info.GetValue("Function", typeof(AOFunctions));
 }
예제 #10
0
        /// Methods to do:
        /// Read Item
        /// Write Item
        /// Return Dynel Item (placing on the ground)
        public AONanos ShallowCopy()
        {
            AONanos it = new AONanos();

            it.ID = ID;

            foreach (AOItemAttribute ai in Attack)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Attack.Add(z);
            }

            foreach (AOItemAttribute ai in Defend)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Defend.Add(z);
            }

            foreach (AOItemAttribute ai in Stats)
            {
                AOItemAttribute z = new AOItemAttribute();
                z.Stat  = ai.Stat;
                z.Value = ai.Value;
                it.Stats.Add(z);
            }

            foreach (AOEvents ev in Events)
            {
                AOEvents newEV = new AOEvents();
                foreach (AOFunctions aof in ev.Functions)
                {
                    AOFunctions newAOF = new AOFunctions();
                    foreach (AORequirements aor in aof.Requirements)
                    {
                        AORequirements newAOR = new AORequirements();
                        newAOR.ChildOperator = aor.ChildOperator;
                        newAOR.Operator      = aor.Operator;
                        newAOR.Statnumber    = aor.Statnumber;
                        newAOR.Target        = aor.Target;
                        newAOR.Value         = aor.Value;
                        newAOF.Requirements.Add(newAOR);
                    }

                    foreach (object ob in aof.Arguments.Values)
                    {
                        if (ob.GetType() == typeof(string))
                        {
                            string z = (string)ob;
                            newAOF.Arguments.Values.Add(z);
                        }
                        if (ob.GetType() == typeof(int))
                        {
                            int i = (int)ob;
                            newAOF.Arguments.Values.Add(i);
                        }
                        if (ob.GetType() == typeof(Single))
                        {
                            Single s = (Single)ob;
                            newAOF.Arguments.Values.Add(s);
                        }
                    }
                    newAOF.dolocalstats = aof.dolocalstats;
                    newAOF.FunctionType = aof.FunctionType;
                    newAOF.Target       = aof.Target;
                    newAOF.TickCount    = aof.TickCount;
                    newAOF.TickInterval = aof.TickInterval;
                    newEV.Functions.Add(newAOF);
                }
                newEV.EventType = ev.EventType;
                it.Events.Add(newEV);
            }


            it.flags    = flags;
            it.Instance = Instance;
            it.ItemType = ItemType;
            it.NCUCost  = NCUCost;

            return(it);
        }
예제 #11
0
파일: AOEvents.cs 프로젝트: semirs/CellAO
        /// <summary>
        /// read from blob, only in there for converting
        /// </summary>
        /// <param name="blob"></param>
        /// <param name="offset"></param>
        /// <returns></returns>
        public int readEventfromBlob(byte[] blob, int offset)
        {
            int c = offset;

            EventType = BitConverter.ToInt32(blob, c);
            c += 4;

            // Read Event Functions
            AOFunctions m_aof;
            int c2 = BitConverter.ToInt32(blob, c);
            c += 4;
            while (c2 > 0)
            {
                m_aof = new AOFunctions();
                c = m_aof.ReadFunctionfromBlob(blob, c);
                Functions.Add(m_aof);
                c2--;
            }
            return c;
        }
예제 #12
0
 /// <summary>
 /// Deserialization, internal use only
 /// </summary>
 /// <param name="info"></param>
 /// <param name="context"></param>
 public AOTimers(SerializationInfo info, StreamingContext context)
 {
     Strain = (Int32) info.GetValue("Strain", typeof (Int32));
     Timestamp = (DateTime) info.GetValue("Timestamp", typeof (DateTime));
     Function = (AOFunctions) info.GetValue("Function", typeof (AOFunctions));
 }