Esempio n. 1
0
        public static void RemoveOnDisconnect(party p, Systems c)
        {
            //Remove client and member if it contains our removing character
            if (p.Members.Contains(c.Character.Information.UniqueID))
            {
                p.Members.Remove(c.Character.Information.UniqueID);
                p.MembersClient.Remove(c.client);
            }
            //Send packet to each player
            foreach (int member in p.Members)
            {
                Systems playerdetail = GetPlayer(member);

                if (p.Members.Count > 1)
                {
                    playerdetail.client.Send(Packet.Party_Data(1, 0));
                }
                else
                {
                    //Send removal of party
                    playerdetail.client.Send(Packet.Party_Data(3, playerdetail.Character.Information.UniqueID));
                    //Remove party state
                    playerdetail.Character.Network.Party = null;
                }
            }
        }
Esempio n. 2
0
 void CleanUp(Systems c)
 {
     c.Character.Network.Guild.MembersClient.Remove(c.client);
     c.Character.Network.Guild.Members.Remove(c.Character.Information.CharacterID);
     c.Character.Network.Guild.Name = null;
     c.Character.Network.Guild.Level = 0;
     c.Character.Network.Guild.PointsTotal = 0;
     c.Character.Network.Guild.NewsTitle = null;
     c.Character.Network.Guild.NewsMessage = null;
     c.Character.Network.Guild.StorageSlots = 0;
     c.Character.Network.Guild.Wargold = 0;
     c.Character.Network.Guild.StorageGold = 0;
     c.Character.Network.Guild.GuildOwner = 0;
     c.Character.Network.Guild.Guildid = 0;
     c.Character.Network.Guild.GrantName = null;
     c.Character.Network.Guild.FWrank = 0;
     c.Character.Network.Guild.DonateGP = 0;
     c.Character.Network.Guild.LastDonate = 0;
     c.Character.Network.Guild.joinRight = false;
     c.Character.Network.Guild.withdrawRight = false;
     c.Character.Network.Guild.unionRight = false;
     c.Character.Network.Guild.guildstorageRight = false;
     c.Character.Network.Guild.noticeeditRight = false;
     c.Character.Network.Guild.MembersClient = null;
     c.Character.Network.Guild.MembersClient = null;
 }
Esempio n. 3
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Player Disconnect
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void KickPlayer(Systems Target)
        {
            try
            {
                Target.client.Send((Packet.ChatPacket(7, Target.Character.Information.UniqueID, "You Have been kicked!", "")));
                if (Player != null)
                {
                    MsSQL.UpdateData("UPDATE users SET online='" + 0 + "' WHERE id='" + Target.Player.AccountName + "'");
                    MsSQL.UpdateData("UPDATE character SET online=" + 0 + "' WHERE id='" + Target.Character.Information.UniqueID + "'");
                    Target.Player.Dispose();
                    Target.Player = null;
                }
                if (Target.Character != null)
                {
                    if (Target.Character.Transport.Right) Target.Character.Transport.Horse.DeSpawnMe();
                    if (Target.Character.Grabpet.Active) Target.Character.Grabpet.Details.DeSpawnMe();
                    if (Target.Character.Network.Exchange.Window) Target.Exchange_Close();
                    if (Target.Character.State.Sitting) Target.StopSitDownTimer();
                    Target.StopAttackTimer();
                    Target.BuffAllClose();
                    Target.DeSpawnMe();
                    Target.StopMPRegen();
                    Target.StopHPRegen();
                    Target.SavePlayerPosition();
                    Target.SavePlayerInfo();
                    Target.Character.InGame = false;

                    client.Disconnect(Target.client.clientSocket);
                    Target.client.Close();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public void ChangeCrit_cr(Systems Target, int slot, bool delete,bool UpdatePacket)
        {
            if (!delete)
            {

            }
        }
Esempio n. 6
0
        public static byte[] Party_DataMember(party p)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTYMEMBER_DATA);
            //Write static byte
            Writer.Byte(0xFF);
            //Write party id
            Writer.DWord(p.ptid);
            //Write leader id
            Writer.DWord(p.LeaderID);
            //Write byte party type
            Writer.Byte(p.Type);
            //Write total amount of members in party
            Writer.Byte(p.Members.Count);
            //Repeat for each member in party -1
            for (byte b = 0; b <= p.Members.Count - 1; b++)
            {
                //Get player detail information
                Systems PartyMemberInfo = Systems.GetPlayer(p.Members[b]);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondMP * 10) / PartyMemberInfo.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(PartyMemberInfo.Character.Stat.SecondHp * 10) / PartyMemberInfo.Character.Stat.Hp);
                //Set percent
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write static byte
                Writer.Byte(0xff);
                //Write unique member id
                Writer.DWord(PartyMemberInfo.Character.Information.UniqueID);
                //Write character name
                Writer.Text(PartyMemberInfo.Character.Information.Name);
                //Write character model
                Writer.DWord(PartyMemberInfo.Character.Information.Model);
                //Write character level
                Writer.Byte(PartyMemberInfo.Character.Information.Level);
                //Write stat hp mp information
                Writer.Byte((byte)partyPercent);
                //Write x and y sector
                Writer.Byte(PartyMemberInfo.Character.Position.xSec);
                Writer.Byte(PartyMemberInfo.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(PartyMemberInfo.Character.Position.x, PartyMemberInfo.Character.Position.xSec));
                Writer.Word(PartyMemberInfo.Character.Position.z);
                Writer.Word(Formule.packety(PartyMemberInfo.Character.Position.y, PartyMemberInfo.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If player has a guild
                if (PartyMemberInfo.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(PartyMemberInfo.Character.Network.Guild.Name);
                }
                //If player has no guild
                else
                {
                    //Write word 0 value
                    Writer.Word(0);
                }
                //Write static byte
                Writer.Byte(0);
                //Write dword
                Writer.DWord(0);
                Writer.DWord(0);
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Esempio n. 7
0
        private void SpawnUnique(List <string> parameters)
        {
            obj o = new obj();

            switch ((Uniques)Int32.Parse(parameters[0]))
            {
            case Uniques.TigerGirl:     // INSERT SPAWN CODE HERE
                o = getMob(1954, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Urichi:
                o = getMob(1982, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Isyutaru:
                o = getMob(2002, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.LordYarkan:
                o = getMob(3810, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.DemonShaitan:
                o = getMob(3875, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Cerberus:
                o = getMob(5871, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.CapIvy:
                o = getMob(14778, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Medusa:
                o = getMob(14839, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Roc:
                o = getMob(3877, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Neith:
                o = getMob(32768, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Isis:
                o = getMob(32770, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;

            case Uniques.Sphinx:
                o = getMob(32752, parameters);
                Systems.Objects.Add(o);
                o.SpawnMe();
                Systems.SendAll(Packet.Unique_Data(5, (int)o.ID, null));
                break;
            }
        }
Esempio n. 8
0
        public void ChangeTargetHp_cmcr(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["cmcr"] != 0)
                    {
                        int amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["cmcr"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Mp = amount;
                        Target.Character.Stat.Mp -= Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                        Target.Character.Stat.SecondMP -= Target.Character.Action.Buff.UpdatedStats[slot].Mp;

                    }
                }

                else
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["cmcr"] != 0)
                    {
                        Target.Character.Stat.Mp += Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                        Target.Character.Stat.SecondMP += Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                        Target.Character.Action.Buff.UpdatedStats[slot].Mp = 0;
                    }
                }
                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 9
0
 /////////////////////////////////////////////////////////////////////////////////
 // DE-Spawn system (Spawn our char to others).
 /////////////////////////////////////////////////////////////////////////////////    
 void ObjectDePlayerSpawn(Systems s)
 {
     try
     {
         if (s.Character.Spawned(this.Character.Information.UniqueID) && !s.Character.deSpawning)
         {
             if (s.Character.Information.UniqueID != 0)
             {
                 s.ObjectDeSpawnCheck();
             }
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Systems despawn error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 10
0
 void KickFromGuild()
 {
     //Wrap our function inside a catcher
     try
     {
         //Open a new packet reader
         PacketReader Reader = new PacketReader(PacketInformation.buffer);
         //Read short value lenght of name below
         short CharacterNameLen = Reader.Int16();
         //Read string charactername
         string CharacterName = Reader.String(CharacterNameLen);
         //Close packet reader
         Reader.Close();
         //Get player information
         Systems TargetCharacter = GetPlayerName(CharacterName);
         //Send required packets to network
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure member s not null
             if (member != 0)
             {
                 //Get information for the guildmember
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember isnt null
                 if (guildmember != null)
                 {
                     //Make sure the kicked member does not receive the packet
                     if (guildmember.Character.Information.CharacterID != TargetCharacter.Character.Information.CharacterID)
                     {
                         guildmember.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
                     }
                 }
             }
         }
         //Send update packet to the kicked player
         TargetCharacter.client.Send(Packet.GuildUpdate(TargetCharacter.Character, 7, 0, 0, 0));
         //Send guild kick message packet to the kicked player
         PacketWriter Writer = new PacketWriter();
         //Add opcode
         Writer.Create(Systems.SERVER_GUILD_KICK);
         //Add static byte 1
         Writer.Byte(1);
         //Send packet to kicked member
         TargetCharacter.client.Send(Writer.GetBytes());
         //Send guildkick visual packet update to kicked player
         TargetCharacter.Send(Packet.GuildKick(TargetCharacter.Character.Information.UniqueID));
         //Remove the player from database
         MsSQL.UpdateData("DELETE from guild_members where guild_member_id='" + TargetCharacter.Character.Information.CharacterID + "'");
         //Update database
         Character.Network.Guild.TotalMembers -= 1;
         MsSQL.InsertData("UPDATE guild SET guild_members_t='" + Character.Network.Guild.TotalMembers + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         TargetCharacter.CleanUp(TargetCharacter);
     }
     //Catch bad exception errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Guild Kick Error: {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 11
0
        /////////////////////////////////////////////////////////////////////////////////
        // Load our unions
        /////////////////////////////////////////////////////////////////////////////////
        #region Load unions
        public void LoadUnions()
        {
            try
            {
                //First clear out the guild union info (will clean this later).
                if (Character.Network.Guild.Unions != null)
                {
                    Character.Network.Guild.Unions       = null;
                    Character.Network.Guild.UnionMembers = null;
                    Character.Network.Guild.UnionLeader  = 0;
                    Character.Network.Guild.UniqueUnion  = 0;
                }
                //Then we query the row guildid
                int my_union = MsSQL.GetDataInt("SELECT union_unique_id FROM guild_unions WHERE union_guildid='" + Character.Network.Guild.Guildid + "'", "union_unique_id");
                //If 0 means we check if we are the union leaders
                if (my_union == 0)
                {
                    //Check for union leader
                    my_union = MsSQL.GetDataInt("SELECT union_unique_id FROM guild_unions WHERE union_leader='" + Character.Network.Guild.Guildid + "'", "union_unique_id");
                    //If we are the union leader
                    if (my_union > 0)
                    {
                        Character.Network.Guild.UnionLeader = Character.Network.Guild.Guildid;
                    }
                }

                //If union is active so count higher then 0
                if (my_union > 0)
                {
                    MsSQL unions = new MsSQL("SELECT * FROM guild_unions WHERE union_unique_id='" + my_union + "'");
                    //Open new sql data reader
                    using (SqlDataReader reader = unions.Read())
                    {
                        //While our reader is reading the information
                        while (reader.Read())
                        {
                            //Check if we allready have main info loaded
                            //If the union leader isnt the loading guild
                            if (Character.Network.Guild.UnionLeader == 0)
                            {
                                Character.Network.Guild.UnionLeader = reader.GetInt32(1);
                            }
                            //Add union to the listening
                            Character.Network.Guild.Unions.Add(reader.GetInt32(2));
                            //Set union active
                            Character.Network.Guild.UnionActive = true;
                        }
                        // Repeat for each guild in our union
                        foreach (int guild in Character.Network.Guild.Unions)
                        {
                            //Make sure the guild isnt 0
                            if (guild != 0)
                            {
                                //Get guildplayer details
                                Systems unionmember = GetGuildPlayer(guild);
                                //Make sure the player isnt null
                                if (unionmember != null)
                                {
                                    //Then add our character id to the member list.
                                    Character.Network.Guild.UnionMembers.Add(Character.Information.CharacterID);
                                }
                            }
                        }
                        //Close our sql reader.
                        reader.Close();
                    }
                    //Finally send packet for union listening
                    client.Send(Packet.UnionInfo(this));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Union Load Error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 12
0
 void Player_Wait_CallBack(object e)
 {
     try
     {
         if (Character.Information.Quit)
         {
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Position.Walking)
             {
                 Character.Position.RecordedTime = 0;
                 Timer.Movement.Dispose();
                 Timer.Movement = null;
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Information.CheckParty)
             {
                 LeaveParty();
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Network.Guild.Guildid != 0)
             {
                 Character.Information.Online = 0;
                 //Send packets to network and spawned players
                 foreach (int member in Character.Network.Guild.Members)
                 {
                     //Make sure the member is there
                     if (member != 0)
                     {
                         //We dont send this info to the invited user.
                         if (member != Character.Information.CharacterID)
                         {
                             //If the user is not the newly invited member get player info
                             Systems tomember = GetPlayerMainid(member);
                             //Send guild update packet
                             if (tomember != null)
                             {
                                 tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0));
                             }
                         }
                     }
                 }
                 Character.Network.Guild.Members.Remove(Character.Information.CharacterID);
                 Character.Network.Guild.MembersClient.Remove(this.client);
             }
             //##############################################
             // checks before logout
             //##############################################
             if (Character.Transport.Right)
             {
                 Character.Transport.Horse.DeSpawnMe();
             }
             if (Character.Grabpet.Active)
             {
                 UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
             }
             if (Character.Attackpet.Active)
             {
                 UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
             }
             if (Character.Network.Exchange.Window)
             {
                 Exchange_Close();
             }
             //##############################################
             // checks before logout
             //##############################################
             MsSQL ms    = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
             int   count = ms.Count();
             if (count >= 0)
             {
                 using (SqlDataReader reader = ms.Read())
                 {
                     while (reader.Read())
                     {
                         int     getid = reader.GetInt32(2);
                         Systems sys   = GetPlayerid(getid);
                         if (sys != null)
                         {
                             sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, true));
                         }
                     }
                 }
             }
             //##############################################
             // Send packet leave game
             //##############################################
             client.Send(Packet.EndLeaveGame());
             //##############################################
             // Updated database
             //##############################################
             MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");
             //##############################################
             // Remove all remaining parts
             //##############################################
             BuffAllClose();
             DeSpawnMe();
             SavePlayerPosition();
             SavePlayerInfo();
             this.client.Close();
             this.Character.Dispose();
             this.Dispose();
             Character.InGame = false;
             Disconnect("normal");
         }
         Timer.Logout.Dispose();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Logout error: {0}", ex);
     }
 }
Esempio n. 13
0
        /////////////////////////////////////////////////////////////////////////
        //Guild Disbanding
        /////////////////////////////////////////////////////////////////////////
        #region Guild Disband
        void GuildDisband()
        {
            try
            {
                foreach (int member in Character.Network.Guild.Members)
                {
                    if (member != 0)
                    {
                        Systems guildplayer = GetPlayerMainid(member);
                        if (guildplayer != null)
                        {
                            if (guildplayer.Character.Information.CharacterID != Character.Information.CharacterID)
                            {
                                //Guild disband message packet
                                guildplayer.client.Send(Packet.GuildUpdate(Character, 2, 0, 0, 0));
                                //Remove guild name and details from player
                                Send(Packet.GuildKick(guildplayer.Character.Information.UniqueID));
                                //State packet
                                guildplayer.client.Send(Packet.StatePack(guildplayer.Character.Information.UniqueID, 4, 0, false));
                                //Set all values to null.
                                guildplayer.Character.Network.Guild.Members.Remove(guildplayer.Character.Information.CharacterID);
                                guildplayer.Character.Network.Guild.MembersClient.Remove(guildplayer.client);
                                guildplayer.Character.Network.Guild.Guildid = 0;

                                if (guildplayer.Character.Network.Guild.UniqueUnion != 0)
                                {
                                    guildplayer.Character.Network.Guild.UnionActive = false;
                                    guildplayer.Character.Network.Guild.UnionMembers.Remove(guildplayer.Character.Information.CharacterID);
                                }
                            }
                        }
                    }
                }
                //Guild disband message packet
                client.Send(Packet.GuildUpdate(Character, 2, 0, 0, 0));
                //Remove guild name and details from player
                Send(Packet.GuildKick(Character.Information.UniqueID));
                //State packet
                client.Send(Packet.StatePack(Character.Information.UniqueID, 4, 0, false));
                //Set all values to null.

                //Remove all rows that contains guildname
                MsSQL.UpdateData("DELETE FROM guild_members WHERE guild_id=" + Character.Network.Guild.Guildid + "");
                //Remove guild from guild table
                MsSQL.UpdateData("DELETE FROM guild WHERE id=" + Character.Network.Guild.Guildid + "");
                //Remove ourself
                if (Character.Network.Guild.UniqueUnion != 0)
                {
                    Character.Network.Guild.UnionActive = false;
                    Character.Network.Guild.UnionMembers.Remove(Character.Information.CharacterID);
                }

                Character.Network.Guild.Members.Remove(Character.Information.UniqueID);
                Character.Network.Guild.MembersClient.Remove(client);
                Character.Network.Guild.Guildid = 0;

                //Packet Final message
                client.Send(Packet.PromoteOrDisband(1));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Guild Disband Error: {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 14
0
        void Player_Movement(object e)
        {
            try
            {
                if (Character.Position.RecordedTime <= 0)
                {
                    if (Timer.Movement != null)
                    {
                        Timer.Movement.Dispose();
                    }

                    Character.Position.Walking = false;

                    if (Character.Action.PickUping)
                    {
                        Player_PickUpItem();
                    }

                    Character.Position.z = Character.Position.wZ;

                    if (Timer.SpawnWatch.ElapsedMilliseconds >= 10)
                    {
                        ObjectSpawnCheck();
                        Timer.SpawnWatch.Restart();
                    }

                    Movement_CaveTeleport();
                }
                else
                {
                    //If player is in a party send location update packet to each member
                    if (Character.Network.Party != null)
                    {
                        foreach (int member in Character.Network.Party.Members)
                        {
                            if (member != Character.Information.UniqueID)
                            {
                                Systems memberinfo = GetPlayer(member);
                                memberinfo.client.Send(Packet.Party_Data(6, member));
                            }
                        }
                    }

                    if (Character.Action.nAttack)
                    {
                        Character.Position.kX -= (Character.Position.wX * 10) / 100;
                        Character.Position.kY -= (Character.Position.wY * 10) / 100;

                        if (Character.Information.Item.wID != 0)
                        {
                            if (Math.Sqrt(Character.Position.kX * Character.Position.kX + Character.Position.kY * Character.Position.kY) <= Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE)
                            {
                                Character.Position.RecordedTime = 0;

                                if (Character.Action.nAttack)
                                {
                                    ActionAttack();
                                }

                                if (Timer.SpawnWatch.ElapsedMilliseconds >= 150)
                                {
                                    this.ObjectSpawnCheck();
                                    Timer.SpawnWatch.Restart();
                                }

                                Timer.Movement.Dispose();
                                Character.Position.z       = Character.Position.wZ;
                                Character.Action.PickUping = false;
                                Character.Position.Walking = false;
                                return;
                            }
                        }
                        else
                        {
                            if (Math.Sqrt(Character.Position.kX * Character.Position.kX + Character.Position.kY * Character.Position.kY) <= 1)
                            {
                                Character.Position.RecordedTime = 0;

                                if (Character.Action.nAttack)
                                {
                                    ActionAttack();
                                }

                                if (Timer.SpawnWatch.ElapsedMilliseconds >= 1000)
                                {
                                    this.ObjectSpawnCheck();
                                    Timer.SpawnWatch.Restart();
                                }

                                Timer.Movement.Dispose();
                                Character.Position.z       = Character.Position.wZ;
                                Character.Action.PickUping = false;
                                Character.Position.Walking = false;
                                return;
                            }
                        }
                    }
                    else if (Character.Action.sAttack)
                    {
                        Character.Position.kX -= (Character.Position.wX * 10) / 100;
                        Character.Position.kY -= (Character.Position.wY * 10) / 100;
                        double test = Character.Action.Skill.Distance;
                        if (test == 0)
                        {
                            test = Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                        }
                        if (Math.Sqrt(Character.Position.kX * Character.Position.kX + Character.Position.kY * Character.Position.kY) < test)
                        {
                            if (Character.Action.sAttack)
                            {
                                StartSkill();
                            }
                            Character.Position.RecordedTime = 0;
                            Character.aRound = new bool[10];

                            if (Timer.SpawnWatch.ElapsedMilliseconds >= 1000)
                            {
                                this.ObjectSpawnCheck();
                                Timer.SpawnWatch.Restart();
                            }

                            Timer.Movement.Dispose();
                            Character.Position.z       = Character.Position.wZ;
                            Character.Action.PickUping = false;
                            Character.Position.Walking = false;
                            return;
                        }
                    }

                    Character.aRound      = new bool[10];
                    Character.Position.x += (Character.Position.wX * 10) / 100;
                    Character.Position.y += (Character.Position.wY * 10) / 100;

                    if (Character.Transport.Right)
                    {
                        Character.Transport.Horse.x = Character.Position.x;
                        Character.Transport.Horse.y = Character.Position.y;
                    }
                    Character.Position.RecordedTime -= (Character.Position.Time * 0.1);

                    if (Timer.SpawnWatch.ElapsedMilliseconds >= 10)
                    {
                        this.ObjectSpawnCheck();
                        this.ObjectAttackCheck();
                        Timer.SpawnWatch.Restart();
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Move call error: {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 15
0
        public void PingTimerCallBack(object e)
        {
            try
            {
                TimeSpan t = DateTime.Now - lastPing;
                if (client.State)
                {
                    Ping();
                }
                if (!client.State && Player != null)
                {
                    Console.BackgroundColor = ConsoleColor.Black;
                    MsSQL.UpdateData("UPDATE users SET online='" + 0 + "' WHERE id='" + Player.AccountName + "'");
                    MsSQL.UpdateData("UPDATE character SET online='0' WHERE id='" + Character.Information.CharacterID + "'");

                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("@Evo-Debug :         Srevo has debugged: {0}", Character.Information.Name);
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("[@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@]");
                    Console.ForegroundColor = ConsoleColor.Green;
                    if (Character.Grabpet.Active)
                    {
                        UnSummonPetLogoff(Character.Grabpet.Details.UniqueID);
                    }
                    if (Character.Attackpet.Active)
                    {
                        UnSummonPetLogoff(Character.Attackpet.Details.UniqueID);
                    }
                    if (Character.Network.Party != null)
                    {
                        LeaveParty();
                    }

                    if (Character.Network.Guild.Guildid != 0)
                    {
                        Character.Information.Online = 0;
                        //Send packets to network and spawned players
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //We dont send this info to the invited user.
                                if (member != Character.Information.CharacterID)
                                {
                                    //If the user is not the newly invited member get player info
                                    Systems tomember = GetPlayerMainid(member);
                                    //Send guild update packet
                                    if (tomember != null)
                                    {
                                        tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0));
                                    }
                                }
                            }
                        }
                        Character.Network.Guild.Members.Remove(Character.Information.CharacterID);
                        Character.Network.Guild.MembersClient.Remove(this.client);
                    }

                    if (this.Character.Transport.Right)
                    {
                        this.Character.Transport.Horse.DeSpawnMe();
                    }
                    if (this.Character.Grabpet.Active)
                    {
                        this.Character.Grabpet.Details.DeSpawnMe();
                    }
                    if (this.Character.Network.Exchange.Window)
                    {
                        this.Exchange_Close();
                    }

                    #region Friend list
                    MsSQL ms    = new MsSQL("SELECT * FROM friends WHERE owner='" + Character.Information.CharacterID + "'");
                    int   count = ms.Count();
                    if (count >= 0)
                    {
                        using (SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                int     getid = reader.GetInt32(2);
                                Systems sys   = GetPlayerid(getid);
                                if (sys != null)
                                {
                                    sys.client.Send(Packet.FriendData(Character.Information.CharacterID, 4, Character.Information.Name, Character, true));
                                }
                            }
                        }
                    }
                    else
                    {
                        client.Send(Packet.SendFriendListstatic());
                    }
                    #endregion
                    BuffAllClose();
                    DeSpawnMe();
                    SavePlayerPosition();
                    SavePlayerInfo();
                    this.client.Close();
                    this.Character.Dispose();
                    this.Dispose();
                    Character.InGame = false;
                    Disconnect("normal");
                    lock (Systems.clients)
                    {
                        Systems.clients.Remove(this);
                    }
                }
            }
            catch (NullReferenceException nex)
            {
                Console.WriteLine("Timer.PingTimerCallBack: {0}", nex);
                PingStop();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Debug error: {0}", ex);
            }
        }
Esempio n. 16
0
        void NormalRequest()
        {
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Get invited member
                int Target = Reader.Int32();
                //Get party type
                byte PartyType = Reader.Byte();
                //Close reader
                Reader.Close();

                //Get target player information
                Systems InvitedPlayer = GetPlayer(Target);
                //First we check the our own player level
                if (Character.Information.Level < 5)
                {
                    //Send message

                    //Return
                    return;
                }
                //Check target level
                if (InvitedPlayer.Character.Information.Level < 5)
                {
                    //Send message

                    //Return
                    return;
                }
                //Set target information for invited player
                InvitedPlayer.Character.Network.TargetID = Character.Information.UniqueID;
                //If the player inviting, has no party yet.
                if (Character.Network.Party == null)
                {
                    //Create new party
                    party Party = new party();
                    //Set leader of party
                    Party.LeaderID = Character.Information.UniqueID;
                    //Set party type
                    Party.Type = PartyType;
                    //Add to party net info
                    Character.Network.Party = Party;
                }
                //If the target player has no party yet.
                if (InvitedPlayer.Character.Network.Party == null)
                {
                    //Send invitation packet
                    InvitedPlayer.client.Send(Packet.PartyRequest(2, this.Character.Information.UniqueID, PartyType));
                    //Set invite bools
                    InvitedPlayer.Character.Information.CheckParty = true;
                    Character.Information.CheckParty = true;
                }
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine(ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 17
0
        public void ChangeHitRate_E2AH(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2AH"] != 0)
                    {
                        int amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2AH"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Hit = amount;
                        Target.Character.Stat.Hit += Target.Character.Action.Buff.UpdatedStats[slot].Hit;
                    }

                }
                else
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2AH"] != 0)
                    {
                        Target.Character.Stat.Hit -= Target.Character.Action.Buff.UpdatedStats[slot].Hit;
                        Target.Character.Action.Buff.UpdatedStats[slot].Hit = 0;
                    }
                }

                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 18
0
        void CharacterRequest()
        {
            try
            {
                //Open packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);

                //Get targeted player information
                Systems sys = GetPlayer(Character.Network.TargetID);

                if (this.Character.State.UnionApply && sys.Character.State.UnionApply)
                {
                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {
                        //Need to sniff decline packet info
                        Character.State.UnionApply     = false;
                        sys.Character.State.UnionApply = false;
                    }
                    else
                    {
                        //Check for null and set unique id for union and insert our own guild.
                        if (sys.Character.Network.Guild.Unions == null)
                        {
                            int uniqueid = MsSQL.GetRowsCount("SELECT * FROM guild_unions");
                            sys.Character.Network.Guild.UniqueUnion = uniqueid + 1;
                            MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");
                        }
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_unions (union_leader, union_guildid, union_unique_id) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Network.Guild.Guildid + "','" + sys.Character.Network.Guild.UniqueUnion + "')");

                        //Send union packet to newly joined player
                        client.Send(Packet.UnionInfo(this));

                        //Send update packet to all guilds in union
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        if (Character.Information.CharacterID != tomember.Character.Information.CharacterID)
                                        {
                                            tomember.Character.Network.Guild.SingleSend = true;
                                            tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                        }
                                    }
                                }
                            }
                        }
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //If the user is not the newly invited member get player info
                                Systems tomember = GetPlayerMainid(member);
                                //Send guild update packet
                                if (tomember != null)
                                {
                                    if (!tomember.Character.Network.Guild.SingleSend)
                                    {
                                        tomember.Character.Network.Guild.SingleSend = true;
                                        tomember.client.Send(Packet.GuildUpdate(Character, 14, 0, 0, 0));
                                    }
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Disable the bool again
                        foreach (int member in Character.Network.Guild.UnionMembers)
                        {
                            //Make sure member isnt null
                            if (member != 0)
                            {
                                //Get guildmember details
                                Systems guildmember = GetPlayerMainid(member);
                                //Make sure guildmember isnt null
                                if (guildmember != null)
                                {
                                    //Disable bool to allow resend new packets.
                                    guildmember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                        //Reset bools
                        Character.State.UnionApply     = false;
                        sys.Character.State.UnionApply = false;
                    }
                }
                //------------------------------------- [ Exchange invite ] -------------------------------------//
                else if (this.Character.State.Exchanging && sys.Character.State.Exchanging)
                {
                    if (Reader.Byte() == 1 && Reader.Byte() == 0)
                    {
                        sys.client.Send(Packet.Exchange_Cancel());
                        Character.State.Exchanging     = false;
                        sys.Character.State.Exchanging = false;
                    }
                    else
                    {
                        sys.client.Send(Packet.OpenExhangeWindow(1, this.Character.Information.UniqueID));
                        client.Send(Packet.OpenExhangeWindow(sys.Character.Information.UniqueID));

                        Character.Network.Exchange.Window       = true;
                        Character.Network.Exchange.ItemList     = new List <DarkEmu_GameServer.Global.slotItem>();
                        sys.Character.Network.Exchange.Window   = true;
                        sys.Character.Network.Exchange.ItemList = new List <DarkEmu_GameServer.Global.slotItem>();
                    }
                }
                //------------------------------------- [ Guild invite ] -------------------------------------//
                else if (this.Character.State.GuildInvite && sys.Character.State.GuildInvite)
                {
                    //If byte equals 2 the type is denied
                    if (Reader.Byte() == 2)
                    {
                        //Denied request
                        Character.State.GuildInvite     = false;
                        sys.Character.State.GuildInvite = false;
                        //Send refused packet to sender
                        sys.client.Send(Packet.IngameMessages(SERVER_GUILD, IngameMessages.UIIT_MSG_GUILDERR_JOIN_GUILD_REFUSED));
                    }
                    //If not denied we start adding the new member
                    else
                    {
                        //Invite guild member (Add member count + 1).
                        int guildmemberadd = sys.Character.Network.Guild.Members.Count + 1;
                        //Update database
                        MsSQL.InsertData("INSERT INTO guild_members (guild_id, guild_member_id, guild_rank, guild_points, guild_fortress, guild_grant, guild_perm_join, guild_perm_withdraw, guild_perm_union, guild_perm_storage, guild_perm_notice) VALUES ('" + sys.Character.Network.Guild.Guildid + "','" + Character.Information.CharacterID + "','10','0','1','" + "" + "','0','0','0','0','0')");
                        MsSQL.UpdateData("UPDATE guild SET guild_members_t='" + guildmemberadd + "' WHERE guild_name='" + sys.Character.Network.Guild.Name + "'");
                        //Reload new member and load character data for guildinfo
                        LoadPlayerGuildInfo(true);
                        //Send packets to network and spawned players
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Make sure the member is there
                            if (member != 0)
                            {
                                //We dont send this info to the invited user.
                                if (member != Character.Information.CharacterID)
                                {
                                    //If the user is not the newly invited member get player info
                                    Systems tomember = GetPlayerMainid(member);
                                    //Send guild update packet
                                    tomember.LoadPlayerGuildInfo(true);
                                    tomember.client.Send(Packet.GuildUpdate(Character, 1, Character.Information.CharacterID, 0, 0));
                                    tomember.client.Send(Packet.GuildSetOnline(Character.Network.Guild, Character.Information.UniqueID));
                                    tomember.client.Send(Packet.GuildUpdate(Character, 6, Character.Information.CharacterID, 0, 0));
                                }
                                //Send information to the invited player
                                else
                                {
                                    //Send guild data packets to invited
                                    client.Send(Packet.SendGuildStart());
                                    client.Send(Packet.SendGuildInfo(Character.Network.Guild));
                                    client.Send(Packet.SendGuildEnd());
                                    //Load union data for new invited player
                                    LoadUnions();
                                }
                            }
                        }
                        //Set bools to false for new invite
                        Character.State.GuildInvite     = false;
                        sys.Character.State.GuildInvite = false;
                    }
                }

                //------------------------------------- [ Party invite ] -------------------------------------//
                else
                {
                    //If invitation is accepted
                    if (Reader.Byte() == 1 && Reader.Byte() == 1)
                    {
                        //First we set our main checks (Check if player is in party or not).
                        if (Character.Network.Party != null)
                        {
                            return;
                        }
                        //Set bools for check
                        Character.Information.CheckParty     = true;
                        sys.Character.Information.CheckParty = true;

                        //Set main party information
                        party JoiningParty = sys.Character.Network.Party;

                        //Check party type members allowed need message if full
                        if (JoiningParty.Type == 4 && JoiningParty.Members.Count > 3)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        if (JoiningParty.Type == 5 && JoiningParty.Members.Count > 7)
                        {
                            //Send party is full message to player
                            client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_ALREADY_FULL));
                            return;
                        }
                        //If the current count == 0 then add party and add me
                        if (JoiningParty.Members.Count == 0)
                        {
                            //Add ourselfs to the party list
                            JoiningParty.Members.Add(sys.Character.Information.UniqueID);
                            //Add our client to the party list
                            JoiningParty.MembersClient.Add(sys.client);
                            //Set party id
                            JoiningParty.ptid = Party.Count + 1;
                            //Set party network info
                            sys.Character.Network.Party = JoiningParty;
                            //Send permissions
                            sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID));
                            //Send party data to leader
                            sys.client.Send(Packet.Party_DataMember(JoiningParty));
                            //Send party data packet to leader (Other player that joined).
                            sys.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            //Add invited member to the list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            JoiningParty.MembersClient.Add(client);
                            //Set party info for invited member
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            //return
                            return;
                        }
                        //If there are more members in the current party
                        else
                        {
                            //Repeat for each member using count
                            for (byte b = 0; b <= JoiningParty.Members.Count - 1; b++)
                            {
                                //Get player information from [b]
                                Systems others = GetPlayer(JoiningParty.Members[b]);
                                //Send party data to member
                                others.client.Send(Packet.Party_Data(2, Character.Information.UniqueID));
                            }
                            //Add the invited member to list
                            JoiningParty.Members.Add(Character.Information.UniqueID);
                            //Add the invited client to the list
                            JoiningParty.MembersClient.Add(client);
                            //Set party
                            Character.Network.Party = JoiningParty;
                            //Send permissions
                            client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));
                            //Send party data
                            client.Send(Packet.Party_DataMember(JoiningParty));
                            return;
                        }
                    }
                    //If denied request
                    else
                    {
                        //Send denied message to the player joining
                        client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MEMBER, IngameMessages.UIIT_MSG_PARTYERR_JOIN_PARTY_REFUSED));
                        //Set both bools to false so inviting can be done again
                        sys.Character.Information.CheckParty = false;
                        Character.Information.CheckParty     = false;
                    }
                }
            }
            //Catch bad exception errors
            catch (Exception ex)
            {
                //Write information to the console
                Console.WriteLine("Request error: {0}", ex);
                //Write information to the debug log
                Debugger.Write(ex);
            }
        }
Esempio n. 19
0
 public void ChangeInt_inti(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         if (!delete)
         {
             int amount;
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["inti"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["inti"];
                 Target.Character.Action.Buff.UpdatedStats[slot].Intelligence = (short)amount;
             }
             //TODO majd uncomment.
             /*if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2.ContainsKey("inti"))
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["inti"];
                 Target.Character.Action.Buff.UpdatedStats[slot].Intelligence = (short)((Target.Character.Stat.Intelligence / 100) * (amount));
             }*/
             Target.Character.Stat.Intelligence += Target.Character.Action.Buff.UpdatedStats[slot].Intelligence;
         }
         else
         {
             Target.Character.Stat.Intelligence -= Target.Character.Action.Buff.UpdatedStats[slot].Intelligence;
             Target.Character.Action.Buff.UpdatedStats[slot].Intelligence = 0;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 20
0
        public static byte[] UnionInfo(Systems c)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_GUILD_UNIONS);
            Writer.DWord(c.Character.Information.CharacterID);                // Union owner id
            Writer.DWord(7);                                                  // ??Need to check
            Writer.DWord(c.Character.Network.Guild.Guildid);                  // Union leader guild id
            Writer.Byte(c.Character.Network.Guild.Unions.Count);              // Count guilds in union
            //Get all guilds details
            foreach (int guild in c.Character.Network.Guild.Unions)
            {
                //Load other guild data
                Systems.MsSQL guild_data = new Systems.MsSQL("SELECT * FROM guild WHERE id='" + guild + "'");

                using (System.Data.SqlClient.SqlDataReader reader = guild_data.Read())
                {
                    while (reader.Read())
                    {
                        string Guildname        = reader.GetString(1);
                        byte   Guildlevel       = reader.GetByte(2);
                        byte   Guildmembercount = reader.GetByte(6);
                        int    Ownerid          = reader.GetInt32(9);

                        string Charname  = Systems.MsSQL.GetData("SELECT name FROM character WHERE id='" + Ownerid + "'", "name").ToString();
                        int    Charmodel = Convert.ToInt32(Systems.MsSQL.GetData("SELECT chartype FROM character WHERE id='" + Ownerid + "'", "chartype"));

                        Writer.DWord(guild);                        //Guild ID
                        Writer.Text(reader.GetString(1));           //Guildname
                        Writer.Byte(reader.GetByte(2));             //Guildlevel
                        Writer.Text(Charname);                      //Ownername
                        Writer.DWord(Charmodel);                    //Owner model
                        Writer.Byte(reader.GetByte(6));             //Guild member count

                        //Get guild details
                        Systems Guildmembers = Systems.GetGuildPlayer(guild);
                        //Add clients that are online to union list
                        //Null check
                        if (Guildmembers != null)
                        {
                            foreach (int member in Guildmembers.Character.Network.Guild.Members)
                            {
                                //make sure member isnt 0
                                if (member != 0)
                                {
                                    //Get player details
                                    Systems getmember = Systems.GetPlayerMainid(member);
                                    //Make sure that the player is there
                                    if (getmember != null)
                                    {
                                        //Add client to union list
                                        c.Character.Network.Guild.UnionMembers.Add(getmember.Character.Information.CharacterID);
                                        //Add to member
                                        if (c.Character.Information.CharacterID != getmember.Character.Information.CharacterID)
                                        {
                                            getmember.Character.Network.Guild.UnionMembers.Add(c.Character.Information.CharacterID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(Writer.GetBytes());
        }
Esempio n. 21
0
        public void ChangeSpeed_hste(Systems Target, int slot, bool delete,bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    int amount;
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["hste"] != 0)
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["hste"];
                        Target.Character.Speed.Updateded[slot] += (Target.Character.Speed.RunSpeed / 100) * amount;

                    }
                    Target.Character.Speed.RunSpeed += Target.Character.Speed.Updateded[slot];
                }
                else
                {
                    Target.Character.Speed.RunSpeed -= Target.Character.Speed.Updateded[slot];
                    Target.Character.Speed.Updateded[slot] = 0;
                }
                if (UpdatePacket) Target.client.Send(Packet.SetSpeed(Target.Character.Information.UniqueID, Target.Character.Speed.WalkSpeed, Target.Character.Speed.RunSpeed));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 22
0
        void GuildPermissions()
        {
            try
            {
                //Create new packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Skip first
                Reader.Skip(1);
                //Read member id
                int memberid = Reader.Int32();
                //Read permission byte
                byte permissions = (byte)Reader.Int32();
                //Set new char bits 8
                char[] bits = new char[8];
                //Repeat for each 8 bits
                for (int i = 0; i < 8; ++i)
                {
                    bits[i] = (char)0;
                }
                //Convert bits to string / to char array
                bits = Convert.ToString(permissions, 2).ToCharArray();
                //Close reader
                Reader.Close();
                //Set amount to player targetindex
                int targetindex = this.Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == memberid);
                //If character is online
                if (this.Character.Network.Guild.MembersInfo[targetindex].Online)
                {
                    //Get detailed player information
                    Systems member = GetPlayerMainid(memberid);
                    //Set bits
                    member.Character.Network.Guild.joinRight         = bits[4] == '1' ? true : false;
                    member.Character.Network.Guild.withdrawRight     = bits[3] == '1' ? true : false;
                    member.Character.Network.Guild.unionRight        = bits[2] == '1' ? true : false;
                    member.Character.Network.Guild.guildstorageRight = bits[0] == '1' ? true : false;
                    member.Character.Network.Guild.noticeeditRight   = bits[1] == '1' ? true : false;
                }
                // set new amount to every guild members guild class
                foreach (int m in Character.Network.Guild.Members)
                {
                    //Set int index (Find member id)
                    int index = Character.Network.Guild.MembersInfo.FindIndex(i => i.MemberID == m);
                    //If the character is online
                    if (Character.Network.Guild.MembersInfo[index].Online)
                    {
                        //Get detailed information of the player
                        Systems sys = Systems.GetPlayerMainid(m);

                        //Set new guild player
                        Global.guild_player mygp = new Global.guild_player();
                        int myindex = 0;
                        //Repeat for each player
                        foreach (Global.guild_player gp in sys.Character.Network.Guild.MembersInfo)
                        {
                            //if the member id equals the player
                            if (gp.MemberID == memberid)
                            {
                                //Set my gp
                                mygp = gp;
                                //Set bits
                                mygp.joinRight         = bits[4] == '1' ? true : false;
                                mygp.withdrawRight     = bits[3] == '1' ? true : false;
                                mygp.unionRight        = bits[2] == '1' ? true : false;
                                mygp.guildstorageRight = bits[0] == '1' ? true : false;
                                mygp.noticeeditRight   = bits[1] == '1' ? true : false;
                                break;
                            }
                            //Index ++
                            myindex++;
                        }
                        //Set membersinfo index as mygp
                        sys.Character.Network.Guild.MembersInfo[myindex] = mygp;
                    }
                }
                //Update guild database information rights
                MsSQL.UpdateData("UPDATE guild_members SET guild_perm_join='" + bits[4] + "',guild_perm_withdraw='" + bits[3] + "',guild_perm_union='" + bits[2] + "',guild_perm_storage='" + bits[0] + "',guild_perm_notice='" + bits[1] + "' WHERE guild_member_id='" + memberid + "'");
                //Send to everyone in guild update of permissions
                Character.Network.Guild.Send(Packet.GuildUpdate(Character, 4, 0, permissions, 0));
            }
            //If an error happens
            catch (Exception ex)
            {
                //Write the information to the console
                Console.WriteLine("Guild permission error: {0}", ex);
                //Write information to the debug log
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 23
0
 public bool SkillAdd_Properties(Systems Target, string PropertiesName, bool UpdatePacket, byte slot = 255, int skillid = -1)
 {
     try
     {
         switch (PropertiesName)
         {
             case "hpi":
                 ChangeMaxHP_hpi(Target, slot, false, UpdatePacket);
                 break;
             case "mpi":
                 ChangeMaxMP_mpi(Target, slot, false, UpdatePacket);
                 break;
             case "dru":
                 ChangeAtk_dru(Target, slot, false,UpdatePacket);
                 break;
             case "er":
                 ChangeParry_er(Target, slot, false,UpdatePacket);
                 break;
             case "stri":
                 ChangeStr_stri(Target, slot, false,UpdatePacket);
                 break;
             case "inti":
                 ChangeInt_inti(Target, slot, false, UpdatePacket);
                 break;
             case "cr":
                 ChangeCrit_cr(Target, slot, false,UpdatePacket);
                 break;
             case "br":
                 ChangeBlockingRatio_br(Target, slot, false,UpdatePacket);
                 break;
             case "spda":
                 Change_spda(Target, slot, false,UpdatePacket);
                 break;
             case "ru":
                 ChangeRange_ru(Target, slot, false,UpdatePacket);
                 break;
             case "dgmp":
                 ChangeAbsorbMP_dgmp(Target, slot, false,UpdatePacket);
                 break;
             case "defp":
                 ChangeDefPower_defp(Target, slot, false, UpdatePacket);
                 break;
             case "hste":
                 ChangeSpeed_hste(Target,slot,false,UpdatePacket);
                 break;
             case "drci":
                 ChangeCriticalParry_dcri(Target, slot, false, UpdatePacket);
                 break;
             case "heal":
                 HealHPMP(Target, slot, skillid, false, UpdatePacket);
                 break;
             case "E1SA": // setvaluek ( valószínű ) nem így lesznek
                 ChangePhyAtk_E1SA(Target, slot, false, UpdatePacket);
                 break;
             case "E2SA":
                 ChangePhyAtk_E2SA(Target, slot, false, UpdatePacket);
                 break;
             case "E2AH":
                 ChangeHitRate_E2AH(Target, slot, false, UpdatePacket);
                 break;
             case "terd":
                 ChangeParry_terd(Target, slot, false, UpdatePacket);
                 break;
             case "chcr":
                 ChangeTargetHp_chcr(Target, slot, false, UpdatePacket);
                 break;
             case "cmcr":
                 ChangeTargetHp_cmcr(Target, slot, false, UpdatePacket);
                 break;
             case "thrd":
                 ChangeDecAttkRate_thrd(Target, slot, false, UpdatePacket);
                 break;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("BuffAdd_Properties() error..");
         Systems.Debugger.Write(ex);
     }
     return false;
 }
Esempio n. 24
0
        void GuildPromote()
        {
            try
            {
                //Read client information int32 id
                PacketReader reader  = new PacketReader(PacketInformation.buffer);
                int          guildid = reader.Int32();
                reader.Close();

                //When a guild has reached its max level
                if (Character.Network.Guild.Level == 5)
                {
                    //Send packet to client and return (Message level up max).
                    client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL));
                    return;
                }
                //Definition for gold needed
                int GoldRequired;
                //Definition for guild points needed
                int GuildPointRequired;
                //Check if player is allready in process of upgrading
                if (!IsUpgrading)
                {
                    //Set bool to true, so we cant dupe
                    IsUpgrading = true;
                    //Load player guild information before we continue (Check last info).
                    LoadPlayerGuildInfo(false);
                    //Create switch on guildl evel
                    switch (Character.Network.Guild.Level)
                    {
                    case 1:
                        GoldRequired       = 3000000;
                        GuildPointRequired = 5400;
                        break;

                    case 2:
                        GoldRequired       = 9000000;
                        GuildPointRequired = 50400;
                        break;

                    case 3:
                        GoldRequired       = 15000000;
                        GuildPointRequired = 135000;
                        break;

                    case 4:
                        GoldRequired       = 21000000;
                        GuildPointRequired = 378000;
                        break;

                    default:
                        return;
                    }
                    //Set new guild level definition + 1
                    int NewLevel = Character.Network.Guild.Level + 1;
                    //Set new guild storage slot  amount
                    int NewStorageSlots = Character.Network.Guild.StorageSlots + 30;
                    //If character's gold is not enough
                    if (Character.Information.Gold < GoldRequired)
                    {
                        //Send message to client
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GOLD_DEFICIT));
                        return;
                    }
                    //Not enough guildpoints
                    if (Character.Network.Guild.PointsTotal < GuildPointRequired)
                    {
                        //Send client message
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_GP_DEFICIT));
                        return;
                    }
                    //Max level
                    if (Character.Network.Guild.Level == 5)
                    {
                        //Send client message
                        client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_ERROR_GUILD_LEVEL_UP_FULL));
                        return;
                    }
                    //If everything else is fine
                    else
                    //Upgrade guild initiate
                    {
                        //If max level return just incase.
                        if (Character.Network.Guild.Level == 5)
                        {
                            return;
                        }
                        //Reduct guildpoints
                        Character.Network.Guild.PointsTotal -= GuildPointRequired;
                        //If the upgrade is final upgrade set points to 0
                        if (Character.Network.Guild.Level == 4)
                        {
                            Character.Network.Guild.PointsTotal = 0;
                        }
                        //Reduct gold
                        Character.Information.Gold -= GoldRequired;
                        //Send update information to client
                        client.Send(Packet.InfoUpdate(1, Character.Network.Guild.PointsTotal, 0));
                        //Send success message to client
                        client.Send(Packet.PromoteOrDisband(2));
                        //Update guild in database
                        MsSQL.UpdateData("UPDATE guild SET guild_level='" + NewLevel + "',guild_points='" + Character.Network.Guild.PointsTotal + "',guild_storage_slots='" + NewStorageSlots + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
                        //Repeat for each member in our guild
                        foreach (int member in Character.Network.Guild.Members)
                        {
                            //Check if memeber is not null
                            if (member != 0)
                            {
                                //Get detailed member information
                                Systems memberinfo = GetPlayerMainid(member);
                                //Make sure the member is not null
                                if (memberinfo != null)
                                {
                                    //Reload information for the current guild member
                                    memberinfo.LoadPlayerGuildInfo(false);
                                    //Send guild update packet for current guild member
                                    memberinfo.client.Send(Packet.GuildUpdate(Character, 5, 0, 0, 0));
                                }
                            }
                        }
                        //Save player's gold
                        SaveGold();
                        //Send update gold packet to client
                        client.Send(Packet.UpdateGold(Character.Information.Gold));
                    }
                }
                //Disable the bool so we can upgrade again
                IsUpgrading = false;
            }
            //If any error accures
            catch (Exception ex)
            {
                //Write error to the console
                Console.WriteLine("Guild Promote Error: {0}", ex);
                //Write error to debug log
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 25
0
        public void StallBuy()
        {
            try
            {
                if (!Character.Network.Stall.isOpened)
                {
                    return;
                }
                PacketReader Reader    = new PacketReader(PacketInformation.buffer);
                byte         stallslot = Reader.Byte();

                stall           currentStall = Character.Network.Stall;
                stall.stallItem sitem        = currentStall.ItemList.Find(i => (i.stallSlot == stallslot));

                // stall buyer update
                byte slot = GetFreeSlot();
                if (slot <= 12)
                {
                    return;
                }
                if (Character.Information.Gold >= (long)sitem.price)
                {
                    Character.Information.Gold -= (long)sitem.price;
                    client.Send(Packet.UpdateGold(Character.Information.Gold));
                    SaveGold();
                }
                else
                {
                    return;  //insufficent gold
                }
                // staller update
                if (currentStall.ItemList.Contains(sitem))
                {
                    Systems staller = GetPlayer(currentStall.ownerID);
                    staller.Character.Information.Gold += (long)sitem.price;
                    staller.client.Send(Packet.UpdateGold(staller.Character.Information.Gold));

                    MsSQL.UpdateData("update character set gold='" + staller.Character.Information.Gold + "' where id='" + staller.Character.Information.CharacterID + "'");
                    //MsSQL.UpdateData("delete from char_items where itemnumber='item" + sitem.Item.Slot + "' AND owner='" + staller.Character.Information.CharacterID + "'");
                    Systems.MsSQL.InsertData("UPDATE char_items SET owner='" + Character.Information.CharacterID + "',slot='" + slot + "',itemnumber='item" + slot + "' WHERE owner='" + staller.Character.Information.CharacterID + "' AND itemid='" + sitem.Item.ID + "' AND id='" + sitem.Item.dbID + "' AND storagetype='0'");
                    //take item out from stall
                    if (currentStall.ItemList.Count == 1)
                    {
                        staller.Character.Stall.Stallactive = false;
                        Character.Stall.Stallactive         = false;
                    }
                    currentStall.ItemList.Remove(sitem);
                    client.Send(Packet.StallBuyItem(stallslot, 1));
                    currentStall.Send(Packet.StallBuyItem2(Character.Information.Name, stallslot, currentStall.ItemList));
                }
                else
                {
                    Disconnect("ban");
                    Console.WriteLine("Autobanned user: "******" Due to hacking");
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 26
0
 public void LoadGuildMembers()
 {
     //Wrap our code in a try to catch bad exception errors
     try
     {
         //Load guild member id's
         LoadGuildMemberIds(Character.Network.Guild.Guildid, ref Character.Network.Guild.Members);
         //Repeat for each member in the guild member list
         foreach (int Guildmember in Character.Network.Guild.Members)
         {
             //Set new guild player information
             Global.guild_player PlayerGuild = new Global.guild_player();
             //Set guildmember id
             PlayerGuild.MemberID = Guildmember;
             //Create new mssql query to get player information
             Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM character WHERE id='" + Guildmember + "'");
             //Create mssql data reader
             using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
             {
                 //While the reader is reading
                 while (reader.Read())
                 {
                     //Get player model
                     PlayerGuild.Model = reader.GetInt32(3);
                     //Get player xsector
                     PlayerGuild.Xsector = reader.GetByte(16);
                     //Get player ysector
                     PlayerGuild.Ysector = reader.GetByte(17);
                     //Get player level
                     PlayerGuild.Level = reader.GetByte(5);
                     //Get player name
                     PlayerGuild.Name = reader.GetString(2);
                     //Get player online state
                     PlayerGuild.Online = (reader.GetInt32(47) == 1);
                     //If player is online
                     if (PlayerGuild.Online)
                     {
                         //Get detailed player information
                         Systems sys = GetPlayerMainid(Guildmember);
                         //Make sure sys is not null
                         if (sys != null)
                         {
                             //Add the character client to the client list
                             this.Character.Network.Guild.MembersClient.Add(sys.client);
                         }
                     }
                 }
             }
             //Create new query to select from table guild_members
             ms = new Systems.MsSQL("SELECT * FROM guild_members WHERE guild_member_id='" + Guildmember + "'");
             //Create new sql data reader
             using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
             {
                 //While the sql data reader is reading
                 while (reader.Read())
                 {
                     //Get player rights
                     PlayerGuild.joinRight         = (reader.GetByte(7) == 1);
                     PlayerGuild.withdrawRight     = (reader.GetByte(8) == 1);
                     PlayerGuild.unionRight        = (reader.GetByte(9) == 1);
                     PlayerGuild.guildstorageRight = (reader.GetByte(10) == 1);
                     PlayerGuild.noticeeditRight   = (reader.GetByte(11) == 1);
                     PlayerGuild.FWrank            = reader.GetByte(6);
                     //Get player donated gp
                     PlayerGuild.DonateGP = reader.GetInt32(4);
                     //Get player rank
                     PlayerGuild.Rank = reader.GetByte(3);
                 }
             }
             //Close mssql
             ms.Close();
             //Add our character to the guild member info
             Character.Network.Guild.MembersInfo.Add(PlayerGuild);
         }
     }
     //Catch bad exceptions
     catch (Exception ex)
     {
         //Write error to the console
         Console.WriteLine(ex);
         //Write error to the debug log file
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 27
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Monster Summon Scrolls
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleSummon(int scrollid)
        {
            try
            {
                //if (this.Character.Information.Level < 10) return;

                int count = 1;//Default should be set to 1

                //single scroll
                if (scrollid == 3936)
                {
                    count = 5;
                }
                //party scroll
                if (scrollid == 3935)
                {
                    if (this.Character.Network.Party == null)
                    {
                        return;
                    }
                    if (this.Character.Network.Party.Members.Count < 5)
                    {
                        return;
                    }

                    count = this.Character.Network.Party.Members.Count;
                }

                int  model = GetStrongMobByLevel(this.Character.Information.Level);
                byte type  = Data.ObjectBase[model].ObjectType;

                for (int i = 1; i <= count; i++)
                {
                    obj Spawn = new obj();

                    Spawn.ID           = model;
                    Spawn.Type         = type;
                    Spawn.Ids          = new Global.ID(Global.ID.IDS.Object);
                    Spawn.UniqueID     = Spawn.Ids.GetUniqueID;
                    Spawn.x            = Character.Position.x;
                    Spawn.z            = Character.Position.z;
                    Spawn.y            = Character.Position.y;
                    Spawn.oX           = Spawn.x;
                    Spawn.oY           = Spawn.y;
                    Spawn.xSec         = Character.Position.xSec;
                    Spawn.ySec         = Character.Position.ySec;
                    Spawn.AutoMovement = true;
                    Spawn.State        = 1;
                    Spawn.Move         = 1;
                    Spawn.SpeedWalk    = Data.ObjectBase[Spawn.ID].SpeedWalk;
                    Spawn.SpeedRun     = Data.ObjectBase[Spawn.ID].SpeedRun;
                    Spawn.SpeedZerk    = Data.ObjectBase[Spawn.ID].SpeedZerk;
                    Spawn.HP           = Data.ObjectBase[model].HP;
                    Spawn.Agresif      = Data.ObjectBase[model].Agresif;
                    Spawn.LocalType    = 1;
                    Spawn.AutoSpawn    = false;
                    Spawn.Kat          = 1;
                    Systems.aRound(ref Spawn.x, ref Spawn.y, 1);
                    Systems.Objects.Add(Spawn);
                    Spawn.SpawnMe();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 28
0
        public static void ExecuteCommand(string aCommand, Socket aSocket)
        {
            try
            {
                if (aCommand != null)
                {
                    string[] command = aCommand.Split(' ');
                    if (command[0] == "/help")
                    {

                        if (aSocket == null)
                        {
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.WriteLine("                     Ingame notice: Type 1 space then message.");
                            Console.WriteLine("                     //clear");
                            Console.WriteLine("                     //repairitems");
                            Console.WriteLine("                     //respawn_unique");
                            Console.WriteLine("                     //event");
                            Console.WriteLine("                     //shutdown");
                            Console.WriteLine("                     //manager");

                            Console.ForegroundColor = ConsoleColor.Yellow;
                        }
                        else
                        {
                            sendSocket(aSocket, "Ingame notice: Type 1 space then message." + Environment.NewLine);
                            sendSocket(aSocket, "  //clear = cleanup unused memory" + Environment.NewLine);
                            sendSocket(aSocket, "  //repairitems" + Environment.NewLine);
                            sendSocket(aSocket, "  //respawn_unique" + Environment.NewLine);
                            sendSocket(aSocket, "  //event" + Environment.NewLine);
                            sendSocket(aSocket, "  //shutdown" + Environment.NewLine);
                        }
                    }
                    else if (command[0] == "//clear")
                    {
                        System.GC.Collect();
                        GC.Collect(0, GCCollectionMode.Forced);
                        sendSocket(aSocket, "done memory cleanup" + Environment.NewLine);
                    }
                    else if (command[0] == "//shutdown")
                    {
                        byte waitTime = 5;
                        if (command.Length > 1)
                        {
                            waitTime = System.Convert.ToByte(command[1]);
                        }
                        if (aSocket != null)
                        {
                            aSocket.Send(Encoding.ASCII.GetBytes("SHUTDOWN_START" + Environment.NewLine));
                        }

                        lock (Systems.clients)
                        {
                            Console.WriteLine("{0}stopping server and sending notice to clients ...", DarkEmu_GameServer.Global.Product.Prefix);
                            sendSocket(aSocket, "SHUTDOWN: stopping server and sending notice to clients ..." + Environment.NewLine);
                            net.ServerCheck(true);
                            net.Stop();  // disable any new connection
                            try
                            {
                                Systems.SendAll(Packet.ChatPacket(7, 0, "The server is stopping, your information will be saved.", ""));
                                Systems.SendAll(Packet.StartingLeaveGame(waitTime, 0));
                            }
                            catch { }
                            Thread.Sleep(waitTime);
                            Console.WriteLine("@SHUTDOWN: logoff clients ...");
                            sendSocket(aSocket, "@SHUTDOWN: logoff clients ..." + Environment.NewLine);
                            while (Systems.clients.Count > 0)
                            {
                                try
                                {
                                    try
                                    {
                                        Systems.clients[0].Send(Packet.EndLeaveGame());
                                    }
                                    catch { }
                                    //Ignore new character case (used for disconnect kick).
                                    Systems c = new Systems();
                                    Systems.clients[0].Disconnect("normal");
                                }
                                catch { }
                            }
                        }
                        sendSocket(aSocket, "SHUTDOWN_END" + Environment.NewLine);
                        cancelServer = true;
                        Systems.UpdateServerInfo(0);
                        //Environment.Exit(0);
                    }
                    else if (command[0] == "//repairitems")
                    {
                        int fixeditem = 0;
                        Systems.MsSQL ms = new Systems.MsSQL("SELECT * FROM char_items");
                        using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                short amount = reader.GetInt16(7);
                                if (amount < 1)
                                {
                                    fixeditem++;
                                    amount = 1;
                                    Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE itemnumber='" + "item" + reader.GetByte(5) + "' AND owner='" + reader.GetInt32(3) + "' AND itemid='" + reader.GetInt32(2) + "'");
                                }
                            }
                        }
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("@Gameserver:         Items Repaired:           {0}", fixeditem);
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        sendSocket(aSocket, String.Format("@Gameserver: Items Repaired: {0}", fixeditem) + Environment.NewLine);
                    }
                    else if (command[0] == "//respawn_unique")
                    {
                        DarkEmu_GameServer.GlobalUnique.StartTGUnique(6000 * 10, 6000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartUriUnique(7000 * 10, 7000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIsyUnique(8000 * 10, 8000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartLordUnique(9000 * 10, 9000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartDemonUnique(10000 * 10, 10000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartCerbUnique(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIvyUnique(11000 * 10, 11000 * 10);
                        //Game.GlobalUnique.StartRoc(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartMedusa(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartNeith(11000 * 10, 11000 * 10);
                        //Game.GlobalUnique.StartSphinx(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIsis(11000 * 10, 11000 * 10);
                        sendSocket(aSocket, "done respawn" + Environment.NewLine);
                    }
                    else if (command[0] == "//event")
                    {
                        EventMain eventnew = new EventMain(System.IO.Directory.GetCurrentDirectory() + "/data/event.txt");
                        eventnew.Start();
                        sendSocket(aSocket, "Event Started" + Environment.NewLine);
                    }
                    else if (command[0] == "")
                    {
                        string information = aCommand;
                        DarkEmu_GameServer.Systems c = new DarkEmu_GameServer.Systems();
                        DarkEmu_GameServer.Systems.SendAll(c.sendnoticecon(7, 0, information, ""));

                        Console.WriteLine("Notice: " + information);
                        sendSocket(aSocket, "Sent Notice: " + information + Environment.NewLine);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Program.Main {0}", ex);
            }
        }
Esempio n. 29
0
 public void Send(byte[] buff, Systems.Client client)
 {
     for (byte b = 0; b <= MembersClient.Count - 1; b++)
     {
         if (MembersClient[b] != client)
             MembersClient[b].Send(buff);
     }
 }
Esempio n. 30
0
        ///////////////////////////////////////////////////////////////////////////
        // Frostbite state
        ///////////////////////////////////////////////////////////////////////////
        #region Frost Bite
        public static void GenerateEffect_fb(object target, int skillid)
        {
            // Get effects parameters
            int Power       = Data.SkillBase[skillid].Properties1["fb"];
            int Probability = Data.SkillBase[skillid].Properties2["fb"];

            int Random = Seed.Next(1, 100);

            byte slot;


            // if effect succeeded
            if (Random <= Probability)
            {
                if (target.GetType().ToString() == "DarkEmu_GameServer.Systems") // player
                {
                    Systems sys = target as Systems;

                    if (sys.Character.State.Die == true)
                    {
                        return;
                    }

                    slot = sys.DeBuffGetFreeSlot();
                    sys.Character.Action.DeBuff.Effect.EffectID[slot] = EffectNumbers.FROSTBITE;
                    sys.Character.Action.DeBuff.Effect.SkillID[slot]  = skillid;

                    sys.StartEffectTimer(Power * 100, slot);
                    sys.Send(Packet.EffectUpdate(sys.Character.Information.UniqueID, EffectNumbers.FROSTBITE, true));

                    // attack speed
                    sys.Character.Speed.AttackSpeedModifier = 1.5;

                    sys.Character.Speed.RunSpeed     /= 2;
                    sys.Character.Speed.WalkSpeed    /= 2;
                    sys.Character.Speed.BerserkSpeed /= 2;

                    sys.Send(Packet.SetSpeed(sys.Character.Information.UniqueID, sys.Character.Speed.WalkSpeed, sys.Character.Speed.RunSpeed));
                }
                else if (target.GetType().ToString() == "DarkEmu_GameServer.obj") // mob
                {
                    obj os = target as obj;

                    if (os.Die == true)
                    {
                        return;
                    }

                    slot = os.DeBuffGetFreeSlot();
                    os.DeBuff.Effect.EffectID[slot] = EffectNumbers.FROSTBITE;
                    os.DeBuff.Effect.SkillID[slot]  = skillid;
                    //target.os.DeBuff.Effect.EffectPower[slot] = Power;

                    os.StartEffectTimer(Power * 100, slot);

                    os.Send(Packet.EffectUpdate(os.UniqueID, EffectNumbers.FROSTBITE, true));

                    // attack speed
                    os.AttackSpeed = 1.5;

                    // movement speed
                    os.SpeedRun  /= 2;
                    os.SpeedWalk /= 2;

                    //Set our bool active
                    os.Frostbite = true;

                    os.Send(Packet.SetSpeed(os.UniqueID, os.SpeedWalk, os.SpeedRun));
                }
            }
        }
Esempio n. 31
0
        public static void HealHPMP(Systems Target, int slot, int skillid, bool delete, bool UpdatePacket)
        {
            try
            {
                int amount;
                int sid;

                // get skillid from parameters
                if (skillid == -1)
                    sid = Target.Character.Action.Buff.SkillID[slot];
                else
                    sid = skillid;

                if (!delete)
                {
                    // if hp full
                    if (Target.Character.Stat.SecondHp == Target.Character.Stat.Hp) return;

                    if (Data.SkillBase[sid].Properties1["heal"] != 0)
                    {
                        amount = Data.SkillBase[sid].Properties1["heal"];

                        // add the calculated amount
                        if (Target.Character.Stat.SecondHp + amount < Target.Character.Stat.Hp)
                            Target.Character.Stat.SecondHp += amount;
                        else if (Target.Character.Stat.SecondHp != Target.Character.Stat.Hp)
                            Target.Character.Stat.SecondHp += Target.Character.Stat.Hp - Target.Character.Stat.SecondHp;

                        if (UpdatePacket) Target.UpdateHp();
                    }
                    if (Data.SkillBase[sid].Properties2["heal"] != 0)
                    {
                        amount = Data.SkillBase[sid].Properties2["heal"];
                        amount = (Target.Character.Stat.Hp / 100) * amount;

                        // add the calculated amount
                        if (Target.Character.Stat.SecondHp + amount < Target.Character.Stat.Hp)
                            Target.Character.Stat.SecondHp += amount;
                        else if (Target.Character.Stat.SecondHp != Target.Character.Stat.Hp)
                            Target.Character.Stat.SecondHp += Target.Character.Stat.Hp - Target.Character.Stat.SecondHp;

                        if (UpdatePacket) Target.UpdateHp();
                    }
                    if (Data.SkillBase[sid].Properties3["heal"] != 0)
                    {
                        amount = Data.SkillBase[sid].Properties3["heal"];

                        // add the calculated amount
                        if (Target.Character.Stat.SecondMP + amount < Target.Character.Stat.Mp)
                            Target.Character.Stat.SecondMP += amount;
                        else if (Target.Character.Stat.SecondMP != Target.Character.Stat.Mp)
                            Target.Character.Stat.SecondMP += Target.Character.Stat.Mp - Target.Character.Stat.SecondMP;

                        if (UpdatePacket) Target.UpdateMp();

                    }
                    if (Data.SkillBase[sid].Properties3["heal"] != 0)
                    {
                        amount = Data.SkillBase[sid].Properties4["heal"];
                        amount = (Target.Character.Stat.Mp / 100) * amount;

                        // add the calculated amount
                        if (Target.Character.Stat.SecondMP + amount < Target.Character.Stat.Mp)
                            Target.Character.Stat.SecondMP += amount;
                        else if (Target.Character.Stat.SecondMP != Target.Character.Stat.Mp)
                            Target.Character.Stat.SecondMP += Target.Character.Stat.Mp - Target.Character.Stat.SecondMP;

                        if (UpdatePacket) Target.UpdateMp();
                    }
                }
                else
                {
                    //dunno....
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 32
0
        // collision detection 2D - /With Linear Algebra/
        public static bool isCollided_onMovement(Global.vektor fromPos, Global.vektor toPos, ref Global.vektor CollisionPoint, Systems c)
        {
            try
            {
                fromPos.x = packetx(fromPos.x, fromPos.xSec) / 20.0f;
                fromPos.y = packety(fromPos.y, fromPos.ySec) / 20.0f;
                toPos.x   = packetx(toPos.x, toPos.xSec) / 20.0f;
                toPos.y   = packety(toPos.y, toPos.ySec) / 20.0f;

                // iterated line
                Global.vektor Line_A = new Global.vektor();
                Global.vektor Line_B = new Global.vektor();

                List <Global.vektor> CollisionPoints = new List <Global.vektor>();

                // get current region to filter out the objects
                short region = makeRegion(fromPos.xSec, fromPos.ySec);

                // get all entitys in this region and try to cut them with our movement line
                foreach (Global.SectorObject.n7nEntity obj in Data.MapObject[region].entitys)
                {
                    foreach (Global.SectorObject.n7nEntity.sLine line in obj.OutLines)
                    {
                        // if not passable
                        if (line.flag != 0)
                        {
                            Line_A.x = obj.Points[line.PointA].x + obj.Position.x;
                            Line_A.y = obj.Points[line.PointA].y + obj.Position.y;
                            Line_B.x = obj.Points[line.PointB].x + obj.Position.x;
                            Line_B.y = obj.Points[line.PointB].y + obj.Position.y;

                            if (lineSegmentIntersection(fromPos, toPos, Line_A, Line_B, ref CollisionPoints))
                            {
                                Console.WriteLine("x:{0} y:{1}", gamex(CollisionPoints[0].x, fromPos.xSec), gamey(CollisionPoints[0].y, fromPos.ySec));
                            }
                        }
                    }
                }
                if (CollisionPoints.Count == 0)
                {
                    return(false);
                }

                // set the nearest collision point for return point
                double minDistance = gamedistance(fromPos.x, fromPos.y, CollisionPoints[0].x, CollisionPoints[0].y);
                foreach (Global.vektor cp in CollisionPoints)
                {
                    //double currentDistance = gamedistance(fromPos.x, fromPos.y, cp.x, cp.y);
                    double currentDistance = gamedistance(fromPos, cp);

                    if (currentDistance <= minDistance)
                    {
                        CollisionPoint.x = cp.x;
                        CollisionPoint.y = cp.y;
                    }
                }

                // translate the collision point on the movement line to get real coordinates (not the exact point of collision)
                double sin_alpha = Math.Abs(CollisionPoints[0].y - fromPos.y) / minDistance;
                double cos_alpha = Math.Abs(CollisionPoints[0].x - fromPos.x) / minDistance;

                CollisionPoints[0].y = (float)(sin_alpha * (minDistance - 3));
                CollisionPoints[0].x = (float)(cos_alpha * (minDistance - 3));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Collision detection failed: {0}", ex.Message);
            }
            return(true);
        }
Esempio n. 33
0
        public void ChangeDefPower_defp(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                int amount;
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["defp"] != 0)
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["defp"];
                        Target.Character.Action.Buff.UpdatedStats[slot].PhyDef = amount;
                        Target.Character.Stat.PhyDef += Target.Character.Action.Buff.UpdatedStats[slot].PhyDef;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["defp"] != 0)
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["defp"];
                        Target.Character.Action.Buff.UpdatedStats[slot].MagDef = amount;
                        Target.Character.Stat.MagDef += Target.Character.Action.Buff.UpdatedStats[slot].MagDef;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties3["defp"] != 0)
                    {
                        //nemtudjuk
                    }
                }
                else
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["defp"] != 0)
                    {
                        Target.Character.Stat.PhyDef -= Target.Character.Action.Buff.UpdatedStats[slot].PhyDef;
                        Target.Character.Action.Buff.UpdatedStats[slot].PhyDef = 0;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["defp"] != 0)
                    {
                        Target.Character.Stat.MagDef -= Target.Character.Action.Buff.UpdatedStats[slot].MagDef;
                        Target.Character.Action.Buff.UpdatedStats[slot].MagDef = 0;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties3["defp"] != 0)
                    {
                        //nemtudjuk
                    }
                }

                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 34
0
        public void ChangeMaxMP_mpi(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["mpi"] != 0) // point inc
                    {
                        int amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["mpi"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Mp = amount;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["mpi"] != 0) // %inc
                    {
                        int amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["mpi"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Mp = (Target.Character.Stat.Hp / 100) * (amount);
                    }

                    Target.Character.Stat.Mp += Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                    Target.Character.Stat.SecondMP += Target.Character.Action.Buff.UpdatedStats[slot].Mp;

                    if ((Target.Character.Stat.SecondMP + Target.Character.Action.Buff.UpdatedStats[slot].Mp) > Target.Character.Stat.Mp)
                    {
                        Target.Character.Stat.SecondMP = Target.Character.Stat.Mp;
                    }
                    else
                    {
                        Target.Character.Stat.SecondMP += Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                    }
                }
                else
                {
                    // sub it
                    Target.Character.Stat.Mp -= Target.Character.Action.Buff.UpdatedStats[slot].Mp;

                    // dont want negative mana
                    if (Target.Character.Stat.SecondMP - Target.Character.Action.Buff.UpdatedStats[slot].Mp < 1)
                    {
                        Target.Character.Stat.SecondMP = 1;
                    }
                    else
                    {
                        Target.Character.Stat.SecondMP -= Target.Character.Action.Buff.UpdatedStats[slot].Mp;
                    }

                    Target.Character.Action.Buff.UpdatedStats[slot].Mp = 0;
                }

                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
               Systems.Debugger.Write(ex);
            }
        }
Esempio n. 35
0
        public void ChangeHitrate_hr(Systems Target, int slot, bool delete,bool UpdatePacket)
        {
            try
            {
                //AttackRate = HitRate ???
                int amount;
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1.ContainsKey("hr"))
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["hr"];

                    }
                }

                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 36
0
        public void ChangePhyAtk_E2SA(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                int amount;
                if (!delete)
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2SA"] != 0)
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2SA"];
                        Target.Character.Action.Buff.UpdatedStats[slot].MinPhyAttack = (Target.Character.Stat.MinPhyAttack / 100) * amount;
                        Target.Character.Action.Buff.UpdatedStats[slot].MaxPhyAttack = (Target.Character.Stat.MaxPhyAttack / 100) * amount;
                        Target.Character.Stat.MinPhyAttack += Target.Character.Action.Buff.UpdatedStats[slot].MinPhyAttack;
                        Target.Character.Stat.MaxPhyAttack += Target.Character.Action.Buff.UpdatedStats[slot].MaxPhyAttack;
                    }

                }
                else
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["E2SA"] != 0)
                    {
                        Target.Character.Stat.MinPhyAttack -= Target.Character.Action.Buff.UpdatedStats[slot].MinPhyAttack;
                        Target.Character.Stat.MaxPhyAttack -= Target.Character.Action.Buff.UpdatedStats[slot].MaxPhyAttack;
                        Target.Character.Action.Buff.UpdatedStats[slot].MinPhyAttack = 0;
                        Target.Character.Action.Buff.UpdatedStats[slot].MaxPhyAttack = 0;
                    }

                }
                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 37
0
        public void ChangeMaxHP_hpi(Systems Target, int slot, bool delete, bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    int amount;
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["hpi"] != 0) // point inc
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["hpi"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Hp = amount;
                    }
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["hpi"] != 0) // %inc
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["hpi"];
                        Target.Character.Action.Buff.UpdatedStats[slot].Hp = (Target.Character.Stat.Hp / 100) * (amount);
                    }
                    // add it
                    Target.Character.Stat.Hp += Target.Character.Action.Buff.UpdatedStats[slot].Hp;
                    Target.Character.Stat.SecondHp += Target.Character.Action.Buff.UpdatedStats[slot].Hp;

                    if ((Target.Character.Stat.SecondHp + Target.Character.Action.Buff.UpdatedStats[slot].Hp) > Target.Character.Stat.Hp)
                    {
                        Target.Character.Stat.SecondHp = Target.Character.Stat.Hp;
                    }
                    else
                    {
                        Target.Character.Stat.SecondHp += Target.Character.Action.Buff.UpdatedStats[slot].Hp;
                    }
                }
                else
                {
                    // sub it
                    Target.Character.Stat.Hp -= Target.Character.Action.Buff.UpdatedStats[slot].Hp;

                    // dont kill him :)
                    if (Target.Character.Stat.SecondHp - Target.Character.Action.Buff.UpdatedStats[slot].Hp < 1)
                    {
                        Target.Character.Stat.SecondHp = 1;
                    }
                    else
                    {
                        Target.Character.Stat.SecondHp -= Target.Character.Action.Buff.UpdatedStats[slot].Hp;
                    }

                    Target.Character.Action.Buff.UpdatedStats[slot].Hp = 0;

                }

                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 38
0
 void DonateGP()
 {
     //First we write our function inside a catcher
     try
     {
         //Max level of guild wont allow new gp donations.
         if (Character.Network.Guild.Level == 5)
         {
             //Send error message to client
             client.Send(Packet.IngameMessages(SERVER_GUILD_PROMOTE_MSG, IngameMessages.UIIT_MSG_GUILD_LACK_GP));
             return;
         }
         //Open our packet reader
         PacketReader reader = new PacketReader(PacketInformation.buffer);
         //Read donated gp amount (int).
         int donatedgp = reader.Int32();
         //Close packet reader
         reader.Close();
         //Anti hack checking (If donated gp higher is then the player skillpoints.
         if (donatedgp > Character.Information.SkillPoint)
         {
             return;
         }
         //Calculate total
         int totalgp = Character.Network.Guild.PointsTotal + donatedgp;
         //Set guild points total
         Character.Network.Guild.PointsTotal += donatedgp;
         //Set skill points minus donated amount
         Character.Information.SkillPoint -= donatedgp;
         //Set donated gp + donated skill points
         Character.Network.Guild.DonateGP += donatedgp;
         //Save our information (Skill points).
         SavePlayerInfo();
         //Update database total guild points
         MsSQL.UpdateData("UPDATE guild SET guild_points='" + totalgp + "' WHERE guild_name='" + Character.Network.Guild.Name + "'");
         //Update database donated player guild points amount
         MsSQL.UpdateData("UPDATE guild_members SET guild_points='" + Character.Network.Guild.DonateGP + "' WHERE guild_member_id='" + Character.Information.CharacterID + "'");
         //Send packets to donator.
         client.Send(Packet.InfoUpdate(1, totalgp, 0));
         //Send donated gp info
         PacketWriter writer = new PacketWriter();
         //Add opcode
         writer.Create(Systems.SERVER_GUILD_DONATE_GP);
         //Write static byte 1
         writer.Byte(1);
         //Write dword int value donated gp amount.
         writer.DWord(donatedgp);
         //Send bytes to client
         client.Send(writer.GetBytes());
         //Repeat for each member in our guild
         foreach (int member in Character.Network.Guild.Members)
         {
             //Make sure that the member isnt null
             if (member != 0)
             {
                 //Now we get the detailed information for each member
                 Systems guildmember = GetPlayerMainid(member);
                 //Make sure the guildmember is still there
                 if (guildmember != null)
                 {
                     //Send guild update packets to each member (Donated gp information and % bar update).
                     guildmember.client.Send(Packet.GuildUpdate(Character, 13, 0, 0, totalgp));
                     guildmember.client.Send(Packet.GuildUpdate(Character, 9, 0, 0, totalgp));
                 }
             }
         }
     }
     //Catch any bad exception error
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("Donate GP Error {0}", ex);
         //Write information to the debug log.
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 39
0
        public void ChangeParry_er(Systems Target, int slot, bool delete,bool UpdatePacket)
        {
            try
            {
                if (!delete)
                {
                    int amount;
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["er"] != 0) // parry inc
                    {
                        amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["er"];

                        Target.Character.Action.Buff.UpdatedStats[slot].Parry = amount;
                        Target.Character.Stat.Parry += Target.Character.Action.Buff.UpdatedStats[slot].Parry;
                    }
                    else if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["er"] != 0) // parry %inc?
                    {

                    }
                }
                else
                {
                    if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["er"] != 0) // parry inc
                    {
                        Target.Character.Stat.Parry -= Target.Character.Action.Buff.UpdatedStats[slot].Parry;
                        Target.Character.Action.Buff.UpdatedStats[slot].Parry = 0;
                    }
                    else if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["er"] != 0) // parry %inc?
                    {
                    }
                }
                if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 40
0
        public static void ExecuteCommand(string aCommand, Socket aSocket)
        {
            try
            {
                if (aCommand != null)
                {
                    string[] command = aCommand.Split(' ');
                    if (command[0] == "/help")
                    {
                        if (aSocket == null)
                        {
                            Console.ForegroundColor = ConsoleColor.Cyan;
                            Console.WriteLine("                     Ingame notice: Type 1 space then message.");
                            Console.WriteLine("                     //clear");
                            Console.WriteLine("                     //repairitems");
                            Console.WriteLine("                     //respawn_unique");
                            Console.WriteLine("                     //event");
                            Console.WriteLine("                     //shutdown");
                            Console.WriteLine("                     //manager");

                            Console.ForegroundColor = ConsoleColor.Yellow;
                        }
                        else
                        {
                            sendSocket(aSocket, "Ingame notice: Type 1 space then message." + Environment.NewLine);
                            sendSocket(aSocket, "  //clear = cleanup unused memory" + Environment.NewLine);
                            sendSocket(aSocket, "  //repairitems" + Environment.NewLine);
                            sendSocket(aSocket, "  //respawn_unique" + Environment.NewLine);
                            sendSocket(aSocket, "  //event" + Environment.NewLine);
                            sendSocket(aSocket, "  //shutdown" + Environment.NewLine);
                        }
                    }
                    else if (command[0] == "//clear")
                    {
                        System.GC.Collect();
                        GC.Collect(0, GCCollectionMode.Forced);
                        sendSocket(aSocket, "done memory cleanup" + Environment.NewLine);
                    }
                    else if (command[0] == "//shutdown")
                    {
                        byte waitTime = 5;
                        if (command.Length > 1)
                        {
                            waitTime = System.Convert.ToByte(command[1]);
                        }
                        if (aSocket != null)
                        {
                            aSocket.Send(Encoding.ASCII.GetBytes("SHUTDOWN_START" + Environment.NewLine));
                        }

                        lock (Systems.clients)
                        {
                            Console.WriteLine("{0}stopping server and sending notice to clients ...", DarkEmu_GameServer.Global.Product.Prefix);
                            sendSocket(aSocket, "SHUTDOWN: stopping server and sending notice to clients ..." + Environment.NewLine);
                            net.ServerCheck(true);
                            net.Stop();  // disable any new connection
                            try
                            {
                                Systems.SendAll(Packet.ChatPacket(7, 0, "The server is stopping, your information will be saved.", ""));
                                Systems.SendAll(Packet.StartingLeaveGame(waitTime, 0));
                            }
                            catch { }
                            Thread.Sleep(waitTime);
                            Console.WriteLine("@SHUTDOWN: logoff clients ...");
                            sendSocket(aSocket, "@SHUTDOWN: logoff clients ..." + Environment.NewLine);
                            while (Systems.clients.Count > 0)
                            {
                                try
                                {
                                    try
                                    {
                                        Systems.clients[0].Send(Packet.EndLeaveGame());
                                    }
                                    catch { }
                                    //Ignore new character case (used for disconnect kick).
                                    Systems c = new Systems();
                                    Systems.clients[0].Disconnect("normal");
                                }
                                catch { }
                            }
                        }
                        sendSocket(aSocket, "SHUTDOWN_END" + Environment.NewLine);
                        cancelServer = true;
                        Systems.UpdateServerInfo(0);
                        //Environment.Exit(0);
                    }
                    else if (command[0] == "//repairitems")
                    {
                        int           fixeditem = 0;
                        Systems.MsSQL ms        = new Systems.MsSQL("SELECT * FROM char_items");
                        using (System.Data.SqlClient.SqlDataReader reader = ms.Read())
                        {
                            while (reader.Read())
                            {
                                short amount = reader.GetInt16(7);
                                if (amount < 1)
                                {
                                    fixeditem++;
                                    amount = 1;
                                    Systems.MsSQL.InsertData("UPDATE char_items SET quantity='" + amount + "' WHERE itemnumber='" + "item" + reader.GetByte(5) + "' AND owner='" + reader.GetInt32(3) + "' AND itemid='" + reader.GetInt32(2) + "'");
                                }
                            }
                        }
                        Console.ForegroundColor = ConsoleColor.Magenta;
                        Console.WriteLine("@Gameserver:         Items Repaired:           {0}", fixeditem);
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        sendSocket(aSocket, String.Format("@Gameserver: Items Repaired: {0}", fixeditem) + Environment.NewLine);
                    }
                    else if (command[0] == "//respawn_unique")
                    {
                        DarkEmu_GameServer.GlobalUnique.StartTGUnique(6000 * 10, 6000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartUriUnique(7000 * 10, 7000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIsyUnique(8000 * 10, 8000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartLordUnique(9000 * 10, 9000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartDemonUnique(10000 * 10, 10000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartCerbUnique(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIvyUnique(11000 * 10, 11000 * 10);
                        //Game.GlobalUnique.StartRoc(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartMedusa(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartNeith(11000 * 10, 11000 * 10);
                        //Game.GlobalUnique.StartSphinx(11000 * 10, 11000 * 10);
                        DarkEmu_GameServer.GlobalUnique.StartIsis(11000 * 10, 11000 * 10);
                        sendSocket(aSocket, "done respawn" + Environment.NewLine);
                    }
                    else if (command[0] == "//event")
                    {
                        EventMain eventnew = new EventMain(System.IO.Directory.GetCurrentDirectory() + "/data/event.txt");
                        eventnew.Start();
                        sendSocket(aSocket, "Event Started" + Environment.NewLine);
                    }
                    else if (command[0] == "")
                    {
                        string information           = aCommand;
                        DarkEmu_GameServer.Systems c = new DarkEmu_GameServer.Systems();
                        DarkEmu_GameServer.Systems.SendAll(c.sendnoticecon(7, 0, information, ""));

                        Console.WriteLine("Notice: " + information);
                        sendSocket(aSocket, "Sent Notice: " + information + Environment.NewLine);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Program.Main {0}", ex);
            }
        }
Esempio n. 41
0
 public void ChangeRange_ru(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         if (!delete)
         {
             int amount;
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["ru"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["ru"];
                 Target.Character.Action.Buff.UpdatedStats[slot].EkstraMetre = (byte)amount;
                 Target.Character.Stat.EkstraMetre += Target.Character.Action.Buff.UpdatedStats[slot].EkstraMetre;
             }
         }
         else
         {
             Target.Character.Stat.EkstraMetre -= Target.Character.Action.Buff.UpdatedStats[slot].EkstraMetre;
             Target.Character.Action.Buff.UpdatedStats[slot].EkstraMetre = 0;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 42
0
        void ActionNormalAttack()
        {
            try
            {
                float x = 0, y = 0;

                bool[] aRound = null;

                if (Character.Action.Object != null)
                {
                    //Set target object as object
                    obj TargetInformation = Character.Action.Object as obj;
                    //If our target object is a monster
                    #region Attacking a monster
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.MONSTER)
                    {
                        //If state is dead
                        if (TargetInformation.State == 4)
                        {
                            //Set normal attack bool to false
                            Character.Action.nAttack = false;
                            //Stop attack timer
                            StopAttackTimer();
                        }

                        if (TargetInformation.Agro == null)
                        {
                            TargetInformation.Agro = new List <_agro>();
                        }
                        x = (float)TargetInformation.x;
                        y = (float)TargetInformation.y;

                        if (!TargetInformation.Attacking)
                        {
                            TargetInformation.AddAgroDmg(Character.Information.UniqueID, 1);
                        }
                        if (TargetInformation.Die || TargetInformation.GetDie)
                        {
                            StopAttackTimer();
                            return;
                        }
                    }
                    #endregion
                    //If attacking a player
                    #region Attacking a player
                    if (Data.ObjectBase[TargetInformation.ID].Object_type == Global.objectdata.NamdedType.PLAYER)
                    {
                        if (!Character.Information.PvP)
                        {
                            Character.Action.nAttack = false;
                            StopAttackTimer();
                            return;
                        }

                        Systems sys = Character.Action.Object as Systems;
                        if (sys.Character.State.LastState == 4)
                        {
                            StopAttackTimer();
                            return;
                        }

                        if (!(Character.Information.PvP && sys.Character.Information.PvP))
                        {
                            StopAttackTimer();
                            return;
                        }
                        if (!Character.InGame)
                        {
                            StopAttackTimer();
                            return;
                        }
                        x      = sys.Character.Position.x;
                        y      = sys.Character.Position.y;
                        aRound = sys.Character.aRound;
                    }
                    #endregion

                    double distance = Formule.gamedistance(Character.Position.x,
                                                           Character.Position.y,
                                                           x,
                                                           y);

                    if (Character.Information.Item.wID == 0)
                    {
                        distance -= 0.5;
                    }
                    else
                    {
                        distance -= Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                    }

                    if (distance > 0)
                    {
                        float farkx = x;
                        float farky = y;

                        if (Character.Information.Item.wID == 0)
                        {
                            Character.Position.wX = farkx - Character.Position.x - 0;
                            Character.Position.wY = farky - Character.Position.y - 0;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }
                        else
                        {
                            Character.Position.wX = farkx - Character.Position.x - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.wY = farky - Character.Position.y - (float)Data.ItemBase[Character.Information.Item.wID].ATTACK_DISTANCE;
                            Character.Position.kX = Character.Position.wX;
                            Character.Position.kY = Character.Position.wY;
                        }

                        Send(Packet.Movement(new DarkEmu_GameServer.Global.vektor(Character.Information.UniqueID,
                                                                                  (float)Formule.packetx((float)farkx, Character.Position.xSec),
                                                                                  (float)Character.Position.z,
                                                                                  (float)Formule.packety((float)farky, Character.Position.ySec),
                                                                                  Character.Position.xSec,
                                                                                  Character.Position.ySec)));

                        Character.Position.Time         = (distance / (Character.Speed.RunSpeed * 0.0768)) * 1000.0;
                        Character.Position.RecordedTime = Character.Position.Time;

                        Character.Position.packetxSec = Character.Position.xSec;
                        Character.Position.packetySec = Character.Position.ySec;

                        Character.Position.packetX = (ushort)Formule.packetx((float)farkx, Character.Position.xSec);
                        Character.Position.packetY = (ushort)Formule.packety((float)farky, Character.Position.ySec);

                        Character.Position.Walking = true;

                        StartMovementTimer((int)(Character.Position.Time * 0.1));

                        return;
                    }
                }
                ActionAttack();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Normal Attack Error : {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 43
0
 public void ChangeStr_stri(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         if (!delete)
         {
             int amount;
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["stri"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["stri"];
                 Target.Character.Action.Buff.UpdatedStats[slot].Strength = (short)amount;
             }
             /*if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2.ContainsKey("stri"))
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["stri"];
                 Target.Character.Action.Buff.UpdatedStats[slot].Strength = (short)((Target.Character.Stat.Strength / 100) * (amount));
             }*/
             Target.Character.Stat.Strength += Target.Character.Action.Buff.UpdatedStats[slot].Strength;
         }
         else
         {
             Target.Character.Stat.Strength -= Target.Character.Action.Buff.UpdatedStats[slot].Strength;
             Target.Character.Action.Buff.UpdatedStats[slot].Strength = 0;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 44
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);
            }
        }
Esempio n. 45
0
 public void Change_spda(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         double amount;
         if (!delete)
         {
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1.ContainsKey("spda"))  //Phydef decrease?
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["spda"];
                 Target.Character.Action.Buff.UpdatedStats[slot].uPhyDef = (Target.Character.Stat.PhyDef / 100) * (amount);
                 Target.Character.Stat.PhyDef -= Target.Character.Action.Buff.UpdatedStats[slot].uPhyDef;
             }
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2.ContainsKey("spda")) //Phy attack inc?
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["spda"];
                 Target.Character.Stat.UpdatededPhyAttack = (Target.Character.Stat.MaxPhyAttack / 100) * (amount);
                 Target.Character.Stat.MaxPhyAttack += Target.Character.Stat.UpdatededPhyAttack;
             }
         }
         else
         {
             Target.Character.Stat.PhyDef += Target.Character.Action.Buff.UpdatedStats[slot].uPhyDef;
             Target.Character.Stat.MaxPhyAttack -= Target.Character.Stat.UpdatededPhyAttack;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 46
0
        void Chat()
        {
            /*
             *  We use for each now, to make sure there wont be any issues
             *  Incase the list we send the packet to can have none connected clients.
             *  To prevent bugging of chat we repeat and check each client before sending.
             */
            try
            {
                //Set our list of ranged players
                List <int> Rangedplayers = Character.Spawn;
                //Create new packet reader for reading packet data
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Chat type byte (for our switch case).
                byte chatType = Reader.Byte();
                //Byte chat index
                byte chatIndex = Reader.Byte();
                //Link count byte
                byte linkCount = Reader.Byte();
                //Create switch to switch on type of chat (normal party etc).
                switch (chatType)
                {
                //--------------------------------- [Normal chat] ---------------------------------//
                case 1:
                    //Read written text from packet data
                    string Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();

                    // .additem 111 12
                    if (Character.Information.GM == 1 && Text[0] == '.')
                    {
                        gmCommands(Text);
                    }

                    //Repeat for each in range player
                    foreach (int member in Rangedplayers)
                    {
                        //Make sure the member is not null
                        if (member != 0)
                        {
                            //Make sure its not sending to our client
                            if (member != Character.Information.UniqueID)
                            {
                                //Get member detail
                                Systems memberinfo = GetPlayer(member);
                                //Send packet to the in range player
                                memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                            }
                        }
                    }
                    //Send chatindex packet to ourselfs
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;

                //--------------------------------- [Normal chat pink] ---------------------------------//
                case 3:
                    //Check if our character has gm rights or not
                    if (Character.Information.GM == 1)
                    {
                        //Read packet information (text typed).
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each player in our range list
                        foreach (int member in Rangedplayers)
                        {
                            //Check if the member is not null
                            if (member != 0)
                            {
                                //Make sure its not sending to our own client
                                if (member != Character.Information.UniqueID)
                                {
                                    //Get member detail
                                    Systems memberinfo = GetPlayer(member);
                                    //Send packet to the member
                                    memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                                }
                            }
                        }
                        //Send chat index to our client
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        break;
                    }
                    //If character tried to use pink chat but isnt a gm
                    else
                    {
                        //We ban the player for hacking attempt.
                        Disconnect("ban");
                    }
                    break;

                //--------------------------------- [Private chat] ---------------------------------//
                case 2:
                    //Read from packet data who we are sending the message to
                    string Target = Reader.Text();
                    //Get information from the given player we send to
                    Systems Targetplayer = GetPlayerName(Target);
                    //Make sure the player sending to is not null
                    if (Targetplayer != null)
                    {
                        //Make sure the player is ingame (Not teleporting or such).
                        if (Targetplayer.Character.InGame)
                        {
                            //Read the message from the packet data
                            Text = Reader.Text3();
                            //Close the packet reader
                            Reader.Close();
                            //Send packet to our target
                            Targetplayer.client.Send(Packet.ChatPacket(chatType, 0, Text, this.Character.Information.Name));
                            //Send chatindex packet to ourselfs
                            client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        }
                    }
                    break;

                //--------------------------------- [Party chat] ---------------------------------//
                case 4:
                    //Make sure the player is in a party
                    if (Character.Network.Party != null)
                    {
                        //Read the text the player has typed from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each member in the party member list
                        foreach (int member in Character.Network.Party.Members)
                        {
                            //Make sure the member isnt null (0)
                            if (member != 0)
                            {
                                //Get detailed info for the player
                                Systems memberinfo = GetPlayer(member);
                                //Send packet information to the member for chat
                                memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                            }
                        }
                        //Finally send chatindex packet to ourselfs
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    }

                    break;

                //--------------------------------- [Guild chat] ---------------------------------//
                case 5:
                    //Read message beeing send from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //Repeat for each member in the guild member list
                    foreach (int member in Character.Network.Guild.Members)
                    {
                        //Make sure the member is not null (0)
                        if (member != 0)
                        {
                            //Get guild member detailed information
                            Systems Guildmember = GetPlayerMainid(member);
                            //Again check if the guild member is not null
                            if (Guildmember != null)
                            {
                                //Send chat packet to the member
                                Guildmember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                            }
                        }
                    }
                    //Send chat index packet to our client
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));

                    break;

                //--------------------------------- [Global chat] ---------------------------------//
                case 6:
                    //Get sender name from packet data
                    string Sender = Reader.Text();
                    //Get message from packet data
                    Text = Reader.Text3();
                    //Send to every client connected and logged in
                    SendAll(Packet.ChatPacket(chatType, Character.Information.UniqueID, " " + Text, Sender));
                    break;

                //--------------------------------- [Notice chat] ---------------------------------//
                case 7:
                    //Make sure the character sending is a gm
                    if (Character.Information.GM == 1)
                    {
                        //Get message from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Send to everyone ingame (using void sendnoticecon).
                        SendAll(sendnoticecon(chatType, Character.Information.UniqueID, Text, null));
                    }
                    //If the character is not a gm
                    else
                    {
                        //Disconnect and ban the player for hack attempt
                        Disconnect("ban");
                    }
                    break;

                //--------------------------------- [Stall chat] ---------------------------------//
                case 9:
                    //Read message from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //Repeat for each member in the stall
                    foreach (int stallmember in Character.Network.Stall.Members)
                    {
                        //Make sure the stall member isnt null 0
                        if (stallmember != 0)
                        {
                            //Get stall member details
                            Systems member = GetPlayer(stallmember);
                            //Make sure the member isnt null
                            if (member != null)
                            {
                                //Send chat packet to the member
                                member.client.Send(Packet.ChatPacket(chatType, Character.Network.Stall.ownerID, Text, this.Character.Information.Name));
                            }
                        }
                    }
                    //Send chat index to ourselfs
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;

                //--------------------------------- [Academy chat] ---------------------------------//
                case 10:
                    //Todo academy system then chat.
                    break;

                //--------------------------------- [Union chat] ---------------------------------//
                case 11:
                    //Read message from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //If the character has no union
                    if (!Character.Network.Guild.UnionActive)
                    {
                        //Return
                        return;
                    }
                    //Else for each member in the union
                    foreach (int member in Character.Network.Guild.UnionMembers)
                    {
                        //Make sure the union member is not null 0
                        if (member != 0)
                        {
                            //Get member detailed information
                            Systems tomember = GetPlayerMainid(member);
                            //Make sure the member is not null
                            if (tomember != null)
                            {
                                //Make sure the member isnt ourself
                                if (tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                {
                                    //Send packet to the union member
                                    tomember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, Character.Information.Name));
                                }
                            }
                        }
                    }
                    //Repeat for each member in the guild
                    foreach (int member in Character.Network.Guild.Members)
                    {
                        //Make sure the member isnt null 0
                        if (member != 0)
                        {
                            //Get member detailed information
                            Systems tomember = GetPlayerMainid(member);
                            //Make sure the member isnt null
                            if (tomember != null)
                            {
                                //Make sure the member isnt ourself
                                if (tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                {
                                    //Send packet to the member
                                    tomember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                    }
                    //Finally send chat index packet to ourself
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;
                }
            }
            //If an exception error happens
            catch (Exception errorinformation)
            {
                //Write the information to the console
                Console.WriteLine("Chat error {0}", errorinformation);
                //Write the information to the log system
                Systems.Debugger.Write(errorinformation);
            }
        }
Esempio n. 47
0
        public static void StallItemPacket(List <stall.stallItem> ItemList, PacketWriter Writer)
        {
            for (byte i = 0; i < ItemList.Count; i++)
            {
                //Define item id
                int itemid = ItemList[i].Item.ID;
                //Temp disable mall type, todo : Enable PRE-Mall to sell in stalls.
                if (Data.ItemBase[itemid].Name.Contains("MALL"))
                {
                    return;
                }

                Systems.LoadBluesid(ItemList[i].Item.dbID);

                Writer.Byte(ItemList[i].stallSlot);
                Writer.DWord(0);
                Writer.DWord(itemid);

                //Define what types of item we are adding to the stall
                if (Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ARMOR ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GARMENT ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.GM ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.HEAVY ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.LIGHT ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.PROTECTOR ||
                    Data.ItemBase[itemid].Type == Global.item_database.ArmorType.ROBE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EARRING ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.RING ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.NECKLACE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BLADE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BOW ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_AXE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_HARP ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.GLAVIE ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SPEAR ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.SWORD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                    Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.EU_SHIELD)
                {
                    Writer.Byte(ItemList[i].Item.PlusValue);
                    Writer.LWord(0);
                    Writer.DWord(Data.ItemBase[ItemList[i].Item.ID].Defans.Durability);
                    if (Data.ItemBlue[ItemList[i].Item.dbID].totalblue != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[ItemList[i].Item.dbID].totalblue));
                        for (int a = 1; a <= Data.ItemBlue[ItemList[i].Item.dbID].totalblue; a++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[ItemList[i].Item.dbID].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[ItemList[i].Item.dbID].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Word(1);
                    Writer.Word(2);
                    Writer.Word(3);
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.STONES)
                {
                    Writer.Word(ItemList[i].Item.Amount);
                    Writer.Byte(0);
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    Writer.DWord(0);//Todo : Load monster mask monster model id here
                    return;
                }
                else if (Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ELIXIR)
                {
                    Writer.Word(1);
                }
                else if (Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.ARROW ||
                         Data.ItemBase[itemid].Itemtype == Global.item_database.ItemType.BOLT ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.HP_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.MP_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.VIGOR_POTION ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.SPEED_POTION ||
                         Data.ItemBase[itemid].Ticket == Global.item_database.Tickets.BEGINNER_HELPERS ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ELIXIR ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.ALCHEMY_MATERIAL ||
                         Data.ItemBase[itemid].Etctype == Global.item_database.EtcType.EVENT ||
                         Data.ItemBase[itemid].Class_D == 3)
                {
                    Writer.Word(ItemList[i].Item.Amount);
                }
                Writer.Byte(ItemList[i].Item.Slot);
                Writer.Word(ItemList[i].Item.Amount);
                Writer.LWord(ItemList[i].price);
            }
            Writer.Byte(0xFF);
        }
Esempio n. 48
0
        // collision detection 2D - /With Linear Algebra/
        public static bool isCollided_onMovement(Global.vektor fromPos, Global.vektor toPos, ref Global.vektor CollisionPoint, Systems c)
        {
            try
            {
                fromPos.x = packetx(fromPos.x, fromPos.xSec) / 20.0f;
                fromPos.y = packety(fromPos.y, fromPos.ySec) / 20.0f;
                toPos.x = packetx(toPos.x, toPos.xSec) / 20.0f;
                toPos.y = packety(toPos.y, toPos.ySec) / 20.0f;

                // iterated line
                Global.vektor Line_A = new Global.vektor();
                Global.vektor Line_B = new Global.vektor();

                List<Global.vektor> CollisionPoints = new List<Global.vektor>();

                // get current region to filter out the objects
                short region = makeRegion(fromPos.xSec, fromPos.ySec);

                // get all entitys in this region and try to cut them with our movement line
                foreach (Global.SectorObject.n7nEntity obj in Data.MapObject[region].entitys)
                {
                    foreach (Global.SectorObject.n7nEntity.sLine line in obj.OutLines)
                    {
                        // if not passable
                        if (line.flag != 0)
                        {
                            Line_A.x = obj.Points[line.PointA].x + obj.Position.x;
                            Line_A.y = obj.Points[line.PointA].y + obj.Position.y;
                            Line_B.x = obj.Points[line.PointB].x + obj.Position.x;
                            Line_B.y = obj.Points[line.PointB].y + obj.Position.y;

                            if (lineSegmentIntersection(fromPos, toPos, Line_A, Line_B, ref CollisionPoints))
                            {

                                Console.WriteLine("x:{0} y:{1}", gamex(CollisionPoints[0].x, fromPos.xSec), gamey(CollisionPoints[0].y, fromPos.ySec));
                            }
                        }
                    }
                }
                if (CollisionPoints.Count == 0) return false;

                // set the nearest collision point for return point
                double minDistance = gamedistance(fromPos.x, fromPos.y, CollisionPoints[0].x, CollisionPoints[0].y);
                foreach (Global.vektor cp in CollisionPoints)
                {
                    //double currentDistance = gamedistance(fromPos.x, fromPos.y, cp.x, cp.y);
                    double currentDistance = gamedistance(fromPos, cp);

                    if (currentDistance <= minDistance)
                    {
                        CollisionPoint.x = cp.x;
                        CollisionPoint.y = cp.y;
                    }
                }

                // translate the collision point on the movement line to get real coordinates (not the exact point of collision)
                double sin_alpha = Math.Abs(CollisionPoints[0].y - fromPos.y) / minDistance;
                double cos_alpha = Math.Abs(CollisionPoints[0].x - fromPos.x) / minDistance;

                CollisionPoints[0].y = (float)(sin_alpha * (minDistance - 3));
                CollisionPoints[0].x = (float)(cos_alpha * (minDistance - 3));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Collision detection failed: {0}", ex.Message);
            }
            return true;
        }
Esempio n. 49
0
 /////////////////////////////////////////////////////////////////////////////////
 // Spawn system (Spawn our char to others).
 /////////////////////////////////////////////////////////////////////////////////   
 void ObjectPlayerSpawn(Systems s)
 {
     try
     {
         if (!s.Character.Spawned(this.Character.Information.UniqueID) && this.Character.Information.UniqueID != 0 && !s.Character.Spawning)
         {
             //We loop the spawn check for the player that needs it.
             s.ObjectSpawnCheck();
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Object player spawn error {0}", ex);
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 50
0
        public void AddRemoveBlues(Systems ch, Global.slotItem item, bool add)
        {
            try
            {
                LoadBluesid(item.dbID);
                string name;
                if (Data.ItemBlue.ContainsKey(item.dbID))
                {
                    for (int k = 0; k < Data.ItemBlue[item.dbID].totalblue; k++)
                    {
                        name = Convert.ToString(Data.ItemBlue[item.dbID].blue[k]);
                        switch (name)
                        {
                            case "MATTR_INT":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_INT"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_STR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_STR"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }

                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_LUCK":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_LUCK"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_HP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_HP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_MP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_MP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_REGENHPMP": // hp/mp regen inc(%)
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_REGENHPMP"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.mpregen += Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Blues.hpregen += Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.mpregen -= Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Blues.hpregen -= Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_RESIST_FROSTBITE":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_FROSTBITE"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Frostbite += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Frostbite -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_ESHOCK":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_ESHOCK"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Eshock += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Eshock -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_BURN":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_BURN"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Burn += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Burn -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_POISON":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_POISON"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Poison += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Poison -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_ZOMBIE":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_ZOMBIE"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Zombie += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Zombie -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_STR_3JOB":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_STR_3JOB"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_INT_3JOB":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_INT_3JOB"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_STR_AVATAR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_STR_AVATAR"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_INT_AVATAR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_INT_AVATAR"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_STR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_STR"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_INT":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_INT"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_HR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_HR"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UpdatedStats[item.dbID].Hit = (ch.Character.Stat.Hit / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.Hit += ch.Character.Blues.UpdatedStats[item.dbID].Hit;
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Hit -= ch.Character.Blues.UpdatedStats[item.dbID].Hit;
                                        ch.Character.Blues.UpdatedStats[item.dbID].Hit = 0;
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_ER":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_ER"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UpdatedStats[item.dbID].Parry = (ch.Character.Stat.Parry / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.Parry += ch.Character.Blues.UpdatedStats[item.dbID].Parry;
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Parry -= ch.Character.Blues.UpdatedStats[item.dbID].Parry;
                                        ch.Character.Blues.UpdatedStats[item.dbID].Parry = 0;
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_ER": //parry rate inc
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_ER"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UpdatedStats[item.dbID].Parry = (ch.Character.Stat.Parry / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.Parry += ch.Character.Blues.UpdatedStats[item.dbID].Parry;
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Parry -= ch.Character.Blues.UpdatedStats[item.dbID].Parry;
                                        ch.Character.Blues.UpdatedStats[item.dbID].Parry = 0;
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_HR": //attack rate inc (%)
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_HR"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UpdatedStats[item.dbID].Hit = (ch.Character.Stat.Hit / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.Hit += ch.Character.Blues.UpdatedStats[item.dbID].Hit;
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Hit -= ch.Character.Blues.UpdatedStats[item.dbID].Hit;
                                        ch.Character.Blues.UpdatedStats[item.dbID].Hit = 0;
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_HP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_HP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_MP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_DRUA": // damage increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_DRUA"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UpdatedStats[item.dbID].MinPhyAttack = (ch.Character.Stat.MinPhyAttack / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Blues.UpdatedStats[item.dbID].MaxPhyAttack = (ch.Character.Stat.MaxPhyAttack / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Blues.UpdatedStats[item.dbID].MinMagAttack = (ch.Character.Stat.MinMagAttack / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Blues.UpdatedStats[item.dbID].MaxMagAttack = (ch.Character.Stat.MaxMagAttack / 100) * Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);

                                        ch.Character.Stat.MinPhyAttack += ch.Character.Blues.UpdatedStats[item.dbID].MinPhyAttack;
                                        ch.Character.Stat.MaxPhyAttack += ch.Character.Blues.UpdatedStats[item.dbID].MaxPhyAttack;
                                        ch.Character.Stat.MinMagAttack += ch.Character.Blues.UpdatedStats[item.dbID].MinMagAttack;
                                        ch.Character.Stat.MaxMagAttack += ch.Character.Blues.UpdatedStats[item.dbID].MaxMagAttack;
                                    }
                                    else
                                    {
                                        ch.Character.Stat.MinPhyAttack -= ch.Character.Blues.UpdatedStats[item.dbID].MinPhyAttack;
                                        ch.Character.Stat.MaxPhyAttack -= ch.Character.Blues.UpdatedStats[item.dbID].MaxPhyAttack;
                                        ch.Character.Stat.MinMagAttack -= ch.Character.Blues.UpdatedStats[item.dbID].MinMagAttack;
                                        ch.Character.Stat.MaxMagAttack -= ch.Character.Blues.UpdatedStats[item.dbID].MaxMagAttack;
                                        ch.Character.Blues.UpdatedStats[item.dbID].MinPhyAttack = 0;
                                        ch.Character.Blues.UpdatedStats[item.dbID].MaxPhyAttack = 0;
                                        ch.Character.Blues.UpdatedStats[item.dbID].MinMagAttack = 0;
                                        ch.Character.Blues.UpdatedStats[item.dbID].MaxMagAttack = 0;
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_DARA": // damage absorption
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_DARA"))
                                {
                                    if (add)
                                    {
                                        //ch.Character.Stat.phy_Absorb += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        //ch.Character.Stat.mag_Absorb += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        //ch.Character.Stat.phy_Absorb -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        //ch.Character.Stat.mag_Absorb -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_MDIA": // ignore monster defense
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MDIA"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.MonsterIgnorance += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.MonsterIgnorance -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_HPRG": //hp recovery increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_HPRG"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.hpregen += Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.hpregen -= Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_MPRG": //mp recovery increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MPRG"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.mpregen += Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.mpregen -= Convert.ToDouble(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_RESIST_STUN":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_STUN"))
                                {
                                    if (add)
                                        ch.Character.Blues.Resist_Stun += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Stun -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_CSMP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_CSMP"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_CSMP += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_CSMP -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_DISEASE":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_DISEASE"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Disease += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Disease -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_SLEEP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_SLEEP"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Sleep += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Sleep -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_FEAR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_FEAR"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_Fear += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_Fear -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_NASRUN_UMDU": //damage increase(only @ uniques)
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_NASRUN_UMDU"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.UniqueDMGInc += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.UniqueDMGInc += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_NASRUN_HPNA": //maximum hp increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_NASRUN_HPNA"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Hp += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.SecondHp += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Hp -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.SecondHp -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_NASRUN_MPNA": //maximum mp increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_NASRUN_MPNA"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Mp += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.SecondMP += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Mp -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.Character.Stat.SecondMP -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_NASRUN_BLOCKRATE": //blocking rate increase
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_NASRUN_BLOCKRATE"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.BlockRatio += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Stat.BlockRatio -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_STR_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_STR_SET"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_INT_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_INT_SET"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_ER_SET":
                                break;
                            case "MATTR_HP_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_HP_SET"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();

                                }
                                break;
                            case "MATTR_MP_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_MP_SET"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_LUCK_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_LUCK_SET"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_AVATAR_STR_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_STR_2"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_STR_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_STR_3"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_STR_4":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_STR_4"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_INT_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_INT_2"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_INT_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_INT_3"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_INT_4":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_INT_4"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_AVATAR_MDIA_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MDIA_2"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.MonsterIgnorance += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.MonsterIgnorance -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_MDIA_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MDIA_3"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.MonsterIgnorance += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.MonsterIgnorance -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_MDIA_4":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_MDIA_4"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Blues.MonsterIgnorance += Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                    else
                                    {
                                        ch.Character.Blues.MonsterIgnorance -= Convert.ToInt32(Data.ItemBlue[item.dbID].blueamount[k]);
                                    }
                                }
                                break;
                            case "MATTR_AVATAR_LUCK":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_LUCK"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_AVATAR_LUCK_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_LUCK_2"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_AVATAR_LUCK_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_LUCK_4"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_AVATAR_LUCK_4":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_AVATAR_LUCK_4"))
                                {

                                    if (add)
                                        ch.Character.Blues.Luck += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Luck -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_RESIST_ALL_SET":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_RESIST_ALL_SET"))
                                {

                                    if (add)
                                        ch.Character.Blues.Resist_All += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Blues.Resist_All -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                }
                                break;
                            case "MATTR_TRADE_STR":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_STR"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_STR_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_STR_2"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_STR_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_STR_3"))
                                {

                                    if (add)
                                    {
                                        ch.Character.Stat.Strength += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Strength -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateStrengthMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateHp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_INT":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_INT"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_INT_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_INT_2"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_INT_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_INT_3"))
                                {
                                    if (add)
                                    {
                                        ch.Character.Stat.Intelligence += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceInfo(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    else
                                    {
                                        ch.Character.Stat.Intelligence -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                        ch.UpdateIntelligenceMinus(Convert.ToSByte(Data.ItemBlue[item.dbID].blueamount[k]));
                                        ch.SetStat();
                                        ch.UpdateMp();
                                    }
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_HP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_HP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_HP_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_HP_2"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_HP_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_HP_3"))
                                {

                                    if (add)
                                        ch.Character.Stat.Hp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Hp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateHp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_MP":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_MP"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_MP_2":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_MP_2"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                            case "MATTR_TRADE_MP_3":
                                if (Data.ItemBlue[item.dbID].blue.Contains("MATTR_TRADE_MP_3"))
                                {

                                    if (add)
                                        ch.Character.Stat.Mp += Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);
                                    else
                                        ch.Character.Stat.Mp -= Convert.ToInt16(Data.ItemBlue[item.dbID].blueamount[k]);

                                    ch.client.Send(Packet.PlayerStat(ch.Character));
                                    ch.UpdateMp();
                                    ch.SavePlayerInfo();
                                }
                                break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("[BlueSystem] ItemBlue for ID {0} not found", item.dbID);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Blue add/remove error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 51
0
        public static byte[] Party_Data(byte type, int id)
        {
            //Create new packet writer
            PacketWriter Writer = new PacketWriter();

            //Add opcode
            Writer.Create(Systems.SERVER_PARTY_DATA);
            //Write type byte
            Writer.Byte(type);
            //Create switch for type given
            switch (type)
            {
            case 1:
                //Remove party state
                Writer.Byte(0x0b);
                Writer.Byte(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 2:
                //Formed party new member update
                Systems CharacterInformation = Systems.GetPlayer(id);
                //Write static byte
                Writer.Byte(0xFF);
                //Write unique character id
                Writer.DWord(CharacterInformation.Character.Information.UniqueID);
                //Write character name
                Writer.Text(CharacterInformation.Character.Information.Name);
                //Write character model
                Writer.DWord(CharacterInformation.Character.Information.Model);
                //Write character level
                Writer.Byte(CharacterInformation.Character.Information.Level);
                //Write static byte
                Writer.Byte(0xAA);
                //Write x and y sector
                Writer.Byte(CharacterInformation.Character.Position.xSec);
                Writer.Byte(CharacterInformation.Character.Position.ySec);
                //Write x z y
                Writer.Word(Formule.packetx(CharacterInformation.Character.Position.x, CharacterInformation.Character.Position.xSec));
                Writer.Word(CharacterInformation.Character.Position.z);
                Writer.Word(Formule.packety(CharacterInformation.Character.Position.y, CharacterInformation.Character.Position.ySec));
                //Write double word 1
                Writer.Word(1);
                Writer.Word(1);
                //If character is in a guild
                if (CharacterInformation.Character.Network.Guild.Name != null)
                {
                    //Write guild name
                    Writer.Text(CharacterInformation.Character.Network.Guild.Name);
                }
                //If character has no guild
                else
                {
                    //Write 0 word value
                    Writer.Word(0);
                }
                //Static byte
                Writer.Byte(0);
                //Permissions
                Writer.DWord(0);
                Writer.DWord(0);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 3:
                //Write character id
                Writer.DWord(id);
                //Write static byte 4
                Writer.Byte(4);
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 6:
                //Update player location and stat
                CharacterInformation = Systems.GetPlayer(id);
                //Calculate hp and mp
                int partyPercentMP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondMP * 10) / CharacterInformation.Character.Stat.Mp) << 4;
                int partyPercentHP = (int)Math.Round((decimal)(CharacterInformation.Character.Stat.SecondHp * 10) / CharacterInformation.Character.Stat.Hp);
                //Set percent information
                int partyPercent = partyPercentHP | partyPercentMP;
                //Write character id
                Writer.DWord(id);
                //If character is moving
                if (CharacterInformation.Character.Position.Walking)
                {
                    //Write byte 20
                    Writer.Byte(0x20);
                    //Write location information
                    Writer.Byte(CharacterInformation.Character.Position.packetxSec);
                    Writer.Byte(CharacterInformation.Character.Position.packetySec);
                    Writer.Word(CharacterInformation.Character.Position.packetX);
                    Writer.Word(CharacterInformation.Character.Position.packetZ);
                    Writer.Word(CharacterInformation.Character.Position.packetY);
                    //Write double word 1
                    Writer.Word(1);
                    Writer.Word(1);
                }
                //If not walking
                else
                {
                    //Write static byte 4
                    Writer.Byte(4);
                    //Write hp mp information
                    Writer.Byte((byte)partyPercent);
                }
                //Return all bytes for sending
                return(Writer.GetBytes());

            case 9:
                //New leader id
                Writer.DWord(id);
                //Return all bytes for sending
                return(Writer.GetBytes());
            }
            //Return all bytes for sending
            return(Writer.GetBytes());
        }
Esempio n. 52
0
 void GuildStorage()
 {
     //Wrap our function inside a catcher
     try
     {
         //If guild level is to low send message
         if (Character.Network.Guild.Level == 1)
         {
             //Need to sniff to check what opcode is sending for the message
             client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_STORAGE, IngameMessages.GUILD_STORAGE_LEVEL_TO_LOW));
         }
         //If guild level is 2 meaning it has storage option
         else
         {
             //Make sure the user has guild storage rights
             if (Character.Network.Guild.guildstorageRight)
             {
                 //Check if other guild members are currently in storage
                 foreach (int member in Character.Network.Guild.Members)
                 {
                     //Make sure member isnt 0
                     if (member != 0)
                     {
                         //Get player details
                         Systems getplayer = GetPlayerMainid(member);
                         //Make sure player isnt null
                         if (getplayer != null)
                         {
                             //Check if the player is using storage
                             if (getplayer.Character.Network.Guild.UsingStorage)
                             {
                                 //Send storage message error
                                 client.Send(Packet.IngameMessages(Systems.SERVER_GUILD_WAIT, IngameMessages.UIIT_MSG_STRGERR_STORAGE_OPERATION_BLOCKED));
                                 return;
                             }
                         }
                     }
                 }
                 //Make sure that the user isnt using storage allready
                 if (!Character.Network.Guild.UsingStorage)
                 {
                     byte type = 1;
                     //Set user as active storage user
                     Character.Network.Guild.UsingStorage = true;
                     //Send storage begin packet
                     client.Send(Packet.GuildStorageStart(type));
                 }
             }
             //If the player has no storage rights
             else
             {
                 //Send error message to user not allowed
                 client.Send(Packet.IngameMessages(SERVER_GUILD_STORAGE, IngameMessages.UIIT_MSG_STRGERR_STORAGE_OPERATION_BLOCKED));
             }
         }
     }
     //Catch any bad errors
     catch (Exception ex)
     {
         //Write information to the console
         Console.WriteLine("GuildStorage Open Error: {0}", ex);
         //Write information to the debug log
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 53
0
        public static byte[] Exchange_ItemPacket(int id, List <Global.slotItem> Exhange, bool mine)
        {
            PacketWriter Writer = new PacketWriter();

            Writer.Create(Systems.SERVER_EXCHANGE_ITEM);
            Writer.DWord(id);
            Writer.Byte(Exhange.Count);

            for (byte i = 0; i < Exhange.Count; i++)
            {
                Systems.LoadBluesid(Exhange[i].dbID);
                if (mine)
                {
                    Writer.Byte(Exhange[i].Slot);
                }

                Writer.Byte(i);
                Writer.DWord(0);
                Writer.DWord(Exhange[i].ID);

                if (Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.ARMOR ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.GARMENT ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.GM ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.HEAVY ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.LIGHT ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.PROTECTOR ||
                    Data.ItemBase[Exhange[i].ID].Type == Global.item_database.ArmorType.ROBE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EARRING ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.RING ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.NECKLACE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BLADE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BOW ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_AXE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_CROSSBOW ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_DAGGER ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_HARP ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_STAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_SWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_TSTAFF ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_TSWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.GLAVIE ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.SPEAR ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.SWORD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.CH_SHIELD ||
                    Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.EU_SHIELD)
                {
                    Writer.Byte(Exhange[i].PlusValue);
                    Writer.LWord(0);
                    Writer.DWord(Data.ItemBase[Exhange[i].ID].Defans.Durability);
                    if (Data.ItemBlue[Exhange[i].dbID].totalblue != 0)
                    {
                        Writer.Byte(Convert.ToByte(Data.ItemBlue[Exhange[i].dbID].totalblue));
                        for (int a = 1; a <= Data.ItemBlue[Exhange[i].dbID].totalblue; a++)
                        {
                            Writer.DWord(Data.MagicOptions.Find(mg => (mg.Name == Convert.ToString(Data.ItemBlue[Exhange[i].dbID].blue[i]))).ID);
                            Writer.DWord(Data.ItemBlue[Exhange[i].dbID].blueamount[i]);
                        }
                    }

                    else
                    {
                        Writer.Byte(0);
                    }
                    Writer.Word(1);
                    Writer.Word(2);
                    Writer.Word(3);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.STONES)
                {
                    Writer.Word(Exhange[i].Amount);
                    Writer.Byte(0);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.MONSTERMASK)
                {
                    Writer.DWord(0);
                }
                else if (Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ELIXIR)
                {
                    Writer.Word(1);
                }
                else if (Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.ARROW ||
                         Data.ItemBase[Exhange[i].ID].Itemtype == Global.item_database.ItemType.BOLT ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.HP_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.MP_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.VIGOR_POTION ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.SPEED_POTION ||
                         Data.ItemBase[Exhange[i].ID].Ticket == Global.item_database.Tickets.BEGINNER_HELPERS ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ELIXIR ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.ALCHEMY_MATERIAL ||
                         Data.ItemBase[Exhange[i].ID].Etctype == Global.item_database.EtcType.EVENT ||
                         Data.ItemBase[Exhange[i].ID].Class_D == 3)
                {
                    Writer.Word(Exhange[i].Amount);
                }
            }
            return(Writer.GetBytes());
        }
Esempio n. 54
0
 // dgmp stat ellenőrzése hogy mire jó??
 public void ChangeAbsorbMP_dgmp(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         if (!delete)
         {
             int amount;
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["dgmp"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["dgmp"];
                 Target.Character.Stat.Absorb_mp = amount;
             }
         }
         else
         {
             Target.Character.Stat.Absorb_mp = 0;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 55
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Exchange Approve
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void Exchange_Approve()
        {
            try
            {
                Systems sys = GetPlayer(Character.Network.TargetID);
                client.Send(Packet.Exchange_Approve());
                Character.Network.Exchange.Approved = true;
                if (sys.Character.Network.Exchange.Approved)
                {
                    #region Gold update
                    if (Character.Network.Exchange.Gold != 0)
                    {
                        Character.Information.Gold -= Character.Network.Exchange.Gold;
                        client.Send(Packet.UpdateGold(Character.Information.Gold));
                        SaveGold();

                        sys.Character.Information.Gold += Character.Network.Exchange.Gold;
                        sys.client.Send(Packet.UpdateGold(sys.Character.Information.Gold));
                        sys.SaveGold();
                    }
                    if (sys.Character.Network.Exchange.Gold != 0)
                    {
                        sys.Character.Information.Gold -= sys.Character.Network.Exchange.Gold;
                        sys.client.Send(Packet.UpdateGold(sys.Character.Information.Gold));
                        sys.SaveGold();

                        Character.Information.Gold += sys.Character.Network.Exchange.Gold;
                        client.Send(Packet.UpdateGold(Character.Information.Gold));
                        SaveGold();
                    }
                    #endregion

                    #region Items
                    if (Character.Network.Exchange.ItemList.Count > 0)
                    {
                        foreach (Global.slotItem item in Character.Network.Exchange.ItemList)
                        {
                            byte t_slot = sys.GetFreeSlot();
                            Systems.MsSQL.InsertData("UPDATE char_items SET owner='" + sys.Character.Information.CharacterID + "' WHERE owner='" + Character.Information.CharacterID + "' AND itemid='" + item.ID + "' AND id='" + item.dbID + "' AND storagetype='0'");
                        }
                    }

                    if (sys.Character.Network.Exchange.ItemList.Count > 0)
                    {
                        foreach (Global.slotItem item in sys.Character.Network.Exchange.ItemList)
                        {
                            byte t_slot = GetFreeSlot();
                            Systems.MsSQL.InsertData("UPDATE char_items SET owner='" + Character.Information.CharacterID + "' WHERE owner='" + sys.Character.Information.CharacterID + "' AND itemid='" + item.ID + "' AND id='" + item.dbID + "' AND storagetype='0'");
                        }
                    }
                    #endregion

                    client.Send(Packet.Exchange_Finish());
                    sys.client.Send(Packet.Exchange_Finish());
                    Character.State.Exchanging     = false;
                    sys.Character.State.Exchanging = false;
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 56
0
 public void ChangeBlockingRatio_br(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         int amount;
         if (!delete)
         {
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["br"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["br"];
                 Target.Character.Action.Buff.UpdatedStats[slot].BlockRatio = amount;
             }
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["br"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties2["br"];
                 Target.Character.Action.Buff.UpdatedStats[slot].BlockRatio = (Target.Character.Stat.BlockRatio / 100) * (amount);
             }
             Target.Character.Stat.BlockRatio += Target.Character.Action.Buff.UpdatedStats[slot].BlockRatio;
         }
         else
         {
             Target.Character.Stat.BlockRatio -= Target.Character.Action.Buff.UpdatedStats[slot].BlockRatio;
             Target.Character.Action.Buff.UpdatedStats[slot].BlockRatio = 0;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 57
0
 public void Send(Systems sys, byte[] buff)
 {
     try
     {
         if (Spawned(sys.Character.Information.UniqueID))
         {
             sys.client.Send(buff);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine("Send error: {0}", ex);
     }
 }
Esempio n. 58
0
 public void ChangeCriticalParry_dcri(Systems Target, int slot, bool delete,bool UpdatePacket)
 {
     try
     {
         int amount;
         if (!delete)
         {
             if (Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["dcri"] != 0)
             {
                 amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["dcri"];
                 Target.Character.Stat.CritParryRatio += amount;
             }
         }
         else
         {
             amount = Data.SkillBase[Target.Character.Action.Buff.SkillID[slot]].Properties1["dcri"];
             Target.Character.Stat.CritParryRatio -= amount;
         }
         if (UpdatePacket) Target.client.Send(Packet.PlayerStat(Target.Character));
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
Esempio n. 59
0
        public targetObject(object o, Systems player)
        {
            try
            {
                os = null;
                o_x = 0;
                o_y = 0;
                magdef = 0;
                phydef = 0;
                type = false;

                if (o == null) return;
                main = player;
                if (main == null) return;
                if (o.GetType().ToString() == "DarkEmu_GameServer.obj")
                {
                    os = o as obj;
                    if (os.Die) { player.StopAttackTimer(); return; }
                    o_x = (float)os.x;
                    o_y = (float)os.y;
                    xsec = os.xSec;
                    ysec = os.ySec;
                    magdef = Data.ObjectBase[os.ID].MagDef;
                    phydef = Data.ObjectBase[os.ID].PhyDef;
                    id = os.UniqueID;
                    type = false;
                    hps = os.HP;
                    state = os.State;
                    main.Character.Action.MonsterID.Add(os.UniqueID);
                    mabsrob = 0;
                    os.Target = player;
                }
                if (o.GetType().ToString() == "DarkEmu_GameServer.Systems")
                {
                    sys = o as Systems;
                    o_x = sys.Character.Position.x;
                    o_y = sys.Character.Position.y;
                    xsec = sys.Character.Position.xSec;
                    ysec = sys.Character.Position.ySec;
                    magdef = sys.Character.Stat.MagDef;
                    phydef = sys.Character.Stat.PhyDef;
                    id = sys.Character.Information.UniqueID;
                    absorbphy = sys.Character.Stat.phy_Absorb;
                    absorbmag = sys.Character.Stat.mag_Absorb;
                    state = sys.Character.State.LastState;
                    hps = sys.Character.Stat.SecondHp;
                    type = true;
                    mabsrob = sys.Character.Stat.Absorb_mp;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Target object error :  {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
Esempio n. 60
0
File: Join.cs Progetto: uvbs/DarkEmu
        /////////////////////////////////////////////////////////////////////////
        //Formed party join response
        /////////////////////////////////////////////////////////////////////////
        void FormedResponse()
        {
            try
            {
                //Open our packet data reader
                PacketReader reader         = new PacketReader(PacketInformation.buffer);
                int          Requestermodel = reader.Int32();
                int          Characterid    = reader.Int32();
                byte         responsetype   = reader.Byte();
                reader.Close();
                //Get player information
                Systems sys = GetPlayer(Characterid);
                //If the requester is not in a party yet
                if (sys.Character.Network.Party == null)
                {
                    //If party doesnt excist anymore or is not listed anymore
                    if (Character.Network.Party != null)
                    {
                        //If not formed anymore
                        if (!Character.Network.Party.IsFormed)
                        {
                            //Send cannot find party message
                            sys.client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_CANT_FIND_PARTY));
                            return;
                        }
                    }
                    //If party is null
                    else
                    {
                        //Send cannot find party message
                        sys.client.Send(Packet.IngameMessages(Systems.SERVER_PARTY_MESSAGES, IngameMessages.UIIT_MSG_PARTYERR_CANT_FIND_PARTY));
                        return;
                    }
                    //Accept new member
                    if (responsetype == 1)
                    {
                        //Check party type members allowed need message if full
                        if (Character.Network.Party.Type == 4 && Character.Network.Party.Members.Count > 3)
                        {
                            //Add msg party full
                            return;
                        }
                        if (Character.Network.Party.Type == 5 && Character.Network.Party.Members.Count > 7)
                        {
                            //Add msg party full
                            return;
                        }
                        //Send packets to creator and invited member
                        sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID));
                        client.Send(Packet.PartyOwnerInformation(Character.Information.UniqueID));

                        //Set bools for check
                        Character.Information.CheckParty = true;
                        //Bool for requester
                        sys.Character.Information.CheckParty = true;

                        //Add member
                        Character.Network.Party.Members.Add(sys.Character.Information.UniqueID);
                        Character.Network.Party.MembersClient.Add(sys.client);

                        //Send packet for each member in party
                        foreach (int member in Character.Network.Party.Members)
                        {
                            if (member != 0)
                            {
                                Systems mainParty = GetPlayer(member);
                                //If the member is the owner
                                if (mainParty != null)
                                {
                                    if (mainParty.Character.Information.CharacterID == Character.Information.CharacterID)
                                    {
                                        //Just send update packet
                                        mainParty.client.Send(Packet.Party_DataMember(mainParty.Character.Network.Party));
                                    }
                                    //For other members
                                    else
                                    {
                                        //Send member joined packet
                                        mainParty.client.Send(Packet.JoinResponseMessage(1));
                                        //Send update packet
                                        mainParty.client.Send(Packet.Party_DataMember(Character.Network.Party));
                                        //Set new party data
                                        mainParty.Character.Network.Party = Character.Network.Party;
                                    }
                                }
                            }
                        }
                    }
                    //Refuse
                    else
                    {
                        //If the party is a new party
                        if (sys.Character.Network.Party.Members.Count < 1)
                        {
                            Character.Information.CheckParty = false;
                        }
                        else
                        {
                            sys.client.Send(Packet.Party_Member(sys.Character.Information.UniqueID));
                            Character.Information.CheckParty = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Formed response error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }