ObjectSpawn() публичный статический Метод

public static ObjectSpawn ( character c ) : byte[]
c character
Результат byte[]
Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Drop System Base
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void SkillDrop(obj o, character c, string type)
        {
            try
            {
                world_item sitem = new world_item();
                switch (type)
                {
                case "mask":
                    sitem.Model     = 10364;
                    sitem.Ids       = new Global.ID(Global.ID.IDS.World);
                    sitem.UniqueID  = sitem.Ids.GetUniqueID;
                    sitem.PlusValue = 0;
                    sitem.x         = this.x + rnd.Next(0, 7);
                    sitem.z         = this.z;
                    sitem.y         = this.y + rnd.Next(0, 6);
                    sitem.xSec      = this.xSec;
                    sitem.ySec      = this.ySec;
                    sitem.Type      = 3;
                    sitem.fromType  = 5;
                    sitem.downType  = true;
                    sitem.fromOwner = this.UniqueID;
                    sitem.Owner     = ((Systems)this.GetTarget()).Character.Account.ID;

                    Systems.aRound(ref sitem.x, ref sitem.y, 0);
                    Systems.WorldItem.Add(sitem);
                    sitem.Send(Packet.ObjectSpawn(sitem), true);
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Skill drop error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Пример #2
0
        /////////////////////////////////////////////////////////////////////////////////
        // Spawn system
        /////////////////////////////////////////////////////////////////////////////////
        public void ObjectSpawnCheck()
        {
            try
            {
                if (this.Character.deSpawning)
                {
                    return;
                }
                int spawnrange = 80;
                lock (this)
                {
                    //Make sure character info is not null or not spawning yet allready.
                    if (this.Character != null && !this.Character.Spawning)
                    {
                        //Set spawn state to true so cannot be doubled
                        this.Character.Spawning = true;

                        //Repeat for each client ingame
                        #region Clients
                        for (int i = 0; i < Systems.clients.Count; i++)
                        {
                            //Get defined information for the client
                            Systems playerspawn = Systems.clients[i];
                            //Make sure that the spawning case is not ourselfs, or not spawned yet and not null
                            if (playerspawn != null && playerspawn != this && !Character.Spawned(playerspawn.Character.Information.UniqueID) && playerspawn.Character.Information.Name != this.Character.Information.Name)
                            {
                                //If our position is lower or higher then 50 + spawnrange of that of the player
                                if (playerspawn.Character.Position.x >= (Character.Position.x - 50) && playerspawn.Character.Position.x <= ((Character.Position.x - 50) + spawnrange) && playerspawn.Character.Position.y >= (Character.Position.y - 50) && playerspawn.Character.Position.y <= ((Character.Position.y - 50) + spawnrange))
                                {
                                    //Make sure the unique id is not null
                                    if (playerspawn.Character.Information.UniqueID != 0)
                                    {
                                        Character.Spawn.Add(playerspawn.Character.Information.UniqueID);
                                        client.Send(Packet.ObjectSpawn(playerspawn.Character));
                                    }
                                    //Spawn ourselfs to the other players currently in spawn range.
                                    ObjectPlayerSpawn(playerspawn);
                                }
                            }
                        }
                        #endregion
                        //Repeat for each helper object
                        #region Helper objects
                        for (int i = 0; i < Systems.HelperObject.Count; i++)
                        {
                            //If the helper object is not null , or not spawned for us yet and the unique id is not null
                            if (Systems.HelperObject[i] != null && !Systems.HelperObject[i].Spawned(this.Character.Information.UniqueID))
                            {
                                //If our position is lower or higher then 50 + spawnrange of that of the object
                                if (this.Character.Position.x >= (Systems.HelperObject[i].x - 50) && this.Character.Position.x <= ((Systems.HelperObject[i].x - 50) + spawnrange) && this.Character.Position.y >= (Systems.HelperObject[i].y - 50) && this.Character.Position.y <= ((Systems.HelperObject[i].y - 50) + spawnrange))
                                {
                                    if (Systems.HelperObject[i].UniqueID != 0)
                                    {
                                        //Add our spawn
                                        Systems.HelperObject[i].Spawn.Add(this.Character.Information.UniqueID);
                                        //Send visual packet
                                        this.client.Send(Packet.ObjectSpawn(Systems.HelperObject[i]));
                                    }
                                }
                            }
                        }
                        #endregion

                        /*
                         #region Special objects
                         * for (int i = 0; i < Systems.SpecialObjects.Count; i++)
                         * {
                         *  //If the special object is not null , or not spawned for us yet and the unique id is not null
                         *  if (Systems.SpecialObjects[i] != null && !Systems.SpecialObjects[i].Spawned(this.Character.Information.UniqueID))
                         *  {
                         *      //If our position is lower or higher then 50 + spawnrange of that of the object
                         *      if (this.Character.Position.x >= (Systems.SpecialObjects[i].x - 50) && this.Character.Position.x <= ((Systems.SpecialObjects[i].x - 50) + spawnrange) && this.Character.Position.y >= (Systems.SpecialObjects[i].y - 50) && this.Character.Position.y <= ((Systems.SpecialObjects[i].y - 50) + spawnrange))
                         *      {
                         *          if (Systems.SpecialObjects[i].UniqueID != 0)
                         *          {
                         *              //Add our spawn
                         *              Systems.SpecialObjects[i].Spawn.Add(this.Character.Information.UniqueID);
                         *              //Send visual packet
                         *              client.Send(Packet.ObjectSpawn(Systems.SpecialObjects[i]));
                         *              //Console.WriteLine("Spawning {0}", Data.ObjectBase[Systems.Objects[i].ID].Name);
                         *          }
                         *      }
                         *  }
                         * }
                         #endregion
                         */
                        //Repeat for each object
                        #region Objects
                        for (int i = 0; i < Systems.Objects.Count; i++)
                        {
                            //If the helper object is not null , or not spawned for us yet and the unique id is not null
                            if (Systems.Objects[i] != null && !Systems.Objects[i].Spawned(this.Character.Information.UniqueID))
                            {
                                //If our position is lower or higher then 50 + spawnrange of that of the object
                                if (this.Character.Position.x >= (Systems.Objects[i].x - 50) && this.Character.Position.x <= ((Systems.Objects[i].x - 50) + spawnrange) && this.Character.Position.y >= (Systems.Objects[i].y - 50) && this.Character.Position.y <= ((Systems.Objects[i].y - 50) + spawnrange))
                                {
                                    if (Systems.Objects[i].UniqueID != 0 && !Systems.Objects[i].Die)
                                    {
                                        //Add our spawn
                                        Systems.Objects[i].Spawn.Add(this.Character.Information.UniqueID);
                                        //Send visual packet
                                        client.Send(Packet.ObjectSpawn(Systems.Objects[i]));
                                        //Console.WriteLine("Spawning {0}", Data.ObjectBase[Systems.Objects[i].ID].Name);
                                    }
                                }
                            }
                        }
                        #endregion
                        //Repeat for each world item
                        #region Helper objects
                        for (int i = 0; i < Systems.WorldItem.Count; i++)
                        {
                            //If the helper object is not null , or not spawned for us yet and the unique id is not null
                            if (Systems.WorldItem[i] != null && !Systems.WorldItem[i].Spawned(this.Character.Information.UniqueID))
                            {
                                //If our position is lower or higher then 50 + spawnrange of that of the object
                                if (this.Character.Position.x >= (Systems.WorldItem[i].x - 50) && this.Character.Position.x <= ((Systems.WorldItem[i].x - 50) + spawnrange) && this.Character.Position.y >= (Systems.WorldItem[i].y - 50) && this.Character.Position.y <= ((Systems.WorldItem[i].y - 50) + spawnrange))
                                {
                                    if (Systems.WorldItem[i].UniqueID != 0)
                                    {
                                        //Add our spawn
                                        Systems.WorldItem[i].Spawn.Add(this.Character.Information.UniqueID);
                                        //Send visual packet
                                        this.client.Send(Packet.ObjectSpawn(Systems.WorldItem[i]));
                                    }
                                }
                            }
                        }
                        #endregion
                        //If we are riding a horse and its not spawned to the player yet
                        #region Transports
                        if (Character.Transport.Right)
                        {
                            //If not spawned
                            if (!Character.Transport.Spawned)
                            {
                                //Set bool true
                                Character.Transport.Spawned = true;
                                //Spawn horse object
                                Character.Transport.Horse.SpawnMe();
                                //Send visual update player riding horse
                                Character.Transport.Horse.Send(Packet.Player_UpToHorse(this.Character.Information.UniqueID, true, Character.Transport.Horse.UniqueID));
                            }
                        }
                        #endregion
                        //Reset bool to false so we can re-loop the function
                        this.Character.Spawning = false;
                        ObjectDeSpawnCheck();
                    }
                    //If something wrong happened and we are null, we set our bool false as well.
                    this.Character.Spawning = false;
                }
            }
            catch (Exception ex)
            {
                //If any exception happens we disable the loop bool for re-use
                this.Character.Spawning = false;
                Console.WriteLine("Spawn check error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Пример #3
0
        public void MonsterDrop()
        {
            try
            {
                if (this.GetDie || this.Die)
                {
                    if (this.Type != 16)
                    {
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // Set Target Information
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        Systems sys = (Systems)this.GetTarget();
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        // If There's no target return
                        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                        if (sys == null)
                        {
                            return;
                        }

                        sbyte Leveldiff  = (sbyte)(sys.Character.Information.Level - Data.ObjectBase[ID].Level);
                        int   Amountinfo = 0;

                        if (Math.Abs(Leveldiff) < 10 || Math.Abs(Leveldiff) == 0)
                        {
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Gold Drop
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Gold
                            int Golddrop = rnd.Next(Data.LevelGold[Data.ObjectBase[ID].Level].min, Data.LevelGold[Data.ObjectBase[ID].Level].max);
                            Amountinfo = 0;
                            if (this.Type == 4 && (rnd.Next(0, 200) < 200 * Systems.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(rnd.Next(1, 3));
                            }
                            if (this.Type == 3 && (rnd.Next(0, 200) < 200 * Systems.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(rnd.Next(4, 6));
                            }
                            if (this.Type == 1 && (rnd.Next(0, 200) < 200 * Systems.Rate.Gold))
                            {
                                Amountinfo = Convert.ToByte(rnd.Next(1, 3));
                            }
                            if (this.Type == 0 && (rnd.Next(0, 200) < 100 * Systems.Rate.Gold))
                            {
                                Amountinfo = 1;
                            }

                            for (byte a = 1; a <= Amountinfo;)
                            {
                                world_item Gold_Drop = new world_item();

                                Gold_Drop.amount = Golddrop * Systems.Rate.Gold;
                                Gold_Drop.Model  = 1;

                                if (Gold_Drop.amount < 1000)
                                {
                                    Gold_Drop.Model = 1;
                                }
                                else if (Gold_Drop.amount > 1000 && Gold_Drop.amount < 10000)
                                {
                                    Gold_Drop.Model = 2;
                                }
                                else if (Gold_Drop.amount > 10000)
                                {
                                    Gold_Drop.Model = 3;
                                }

                                Gold_Drop.Ids      = new Global.ID(Global.ID.IDS.World);
                                Gold_Drop.UniqueID = Gold_Drop.Ids.GetUniqueID;
                                Gold_Drop.x        = this.x + rnd.Next(0, 7);
                                Gold_Drop.z        = this.z;
                                Gold_Drop.y        = this.y + rnd.Next(0, 7);
                                Gold_Drop.xSec     = this.xSec;
                                Gold_Drop.ySec     = this.ySec;
                                Gold_Drop.Type     = 1;
                                Gold_Drop.downType = true;
                                Gold_Drop.fromType = 5;

                                Systems.aRound(ref Gold_Drop.x, ref Gold_Drop.y, 0);
                                Systems.WorldItem.Add(Gold_Drop);
                                Gold_Drop.Send(Packet.ObjectSpawn(Gold_Drop), true);
                                a++;

                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                // Send Info To Grabpet
                                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                                if (((Systems)this.GetTarget()).Character.Grabpet.Active)
                                {
                                    ((Systems)this.GetTarget()).Pet_PickupItem(Gold_Drop);
                                }
                            }
                            #endregion
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            // Drop Database
                            ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                            #region Drop Databases
                            foreach (KeyValuePair <string, DarkEmu_GameServer.Global.drop_database> p in Data.DropBase)
                            {
                                Amountinfo = p.Value.GetAmount(Data.ObjectBase[ID].Type, p.Key);
                                if (Amountinfo > 0)
                                {
                                    for (byte c = 1; c <= Amountinfo; c++)
                                    {
                                        world_item Dropped_Item = new world_item();
                                        Dropped_Item.Model = p.Value.GetDrop(Data.ObjectBase[this.ID].Level, this.ID, p.Key, sys.Character.Information.Race);
                                        if (Dropped_Item.Model == -1)
                                        {
                                            continue;
                                        }
                                        Dropped_Item.Ids       = new Global.ID(Global.ID.IDS.World);
                                        Dropped_Item.UniqueID  = Dropped_Item.Ids.GetUniqueID;
                                        Dropped_Item.PlusValue = Function.Items.RandomPlusValue();
                                        Dropped_Item.MagAtt    = Function.Items.RandomStatValue();
                                        Dropped_Item.x         = this.x + rnd.Next(0, 11);
                                        Dropped_Item.z         = this.z;
                                        Dropped_Item.y         = this.y + rnd.Next(0, 11);
                                        Dropped_Item.xSec      = this.xSec;
                                        Dropped_Item.ySec      = this.ySec;
                                        Dropped_Item.Type      = p.Value.GetSpawnType(p.Key);
                                        Dropped_Item.fromType  = 5;
                                        Dropped_Item.downType  = true;
                                        Dropped_Item.fromOwner = this.UniqueID;
                                        Dropped_Item.amount    = p.Value.GetQuantity(this.Type, p.Key);
                                        Dropped_Item.Owner     = ((Systems)this.GetTarget()).Character.Account.ID;
                                        Systems.WorldItem.Add(Dropped_Item);
                                        Dropped_Item.Send(Packet.ObjectSpawn(Dropped_Item), true);
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Drop system error: {0}", ex);
            }
        }