Exemplo n.º 1
0
        public static void ResponseCharacterItemList(Client client)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseCharacterItemList, CryptFlags.Decrypt))
            {
                packet.Write(client.GetCharacter().Bp);

                packet.Write(17, 8);
                for (var i = 0; i < 17; ++i)
                {
                    packet.Write(0);
                    packet.Write(client.GetCharacter().EquippedItems[i].ItemCid);
                }

                packet.Write(client.GetCharacter().Items.Count, 24);
                foreach (var i in client.GetCharacter().Items)
                {
                    packet.Write(0);
                    packet.Write(i.ItemCid);
                    packet.Write(i.ItemId);
                    packet.Write(i.RentHour);
                    packet.Write(0);
                    packet.Write(i.Quantity);
                }
                packet.Write(0, 12);

                client.Send(packet);
            }
        }
Exemplo n.º 2
0
        public int CreateClan(string clanName, Client master, Client member1, Client member2, Client member3, Client member4)
        {
            Execute(string.Format("INSERT INTO Clan (Name,MasterCID,RegDate) VALUES ('{0}',{1},GetDate())", clanName, master.GetCharacter().CharacterId));
            var clanId = GetIdentity(string.Format("select @@identity"));

            Execute(string.Format("INSERT INTO ClanMember (CLID,CID,Grade,RegDate) VALUES ({0},{1}, 1, GetDate())", clanId, master.GetCharacter().CharacterId));
            Execute(string.Format("INSERT INTO ClanMember (CLID,CID,Grade,RegDate) VALUES ({0},{1}, 9, GetDate())", clanId, member1.GetCharacter().CharacterId));
            Execute(string.Format("INSERT INTO ClanMember (CLID,CID,Grade,RegDate) VALUES ({0},{1}, 9, GetDate())", clanId, member2.GetCharacter().CharacterId));
            Execute(string.Format("INSERT INTO ClanMember (CLID,CID,Grade,RegDate) VALUES ({0},{1}, 9, GetDate())", clanId, member3.GetCharacter().CharacterId));
            Execute(string.Format("INSERT INTO ClanMember (CLID,CID,Grade,RegDate) VALUES ({0},{1}, 9, GetDate())", clanId, member4.GetCharacter().CharacterId));

            return clanId;
        }
Exemplo n.º 3
0
        public static void ProcessCharInfo(Client client, PacketReader packetReader)
        {
            var index = packetReader.ReadByte();

            if (index < 0 || index > 4)
            {
                client.Disconnect();
                return;
            }

            client.GetCharacter().CharNum = index;
            client.GetCharacter().UGrade = client.ClientPlayer.PlayerAccount.Access;
            Globals.GunzDatabase.GetCharacter(client.ClientPlayer.PlayerAccount.AccountId, index, client.GetCharacter());

            Match.ResponseCharInfo(client);
        }
Exemplo n.º 4
0
        public static void ProcessRecommendedChannel(Client client, PacketReader packet)
        {
            if (client.GetCharacter().ClanId == 0)
                client.ClientPlayer.PlayerChannel = ChannelList.Recommend(client.GetCharacter().Level);
            else
            {
                client.ClientPlayer.PlayerChannel = ChannelList.Recommend(client.GetCharacter().Level, true, client.GetCharacter().ClanName);
            }

            Match.ResponseRecommendedChannel(client, client.GetChannel().GetTraits().ChannelId);

            if (client.GetCharacter().ClanId != 0)
            {
                ClanPackets.MemberConnected(client, client.GetCharacter().Name);
            }
        }
Exemplo n.º 5
0
        public void Chat(Client client, string message)
        {
            if (message.StartsWith("/dtrank "))
            {
                var args = message.Substring(message.IndexOf(" ") + 1);
                var dtrank = Int32.Parse(args);

                client.GetCharacter().DuelRank = dtrank;
                Refresh();
            }
            if (message.StartsWith("/cw "))
            {
                var args = message.Substring(message.IndexOf(" ") + 1);
                var c = Network.TcpServer.GetClientFromName(args);

                List<Client> red = new List<Client>();
                List<Client> blue = new List<Client>();

                red.Add(c);
                blue.Add(client);

                _stages.CreateClanwar(red, blue);
            }
            lock (_objectLock)
                ChannelPackets.ResponseChat(_traits.Playerlist, _traits.ChannelId, client.GetCharacter().Name, message, client.ClientPlayer.PlayerAccount.Access);
        }
Exemplo n.º 6
0
        public static void ProcessEquipItem(Client client, PacketReader packetReader)
        {
            var uidChar = packetReader.ReadUInt64();
            var nItemLow = packetReader.ReadInt32();
            var nItemHigh = packetReader.ReadInt32();
            var nItemSlot = packetReader.ReadInt32();
            Results result = Results.Accepted;

            if (!Enum.IsDefined(typeof(ItemSlotType), nItemSlot))
            {
                client.Disconnect();
                return;
            }

            Items.Item nItem = client.GetCharacter().Items.Find(i => i.ItemCid == nItemHigh);
            if (nItem == null)
                result = Results.ShopItemNonExistant;
            else if (nItem.Level > client.GetCharacter().Level)
            {
                result = Results.ShopLevelTooLow;
            }
            else if ((ItemSlotType)nItemSlot == ItemSlotType.primary_slot && nItem.ItemId == client.GetCharacter().EquippedItems[(int)ItemSlotType.secondary_slot].ItemId)
            {
                result = Results.ShopInvalidItem;
            }
            else if ((ItemSlotType)nItemSlot == ItemSlotType.secondary_slot && nItem.ItemId == client.GetCharacter().EquippedItems[(int)ItemSlotType.primary_slot].ItemId)
            {
                result = Results.ShopInvalidItem;
            }
            else
            {
                client.GetCharacter().EquippedItems[nItemSlot].ItemCid = nItemHigh;
                client.GetCharacter().EquippedItems[nItemSlot].ItemId = nItem.ItemId;
                Globals.GunzDatabase.UpdateSlot(client.GetCharacter().CharacterId, (ItemSlotType)nItemSlot, nItemHigh);
            }

            Match.ResponseEquipItem(client, result);
            Match.ResponseCharacterItemList(client);
        }
Exemplo n.º 7
0
        public void Join(Client client)
        {
            var result = Results.Accepted;

            if (_traits.Players.Count == _traits.MaxPlayers && _traits.MaxPlayers != 0)
            {
                result = Results.StageRoomFull;
                StagePackets.ResponseStageJoin(client, result);
            }
            else if (_traits.Level != 0 && !(client.GetCharacter().Level > _traits.Level && client.GetCharacter().Level < _traits.Level + 10))
            {
                result = Results.StageInvalidLevel;
                StagePackets.ResponseStageJoin(client, result);
            }
            else
            {
                client.ClientPlayer.PlayerStage = this;
                client.ClientFlags = PacketFlags.Stage;
                client.ClientPlayer.PlayerLocation = Place.Stage;
                _traits.Players.Add(client);

                lock (ObjectLock)
                {
                    StagePackets.ResponseStageJoin(client, result);
                    StagePackets.ResponseObjectCache(client, ObjectCache.Expire, _traits.Players);
                    StagePackets.ResponseStageMaster(_traits.Players, this);

                    var clients = _traits.Players.FindAll(c => c != client);

                    StagePackets.ResponseObjectCacheExclusive(clients, ObjectCache.Keep, client);
                    StagePackets.ResponseStageMaster(_traits.Players, this);

                   Channel.Refresh(client);
                }
            }
        }
Exemplo n.º 8
0
        public static void AskAgreement(List<Client> clients, Client proposer, int mode, int request)
        {
            using (var packet = new PacketWriter(Operation.MatchAskAgreement, CryptFlags.Encrypt))
            {
                packet.Write(proposer.GetMuid());

                packet.Write(clients.Count+1, 32);
                clients.ForEach(c => packet.Write(c.GetCharacter().Name, 32));
                packet.Write(proposer.GetCharacter().Name, 32);
                packet.Write(mode);
                packet.Write(request);

                clients.ForEach(c => c.Send(packet));
            }
        }
Exemplo n.º 9
0
        public static void ProcessBuyItem(Client client, PacketReader packetReader)
        {
            var uid = packetReader.ReadUInt64();
            var itemid = packetReader.ReadInt32();
            var count = packetReader.ReadInt32();
            Results result = Results.Accepted;

            Items.Item item = ItemList.Find(itemid);
            if (item == null)
                result = Results.ShopItemNonExistant;
            else if ((item.Price > client.GetCharacter().Bp && Globals.Config.Items.UseBounty) || count > 0 && item.Price * count > client.GetCharacter().Bp && Globals.Config.Items.UseBounty)
                result = Results.ShopInsufficientBounty;
            else if (client.GetCharacter().Items.Count == Globals.Config.Character.MaxItems)
                result = Results.ShopInventoryFull;
            else
            {
                var temp = new Items.Item();
                temp.ItemId = item.ItemId;
                temp.Level = item.Level;
                temp.MaxWeight = item.MaxWeight;
                temp.Weight = item.Weight;
                temp.Price = item.Price;
                temp.Quantity = count;
                temp.ItemCid = Globals.GunzDatabase.AddItem(client.GetCharacter().CharacterId, item.ItemId, count);
                client.GetCharacter().Items.Add(temp);

                if (Globals.Config.Items.UseBounty)
                {
                    client.GetCharacter().Bp -= item.Price;
                    Globals.GunzDatabase.UpdateBp(client.GetCharacter().Bp, client.GetCharacter().CharacterId);
                }
            }

            Match.ResponseBuyItem(client, result);
            Match.ResponseCharacterItemList(client);
        }
Exemplo n.º 10
0
        public static void ResponseMySimpleCharInfo(Client client)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseMySimpleCharInfo, CryptFlags.Encrypt))
            {
                packet.Write(1, 9);
                packet.Write((int)client.GetCharacter().Xp);
                packet.Write((int)client.GetCharacter().Bp);
                packet.Write((byte)client.GetCharacter().Level);

                client.Send(packet);
            }
        }
Exemplo n.º 11
0
        public static void ResponseSelectCharacter(Client client)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseSelectChar, CryptFlags.Encrypt))
            {
                packet.Write(0);
                packet.Write(client.GetCharacter(), false);
                packet.Write(1,1);
                packet.Write((byte)ExpManager.PercentToNextLevel((int)client.GetCharacter().Xp));

                client.Send(packet);
            }
        }
Exemplo n.º 12
0
        public static void ProcessResponseAgreement(Client client, PacketReader packetReader)
        {
            var uidProposer = packetReader.ReadMuid();
            var uidChar = packetReader.ReadMuid();
            var name = packetReader.ReadString();
            var proposal = packetReader.ReadInt32();
            var request = packetReader.ReadInt32();
            var agreement = packetReader.ReadBoolean();
            PendingClanWarRequest pc = Globals.PendingClanWar.Find(p => p.ClanName == client.GetCharacter().ClanName);

            if (agreement == true)
            {
                lock (Globals.PendingClanWar)
                {
                    pc.Players.Find(p => p.First == client).Second = true;
                }
            }

            lock (Globals.PendingClanWar)
            {
                if (pc.Players.FindAll(p => p.Second).Count == pc.Players.Count)
                {
                    List<Client> players = new List<Client>();
                    foreach (var p in pc.Players)
                        players.Add(p.First);
                    players.Add(pc.Requester);

                    ClanPackets.SearchRival(players);
                    Globals.PendingClanWar.Remove(pc);
                    ClanWarHandler.FindMatch(players);
                }
            }
        }
Exemplo n.º 13
0
        public static void RequestJoin(Client client, Client target, string clanName)
        {
            using (var packet = new PacketWriter(Operation.MatchClanAskJoinAgreement, CryptFlags.Encrypt))
            {
                packet.Write(clanName);
                packet.Write(client.GetMuid());
                packet.Write(client.GetCharacter().Name);

                target.Send(packet);
            }
        }
Exemplo n.º 14
0
        public static void ProcessPromoteMember(Client client, PacketReader packetReader)
        {
            if (client.GetCharacter().ClanId < 1 || client.GetCharacter().ClanGrade != ClanGrade.Master)
                return;

            var sender = packetReader.ReadMuid();
            var member = packetReader.ReadString();
            var rank = packetReader.ReadInt32();

            if (!Enum.IsDefined(typeof(ClanGrade), rank))
            {
                client.Disconnect();
                return;
            }

            Client memberClient = TcpServer.GetClientFromName(member);

            if (memberClient != null)
            {
                memberClient.GetCharacter().ClanGrade = (ClanGrade)rank;
                Globals.GunzDatabase.UpdateMember(memberClient.GetCharacter().CharacterId, rank);
            }

            ClanPackets.ResponseChangeGrade(client);
            ClanPackets.UpdateClanCharInfo(memberClient);
            ClanPackets.SendMemberList(client);
        }
Exemplo n.º 15
0
        public static void ProcessRequestProposal(Client client, PacketReader packetReader)
        {
            var uid = packetReader.ReadMuid();
            var mode = packetReader.ReadInt32();
            var request = packetReader.ReadInt32();
            var memberCount = packetReader.ReadInt32();
            var totalSize = packetReader.ReadInt32();
            var blobSize = packetReader.ReadInt32();
            var blobCount = packetReader.ReadInt32();
            List<byte[]> blob = new List<byte[]>();

            if (memberCount == blobCount)
            {
                for (int i = 0; i < blobCount; ++i)
                {
                    var temp = new byte[blobSize];
                    packetReader.Read(temp, 0, blobSize);
                    blob.Add(temp);
                }
            }
            else
            {
                client.Disconnect();
                return;
            }

            List<Client> requests = new List<Client>();

            foreach (byte[] b in blob)
            {
                string s = System.Text.ASCIIEncoding.ASCII.GetString(b);
                s = s.Substring(0, s.IndexOf('\0'));
                requests.Add(TcpServer.GetClientFromName(s));
            }

            if (requests.FindAll(c => c.GetCharacter().ClanId == client.GetCharacter().ClanId).Count == memberCount)
            {
                List<Pair<Client, bool>> list = new List<Pair<Client, bool>>();

                foreach (Client c in requests)
                {
                    list.Add(new Pair<Client, bool>(c, false));
                }
                list.Add(new Pair<Client, bool>(client, true));

                ClanPackets.AskAgreement(requests, client, mode, request);
                ClanPackets.ResponseProposal(client, 0, mode, request);

                PendingClanWarRequest pc = new PendingClanWarRequest();
                pc.RequestId = request;
                pc.Players = list;
                pc.ClanName = client.GetCharacter().ClanName;
                pc.Requester = client;
                pc.RequestMode = mode;

                lock(Globals.PendingClanWar)
                    Globals.PendingClanWar.Add(pc);

                var responsetimer = new Timer(30000);
                responsetimer.Elapsed += (s, o) => CancelClanWarRequest(client, pc, responsetimer);
                responsetimer.Start();
            }
        }
Exemplo n.º 16
0
        public static void ProcessCreateClan(Client client, PacketReader packetReader)
        {
            var masterId = packetReader.ReadMuid();
            var reqeuest = packetReader.ReadInt32();
            var clanName = packetReader.ReadString();
            var member1 = packetReader.ReadString();
            var member2 = packetReader.ReadString();
            var member3 = packetReader.ReadString();
            var member4 = packetReader.ReadString();

            var members = new List<Client>();
            members.Add(TcpServer.GetClientFromName(member1));
            members.Add(TcpServer.GetClientFromName(member2));
            members.Add(TcpServer.GetClientFromName(member3));
            members.Add(TcpServer.GetClientFromName(member4));

            if (!Globals.AcceptedString.IsMatch(clanName))
            {
                return;
            }

            if (Globals.GunzDatabase.ClanExists(clanName))
            {
                ClanPackets.ResponseCreateClan(client, Results.ClanNameInUse, reqeuest);
                return;
            }

            foreach (var member in members)
            {
                if (member == null || Globals.GunzDatabase.IsInClan(member))
                {
                    ClanPackets.ResponseCreateClan(client, Results.ClanUserAlreadyInAClan, reqeuest);
                    return;
                }
            }

            var pendingClan = new PendingClan();
            pendingClan.ClanMaster = client;
            pendingClan.ClanName = clanName;
            pendingClan.RequestId = reqeuest;
            pendingClan.Member1 = new Pair<Client, bool>(members[0], false);
            pendingClan.Member2 = new Pair<Client, bool>(members[1], false);
            pendingClan.Member3 = new Pair<Client, bool>(members[2], false);
            pendingClan.Member4 = new Pair<Client, bool>(members[3], false);

            lock (Globals.PendingClans)
                Globals.PendingClans.Add(pendingClan);

            ClanPackets.ResponseCreateClan(client, Results.Accepted, reqeuest);
            ClanPackets.AskAgreement(members, reqeuest, clanName, client.GetMuid(), client.GetCharacter().Name);

            var responsetimer = new Timer(30000);
            responsetimer.Elapsed += (s, o) => CancelRequest(client, pendingClan, responsetimer);
            responsetimer.Start();
        }
Exemplo n.º 17
0
        public virtual void GameLeaveBattle(Client client)
        {
            lock (_stage.ObjectLock)
            {
                Globals.GunzDatabase.UpdateLevel(client.GetCharacter().CharacterId, client.GetCharacter().Xp, client.GetCharacter().Level);
                client.ClientPlayer.PlayerStats.Reset();

                Battle.LeaveBattle(CurrentStage.GetTraits().Players, client.GetMuid());

                var traits = _stage.GetTraits();
                if (traits.Players.FindAll(c => !c.GetGameStats().InGame).Count == traits.Players.Count)
                {
                    traits.State = StageState.Standby;

                    foreach (var c in _stage.GetTraits().Players)
                    {
                        c.ClientPlayer.PlayerStats = new GameStats();

                        if (c != traits.Master)
                            client.ClientPlayer.PlayerState = ObjectStageState.NonReady;
                    }

                    if (_gameType == ObjectStageGameType.DeathMatch && (this as Deathmatch).ItemSpawns != null)
                        (this as Deathmatch).ItemSpawns.Abort();
                    else if (_gameType == ObjectStageGameType.Berserker && (this as Berserker).ItemSpawns != null)
                        (this as Berserker).ItemSpawns.Abort();
                    else if (_gameType == ObjectStageGameType.TeamDeathMatchExtreme && (this as TeamDeathmatchExtreme).ItemSpawns != null)
                        (this as TeamDeathmatchExtreme).ItemSpawns.Abort();

                    _stage.GetTraits().Players.ForEach(c => StagePackets.ResponseSettings(_stage.GetTraits().Players, _stage.GetTraits()));
                }
            }
        }
Exemplo n.º 18
0
        public static void GameEnterBattle(List<Client> clients, Client client)
        {
            var stage = client.GetStage().GetTraits();

            using (var packet = new PacketWriter(Operation.StageEnterBattle, CryptFlags.Encrypt))
            {
                if (stage.State == StageState.Standby)
                    packet.Write((byte)0);
                else
                    packet.Write((byte)1);

                //really hate constants :(.
                packet.Write(1, 394);
                packet.Write(client.GetMuid());

                if (client.PeerEnd == null)
                {
                    packet.Write(new byte[4], 0, 4);
                    packet.Write(0);
                }
                else
                {
                    packet.Write(client.PeerEnd.Address.GetAddressBytes(), 0, 4);
                    packet.Write(client.PeerEnd.Port);
                }

                packet.Write(client.GetCharacter().Name, 32);
                packet.Write(client.GetCharacter().ClanName, 16);
                packet.Write((Int32)client.GetCharacter().ClanGrade);//clan rank
                packet.Write(client.GetCharacter().ClanPoint);//clan points
                packet.Write((byte)0);//?
                packet.Write(client.GetCharacter().Level);
                packet.Write(client.GetCharacter().Sex);
                packet.Write(client.GetCharacter().Hair);
                packet.Write(client.GetCharacter().Face);
                packet.Write(client.GetCharacter().Xp);
                packet.Write(client.GetCharacter().Bp);
                packet.Write(client.GetCharacter().BonusRate);
                packet.Write(client.GetCharacter().Prize);
                packet.Write(client.GetCharacter().Hp);
                packet.Write(client.GetCharacter().Ap);
                packet.Write(client.GetCharacter().MaxWeight);
                packet.Write(client.GetCharacter().SafeFalls);
                packet.Write(client.GetCharacter().Fr);
                packet.Write(client.GetCharacter().Cr);
                packet.Write(client.GetCharacter().Er);
                packet.Write(client.GetCharacter().Wr);
                foreach (Item nItem in client.GetCharacter().EquippedItems)
                    packet.Write(nItem.ItemId);

                packet.Write((Int32)client.ClientPlayer.PlayerAccount.Access);
                packet.Write(client.GetCharacter().ClanId);
                packet.Write(client.GetCharacter().DuelRank); // duel tourney

                byte[] obfuscation = new byte[] {
                    0x00, 0x00, 0x00, 0x00,  //head
                    0x79, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //chest
                    0x7B, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //hands
                    0x6E, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //legs
                    0x6D, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //feet
                    0x6C, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //fingerL
                    0x49, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //fingerR
                    0x48, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //melee
                    0x4B, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //primary
                    0x72, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //secondary
                    0x4C, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //custom1
                    0x7F, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //custom2
                    0x4A, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //avatar
                    0x80, 0xF5, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //community1
                    0x00, 0x00, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //community2
                    0x00, 0x00, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //long buff1
                    0x00, 0x00, 0x00, 0x00,

                    0x00, 0x00, 0x00, 0x00, //long buff2
                    0x00, 0x00, 0x00, 0x00,

                    0x01, 0x00, 0x00, 0x00, //head quantity

                    0x01, 0x00, 0x00, 0x00, //chest quantity

                    0x01, 0x00, 0x00, 0x00, //hands quantity

                    0x01, 0x00, 0x00, 0x00, //legs quantity

                    0x01, 0x00, 0x00, 0x00, //feet quantity

                    0x01, 0x00, 0x00, 0x00, //fingerL quantity

                    0x01, 0x00, 0x00, 0x00, //fingerR quantity

                    0x01, 0x00, 0x00, 0x00, //melee quantity

                    0x01, 0x00, 0x00, 0x00, //primary quantity

                    0x01, 0x00, 0x00, 0x00, //secondary quantity

                    0x4C, 0x00, 0x00, 0x00, //custom1 quantity

                    0x01, 0x00, 0x00, 0x00, //custom2 quantity

                    0x01, 0x00, 0x00, 0x00, //vatar quantity

                    0x00, 0x00, 0x00, 0x00, //community1 quantity

                    0x00, 0x00, 0x00, 0x00, //community2 quantity

                    0x00, 0x00, 0x00, 0x00, //longbuff1 quantity

                    0x00, 0x00, 0x00, 0x00 //longbuff2 quantity
                };
                packet.Write(obfuscation);

                packet.Write((byte)client.ClientPlayer.PlayerTeam);
                packet.Write((byte)0);
                packet.Write((Int16)0);
                clients.ForEach(c => c.Send(packet));

            }
        }
Exemplo n.º 19
0
        public static void SendMemberList(Client client)
        {
            var members = TcpServer.GetClanMembers(client.GetCharacter().ClanId);

            using (var packet = new PacketWriter(Operation.MatchClanResponseClanMemberList, CryptFlags.Encrypt))
            {
                packet.Write(members.Count, 49);
                foreach (var member in members)
                {
                    packet.Write(member.GetMuid());
                    packet.Write(member.GetCharacter().Name, 32);
                    packet.Write((byte)member.GetCharacter().Level);
                    packet.Write((Int32)member.GetCharacter().ClanGrade);
                    packet.Write((Int32)member.ClientPlayer.PlayerLocation);
                }

                client.Send(packet);
            }
        }
Exemplo n.º 20
0
        public static void ResponseCharInfo(Client client)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseAccountCharInfo, CryptFlags.Encrypt))
            {
                packet.Write(client.GetCharacter().CharNum);
                packet.Write(client.GetCharacter());

                client.Send(packet);
            }
        }
Exemplo n.º 21
0
 public static void UpdateClanCharInfo(Client client)
 {
     using (var packet = new PacketWriter(Operation.MatchClanUpdateClanInfo, CryptFlags.Encrypt))
     {
         packet.Write(client.GetCharacter().ClanName, 16);
         packet.Write((Int32)client.GetCharacter().ClanGrade);
         client.Send(packet);
     }
 }
Exemplo n.º 22
0
        public virtual void GameKillCallback(Client killer, Client victim)
        {
            victim.ClientPlayer.PlayerStats.Spawned = false;
            if (_gameType == ObjectStageGameType.Training)
            {
                var uids = new Pair<Muid, Muid>(killer.GetMuid(), victim.GetMuid());
                var args = new Pair<UInt32, UInt32>(0, 0);
                lock (CurrentStage.ObjectLock)
                {
                    Battle.GameDie(CurrentStage.GetTraits().Players, uids, args);
                }
            }
            else
            {
                if (killer != victim)
                {
                    var exp = ExpManager.GetExpFromKill(killer.GetCharacter().Level,
                                                        victim.GetCharacter().Level);

                    killer.GetCharacter().Xp += exp;

                    var uids = new Pair<Muid, Muid>(killer.GetMuid(), victim.GetMuid());
                    var args = new Pair<UInt32, UInt32>((exp << 16), 0);
                    lock (CurrentStage.ObjectLock)
                    {
                        Battle.GameDie(CurrentStage.GetTraits().Players, uids, args);

                        //killer.GetCharacter().Level =
                          //  (Int16) ExpManager.GetLevel((Int32) killer.GetCharacter().Xp);
                        Log.Write("Exp Gained: {0} | Exp To Next Level: {1} | Current Exp: {2}", exp, ExpManager.GetExp(killer.GetCharacter().Level + 1), killer.GetCharacter().Xp);
                        if (ExpManager.Level(killer.GetCharacter().Level,
                                             killer.GetCharacter().Xp))
                        {
                            killer.GetCharacter().Level++;
                            Battle.GameLevelUp(CurrentStage.GetTraits().Players, killer.GetMuid(),
                                               killer.GetCharacter().Level);
                            EventManager.AddCallback(
                                () =>
                                Globals.GunzDatabase.UpdateLevel(killer.GetCharacter().CharacterId,
                                                     killer.GetCharacter().Xp,
                                                     killer.GetCharacter().Level));
                        }
                    }

                    killer.ClientPlayer.PlayerStats.Kills++;
                    victim.ClientPlayer.PlayerStats.Deaths++;

                    if (killer.ClientPlayer.PlayerStats.Kills%20 == 0)
                    {
                        EventManager.AddCallback(
                            () =>
                            Globals.GunzDatabase.UpdateLevel(killer.GetCharacter().CharacterId,
                                                 killer.GetCharacter().Xp,
                                                 killer.GetCharacter().Level));
                    }
                }
            }
            OnGameKill(killer, victim);
        }
Exemplo n.º 23
0
        public static void ResponseShopItemList(Client client)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseShopItemList, CryptFlags.Encrypt))
            {
                packet.Write(0, 12);
                List<Item> items = ItemList.GetShopItems(client.GetCharacter().Sex);

                packet.Write(items.Count, 4);
                items.ForEach(i => packet.Write(i.ItemId));

                client.Send(packet);
            }
        }
Exemplo n.º 24
0
        public static void ProcessExpelMember(Client client, PacketReader packetReader)
        {
            if (client.GetCharacter().ClanId < 1 || client.GetCharacter().ClanGrade == ClanGrade.User)
                return;

            var sender = packetReader.ReadMuid();
            var member = packetReader.ReadString();

            Client memberClient = TcpServer.GetClientFromName(member);

            if (memberClient != null)
            {
                if (memberClient.GetCharacter().ClanGrade == ClanGrade.Master || (memberClient.GetCharacter().ClanGrade == ClanGrade.Admin && client.GetCharacter().ClanGrade == ClanGrade.Admin))
                {
                    ClanPackets.ExpelMemberNotAllowed(client);
                    return;
                }

                memberClient.GetCharacter().ClanName = string.Empty;
                memberClient.GetCharacter().ClanId = 0;
                memberClient.GetCharacter().ClanGrade = ClanGrade.None;
                ClanPackets.SendMemberList(memberClient);
                ClanPackets.UpdateClanCharInfo(memberClient);
                Globals.GunzDatabase.ExpelMember(memberClient.GetCharacter().CharacterId);
            }

            using (var expelMember = new PacketWriter(Operation.MatchClanAdminResponseLeaveMember, CryptFlags.Encrypt))
            {
                expelMember.Write(0);
                client.Send(expelMember);
            }
        }
Exemplo n.º 25
0
        public static void ProcessAnswerJoin(Client client, PacketReader packetReader)
        {
            var admin = packetReader.ReadMuid();
            var name = packetReader.ReadString();
            var answer = packetReader.ReadBoolean();

            Client owner = TcpServer.GetClientFromUid(admin);

            if (owner == null)
                return;

            if (!answer)
            {
                ClanPackets.ResponseJoin(owner, Results.ClanJoinRejected);
                return;
            }

            ClanPackets.ResponseAgreedJoin(owner);

            client.GetCharacter().ClanId = owner.GetCharacter().ClanId;
            client.GetCharacter().ClanName = owner.GetCharacter().ClanName;

            Globals.GunzDatabase.JoinClan(client.GetCharacter().CharacterId, owner.GetCharacter().ClanId);
            ClanPackets.UpdateClanCharInfo(client);
            ClanPackets.SendMemberList(client);
            ClanPackets.MemberConnected(client,name);
        }
Exemplo n.º 26
0
        public static void Message(Client client, string msg)
        {
            var members = TcpServer.GetClanMembers(client.GetCharacter().ClanId);

            using (var packet = new PacketWriter(Operation.MatchClanMsg, CryptFlags.Encrypt))
            {
                packet.Write(client.GetCharacter().Name);
                packet.Write(msg);
                members.ForEach(m => m.Send(packet));
            }
        }
Exemplo n.º 27
0
        public static void ResponseObjectCacheExclusive(List<Client> clients, ObjectCache cache, Client player)
        {
            using (var packet = new PacketWriter(Operation.MatchObjectCache, CryptFlags.Encrypt))
            {
                packet.Write((byte) cache);
                packet.Write(1, 176);

                packet.Write(0);
                packet.Write(player.GetMuid());
                packet.Write(player.GetCharacter().Name, 32);
                packet.Write(player.GetCharacter().ClanName, 16);
                packet.Write((Int32) player.GetCharacter().Level);
                packet.Write((Int32) player.ClientPlayer.PlayerAccount.Access);
                packet.Write(0);
                packet.Write(0);
                packet.Write(player.GetCharacter().ClanId);
                packet.Write(0);
                packet.Write((Int32) player.GetCharacter().Sex);
                packet.Write(player.GetCharacter().Hair);
                packet.Write(player.GetCharacter().Face);
                packet.Write((Int16) 0);

                foreach (var item in player.GetCharacter().EquippedItems)
                {
                    packet.Write(item.ItemId);
                }

                packet.Write(player.GetCharacter().Rank); //rank
                packet.Write(player.GetCharacter().Kills); //kill
                packet.Write(player.GetCharacter().Deaths); //death
                packet.Write(player.GetCharacter().DuelRank); //duel

                clients.ForEach(c => c.Send(packet));

            }
        }
Exemplo n.º 28
0
        public static void ProcessClanChat(Client client, PacketReader packetReader)
        {
            if (client.GetCharacter().ClanId < 1)
                return;

            var sender = packetReader.ReadMuid();
            var msg = packetReader.ReadString();

            ClanPackets.Message(client, msg);
        }
Exemplo n.º 29
0
 public bool IsInClan(Client client)
 {
     return GetQuery("SELECT COUNT(CID) FROM clanmember WHERE CID=" + client.GetCharacter().CharacterId) > 0;
 }
Exemplo n.º 30
0
        public static void ProcessClanMemberList(Client client, PacketReader packetReader)
        {
            if (client.GetCharacter().ClanId < 1)
                return;

            ClanPackets.SendMemberList(client);
        }