/////////////////////////////////////////////////////////////////////////////////
 // Get matching degree stones for item
 /////////////////////////////////////////////////////////////////////////////////
 public List <int> GetStonesDegree(int itemid, WorldMgr.character c)
 {
     try
     {
         List <int> stones = new List <int>();
         for (int i = 0; i < ObjData.Manager.ItemBase.Length; i++)
         {
             if (ObjData.Manager.ItemBase[i] != null)
             {
                 if (ObjData.Manager.ItemBase[i].Etctype == ObjData.item_database.EtcType.STONES && ObjData.Manager.ItemBase[i].Degree == ObjData.Manager.ItemBase[itemid].Degree)
                 {
                     if (i != 0)
                     {
                         stones.Add(i);
                     }
                 }
             }
         }
         return(stones);
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(null);
 }
 /////////////////////////////////////////////////////////////////////////////////
 // Get matching degree elements for item
 /////////////////////////////////////////////////////////////////////////////////
 public List <int> GetDegreeElements(int itemid, WorldMgr.character c)
 {
     try
     {
         List <int> elements = new List <int>();
         for (int i = 0; i < ObjData.Manager.ItemBase.Length; i++)
         {
             if (ObjData.Manager.ItemBase[i] != null)
             {
                 if (ObjData.Manager.ItemBase[i].Etctype == ObjData.item_database.EtcType.ELEMENTS && ObjData.Manager.ItemBase[i].Degree == ObjData.Manager.ItemBase[itemid].Degree)
                 {
                     if (i != 0)
                     {
                         elements.Add(i);
                     }
                 }
             }
         }
         return(elements);
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
     return(null);
 }
        public void GotoPlayer(character Player, double distance)
        {
            try
            {
                StopMovement();

                float farkx = Player.Position.x + 1; // later have to modify
                float farky = Player.Position.y + 1;
                //Systems.aRound(ref Player.aRound, ref farkx, ref farky);

                xSec = (byte)((farkx / 192) + 135);
                ySec = (byte)((farky / 192) + 92);

                //don't follow the player into the town.
                bool inTown = ObjData.Manager.safeZone.Exists(
                    delegate(ObjData.region r)
                {
                    if (r.SecX == xSec && r.SecY == ySec)
                    {
                        return(true);
                    }
                    return(false);
                });

                Send(Client.Packet.Movement(new ObjData.vektor(UniqueID,
                                                               (float)Formule.packetx((float)farkx, Player.Position.xSec),
                                                               (float)Player.Position.z,
                                                               (float)Formule.packety((float)farky, Player.Position.ySec),
                                                               xSec,
                                                               ySec)));

                if (inTown)
                {
                    AttackStop();
                    Attacking = false;

                    GetDie = true;
                    Die    = true;
                    DeSpawnMe();

                    return;
                }

                // Keep track of the current position of the mob.
                wx = farkx - x;
                wy = farky - y;
                // Calc for time if mob follows initalise speed info Run
                WalkingTime  = (distance / (RunningSpeed * 0.0768)) * 1000.0;
                RecordedTime = WalkingTime;

                StartMovement((int)(WalkingTime / 10));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
 public static bool CheckGuildMemberAdd(WorldMgr.character c)
 {
     foreach (int member in c.Network.Guild.Members)
     {
         if (member == c.Information.CharacterID)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 5
0
        public static byte GetAmmoSlot(WorldMgr.character ch)
        {
            DB   ms   = new DB("SELECT * FROM char_items WHERE owner='" + ch.Information.CharacterID + "' AND (itemid='62' OR itemid='3655' OR itemid='10376' OR itemid='10727')");
            byte ammo = 0;

            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    ammo = reader.GetByte(5);
                }
                ms.Close();
                return(Convert.ToByte(ammo));
            }
        }
Exemplo n.º 6
0
        /////////////////////////////////////////////////////////////////////////////////
        // Get player inventory items (We will use this for stacking and checking).
        // So herer's the simple one ive made we can use to check player inventory
        /////////////////////////////////////////////////////////////////////////////////
        public static List <byte> GetPlayerItems(WorldMgr.character c)
        {
            List <byte> items = new List <byte>();
            DB          ms    = new DB("SELECT * FROM char_items WHERE owner='" + c.Information.CharacterID + "'");

            using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
            {
                while (reader.Read())
                {
                    items.Add(reader.GetByte(5));
                }
            }
            ms.Close();
            return(items);
        }
Exemplo n.º 7
0
 public void CheckCharStats(WorldMgr.character ch)
 {
     //Wrap our code inside a catcher
     try
     {
         //Stats checks
         if (ch.Stat.AttackPower < 0)
         {
             Math.Abs(ch.Stat.AttackPower);
         }
         if (ch.Stat.Hit < 0)
         {
             Math.Abs(ch.Stat.Hit);
         }
         if (ch.Stat.MagDef < 0)
         {
             Math.Abs(ch.Stat.MagDef);
         }
         if (ch.Stat.PhyDef < 0)
         {
             Math.Abs(ch.Stat.PhyDef);
         }
         if (ch.Stat.MinPhyAttack < 0)
         {
             Math.Abs(ch.Stat.MinPhyAttack);
         }
         if (ch.Stat.MinMagAttack < 0)
         {
             Math.Abs(ch.Stat.MinMagAttack);
         }
         if (ch.Stat.MaxPhyAttack < 0)
         {
             Math.Abs(ch.Stat.MaxPhyAttack);
         }
         if (ch.Stat.MaxMagAttack < 0)
         {
             Math.Abs(ch.Stat.MaxMagAttack);
         }
         if (ch.Information.XP < 0)
         {
             Math.Abs(ch.Information.XP);
         }
     }
     catch (Exception ex)
     {
         Log.Exception(ex);
     }
 }
 //When player logs off
 public void RemoveMeFromGuildDisconnect(WorldMgr.guild g, WorldMgr.character c)
 {
     //Repeat for each client in members of guild
     foreach (SRClient member in g.MembersClient)
     {
         //Make sure the client is not null
         if (member != null)
         {
             //Make sure the client is not the one of the player that logs off
             if (member != client)
             {
                 //Send packet to client
                 member.Send(Packet.GuildUpdate(c, 6, 0, 0, 0));
             }
         }
     }
 }
        void LoadTicket(WorldMgr.character c)
        {
            //We wrap our function inside a catcher
            try
            {
                //First we get our data from the database.
                DB ms = new DB("SELECT * FROM character_tickets WHERE owner ='" + c.Information.CharacterID + "' AND active='1'");
                //Check if we have a active ticket
                int CheckActive = ms.Count();

                //Now if we have one active we continue
                if (CheckActive == 1)
                {
                    //Open new sql data reader
                    using (SqlDataReader reader = ms.Read())
                    {
                        //While sql data reader is reading
                        while (reader.Read())
                        {
                            //Set our ticket to active so they cannot use double premium tickets
                            Character.Premium.Active = true;
                            //We can use Character.Information.CharacterID but on safe side we read from db to make sure.
                            Character.Premium.OwnerID = reader.GetInt32(1);
                            //Get the id information to calculate the % gaining and type etc etc..
                            Character.Premium.TicketItemID = reader.GetInt32(2);
                            //Get unique id (incase we need it).
                            Character.Premium.TicketID = reader.GetInt32(0);
                            //Get the start time of the ticket
                            Character.Premium.StartTime = reader.GetDateTime(3);
                        }
                    }
                    //Close our data reader
                    ms.Close();
                    //Calculate remaining time left.
                    TimeSpan Timecheck     = Convert.ToDateTime(Character.Premium.StartTime) - DateTime.Now;
                    double   TimeRemaining = Timecheck.TotalMinutes;
                    //Finally we send our packet to the user (Icon).
                    client.Send(Packet.PremiumTicketData(Character.Premium.TicketItemID, Convert.ToInt32(TimeRemaining)));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public void LoginScreen()
        {
            //Wrap our function inside a catcher
            try
            {
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                string name = Reader.Text();
                Reader.Close();
                //Anti hack checking sql query
                DB ms = new DB("SELECT name FROM character WHERE account='" + Player.AccountName + "' AND name='" + name + "'");
                //Check if the player account and character belongs together (count row).
                int checkinfo = ms.Count();
                //If there's no result
                if (checkinfo == 0)
                {
                    //Disconnect the user if hack attempt
                    client.Disconnect(client.clientSocket);
                    return;
                }
                //If there's a result we continue loading
                else
                {

                    //Create new character definition details
                    Character = new WorldMgr.character();
                    //Set character name
                    Character.Information.Name = name;
                    //Set player id
                    Character.Account.ID = Player.ID;
                    //Load player data
                    PlayerDataLoad();
                    Character.Ids = new GenerateUniqueID(Character.Information.CharacterID, GenerateUniqueID.IDS.Player);
                    Character.Information.UniqueID = Character.Ids.GetUniqueID;

                    //Load job data
                    LoadJobData();
                    //Check same character
                    checkSameChar(name, Character.Information.UniqueID);
                    //Check character stats
                    CheckCharStats(Character);
                    //Add new cient
                    lock (Helpers.Manager.clients)
                    {
                        Helpers.Manager.clients.Add(this);
                    }
                    //Send packets required
                    client.Send(Packet.LoginScreen());
                    client.Send(Packet.StartPlayerLoad());
                    client.Send(Packet.CharacterDataLoad(Character));
                    client.Send(Packet.EndPlayerLoad());
                    client.Send(Packet.PlayerUnknowPack(Character.Information.UniqueID));
                    //client.Send(Packet.UnknownPacket()); //need to research this packet.
                    //Update online status
                    DB.query("UPDATE character SET online='1' WHERE id='" + Character.Information.CharacterID + "'");
                    //Update server information
                    Brain.ServerMgr.UpdateServerInfo();
                    //Open our timer
                    OpenTimer();
                    Character.InitializeCharacter();
                    //Load blue data
                    LoadBlues(Character);

                    #region equipped items
                    List<ObjData.slotItem> EquipedItems = new List<ObjData.slotItem>();
                    //For each equiped item add
                    for (byte q = 0; q < 13; q++)
                    {
                        EquipedItems.Add(GetItem((uint)Character.Information.CharacterID, q, 0));
                    }
                    /*
                    //Load default values for resistance
                    #region Load Resistance default values
                    Character.Blues.Luck = 100;
                    Character.Blues.Resist_All = 100;
                    Character.Blues.Resist_Burn = 100;
                    Character.Blues.Resist_CSMP = 100;
                    Character.Blues.Resist_Disease = 100;
                    Character.Blues.Resist_Eshock = 100;
                    Character.Blues.Resist_Fear = 100;
                    Character.Blues.Resist_Frostbite = 100;
                    Character.Blues.Resist_Poison = 100;
                    Character.Blues.Resist_Sleep = 100;
                    Character.Blues.Resist_Stun = 100;
                    Character.Blues.Resist_Zombie = 100;
                    Character.Blues.MonsterIgnorance = 100;
                    Character.Blues.UniqueDMGInc = 100;
                    #endregion
                    */
                    //Load blues for each item
                    foreach (ObjData.slotItem sitem in EquipedItems)
                    {
                        if (ObjData.Manager.ItemBlue.ContainsKey(sitem.dbID))
                        {
                            LoadBluesid(sitem.dbID);
                            if (ObjData.Manager.ItemBlue[sitem.dbID].totalblue != 0)
                                AddRemoveBlues(this, sitem, true);
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public void GotoPlayer(character Player, double distance)
        {
            try
            {
                StopMovement();

                float farkx = Player.Position.x + 1; // later have to modify
                float farky = Player.Position.y + 1;
                //Systems.aRound(ref Player.aRound, ref farkx, ref farky);

                xSec = (byte)((farkx / 192) + 135);
                ySec = (byte)((farky / 192) + 92);

                //don't follow the player into the town.
                bool inTown = ObjData.Manager.safeZone.Exists(
                    delegate (ObjData.region r)
                    {
                        if (r.SecX == xSec && r.SecY == ySec)
                        {
                            return true;
                        }
                        return false;
                    });

                Send(Client.Packet.Movement(new ObjData.vektor(UniqueID,
                    (float)Formule.packetx((float)farkx, Player.Position.xSec),
                    (float)Player.Position.z,
                    (float)Formule.packety((float)farky, Player.Position.ySec),
                    xSec,
                    ySec)));

                if (inTown)
                {
                    AttackStop();
                    Attacking = false;

                    GetDie = true;
                    Die = true;
                    DeSpawnMe();

                    return;
                }

                // Keep track of the current position of the mob.
                wx = farkx - x;
                wy = farky - y;
                // Calc for time if mob follows initalise speed info Run
                WalkingTime = (distance / (RunningSpeed * 0.0768)) * 1000.0;
                RecordedTime = WalkingTime;

                StartMovement((int)(WalkingTime / 10));
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
Exemplo n.º 12
0
        public void LoginScreen()
        {
            //Wrap our function inside a catcher
            try
            {
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                string       name   = Reader.Text();
                Reader.Close();
                //Anti hack checking sql query
                DB ms = new DB("SELECT name FROM character WHERE account='" + Player.AccountName + "' AND name='" + name + "'");
                //Check if the player account and character belongs together (count row).
                int checkinfo = ms.Count();
                //If there's no result
                if (checkinfo == 0)
                {
                    //Disconnect the user if hack attempt
                    client.Disconnect(client.clientSocket);
                    return;
                }
                //If there's a result we continue loading
                else
                {
                    //Create new character definition details
                    Character = new WorldMgr.character();
                    //Set character name
                    Character.Information.Name = name;
                    //Set player id
                    Character.Account.ID = Player.ID;
                    //Load player data
                    PlayerDataLoad();
                    Character.Ids = new GenerateUniqueID(Character.Information.CharacterID, GenerateUniqueID.IDS.Player);
                    Character.Information.UniqueID = Character.Ids.GetUniqueID;

                    //Load job data
                    LoadJobData();
                    //Check same character
                    checkSameChar(name, Character.Information.UniqueID);
                    //Check character stats
                    CheckCharStats(Character);
                    //Add new cient
                    lock (Helpers.Manager.clients)
                    {
                        Helpers.Manager.clients.Add(this);
                    }
                    //Send packets required
                    client.Send(Packet.LoginScreen());
                    client.Send(Packet.StartPlayerLoad());
                    client.Send(Packet.CharacterDataLoad(Character));
                    client.Send(Packet.EndPlayerLoad());
                    client.Send(Packet.PlayerUnknowPack(Character.Information.UniqueID));
                    //client.Send(Packet.UnknownPacket()); //need to research this packet.
                    //Update online status
                    DB.query("UPDATE character SET online='1' WHERE id='" + Character.Information.CharacterID + "'");
                    //Update server information
                    Brain.ServerMgr.UpdateServerInfo();
                    //Open our timer
                    OpenTimer();
                    Character.InitializeCharacter();
                    //Load blue data
                    LoadBlues(Character);

                    #region equipped items
                    List <ObjData.slotItem> EquipedItems = new List <ObjData.slotItem>();
                    //For each equiped item add
                    for (byte q = 0; q < 13; q++)
                    {
                        EquipedItems.Add(GetItem((uint)Character.Information.CharacterID, q, 0));
                    }

                    /*
                     * //Load default values for resistance
                     #region Load Resistance default values
                     * Character.Blues.Luck = 100;
                     * Character.Blues.Resist_All = 100;
                     * Character.Blues.Resist_Burn = 100;
                     * Character.Blues.Resist_CSMP = 100;
                     * Character.Blues.Resist_Disease = 100;
                     * Character.Blues.Resist_Eshock = 100;
                     * Character.Blues.Resist_Fear = 100;
                     * Character.Blues.Resist_Frostbite = 100;
                     * Character.Blues.Resist_Poison = 100;
                     * Character.Blues.Resist_Sleep = 100;
                     * Character.Blues.Resist_Stun = 100;
                     * Character.Blues.Resist_Zombie = 100;
                     * Character.Blues.MonsterIgnorance = 100;
                     * Character.Blues.UniqueDMGInc = 100;
                     #endregion
                     */
                    //Load blues for each item
                    foreach (ObjData.slotItem sitem in EquipedItems)
                    {
                        if (ObjData.Manager.ItemBlue.ContainsKey(sitem.dbID))
                        {
                            LoadBluesid(sitem.dbID);
                            if (ObjData.Manager.ItemBlue[sitem.dbID].totalblue != 0)
                            {
                                AddRemoveBlues(this, sitem, true);
                            }
                        }
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }