public int HandleUse(MapleClient c)
        {
            int usedArrow = ChosenArrow;

            Arrows[ChosenArrow]--;
            if (Arrows[ChosenArrow] < 1) // Switch to other quiver
            {
                for (int i = 0; i < 3; i++)
                {
                    IncreaseChosenArrow();
                    if (Arrows[ChosenArrow] > 0)
                    {
                        break;
                    }
                }
                if (Arrows[ChosenArrow] <= 0) // All quivers are empty
                {
                    ChosenArrow = 0;
                    for (int i = 0; i < 3; i++)
                    {
                        Arrows[i] = 10;
                    }
                }
            }
            c.SendPacket(GetBuffPacket());
            if (usedArrow != ChosenArrow)
            {
                c.SendPacket(GetEffectPacket());
            }

            return(usedArrow);
        }
        public static void Handle(MapleClient c)
        {
            //Todo, Loop for each world and channel
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.ShowWorlds);
            pw.WriteByte(0);                //WorldId
            pw.WriteMapleString("Scania");  //World name
            pw.WriteByte(2);                //Flag
            pw.WriteMapleString("Leatty!"); //Event message
            pw.WriteShort(0x64);
            pw.WriteShort(0x64);
            pw.WriteByte(0);

            byte channelCount = ServerConstants.Channels;

            pw.WriteByte(channelCount); //Channelcount

            for (short i = 0; i < channelCount; i++)
            {
                pw.WriteMapleString("Scania-" + i.ToString()); //channel name
                pw.WriteInt(0);                                //load
                pw.WriteByte(0);                               //World id again? o-o'
                pw.WriteShort(i);                              //channelid - 1
            }

            pw.WriteZeroBytes(8); //8 empty bytes
            c.SendPacket(pw);

            pw = new PacketWriter();
            pw.WriteHeader(SendHeader.ShowWorlds);
            pw.WriteByte(0xFF);
            pw.WriteByte(0);
            c.SendPacket(pw);
        }
예제 #3
0
        public static void HandleStealSkill(MapleClient c, PacketReader pr)
        {
            //[6A 88 1E 00] [F0 B2 30 00] [00] //choose new
            //[6A 88 1E 00] [00 00 00 00] [01] //remove
            MapleCharacter chr = c.Account.Character;

            if (!chr.IsPhantom)
            {
                return;
            }
            PhantomSystem resource = chr.Resource as PhantomSystem;

            if (resource == null)
            {
                return;
            }
            int skillId    = pr.ReadInt();
            int stolenFrom = pr.ReadInt();

            //last byte: 0 = learn, 1 = remove, but we dont need this since chrId == 0 when removing
            if (stolenFrom == 0) //remove
            {
                int arrayIndex = resource.GetSkillIndex(skillId);
                if (arrayIndex >= 0)
                {
                    resource.StolenSkills[arrayIndex] = 0;
                    resource.RemoveChosenSkill(skillId);
                    int jobNum = PhantomSystem.GetJobNum(arrayIndex);
                    int index  = PhantomSystem.GetJobPositionIndex(arrayIndex);
                    chr.RemoveSkillSilent(skillId);
                    c.SendPacket(RemoveStolenSkill(jobNum, index));
                }
            }
            else
            {
                if (resource.GetSkillIndex(skillId) > -1) //Already have the skill
                {
                    return;
                }
                MapleCharacter target = Program.GetCharacterById(stolenFrom);
                if (target != null)
                {
                    Skill targetsSkill = target.GetSkill(skillId);
                    if (targetsSkill != null && targetsSkill.IsStealable)
                    {
                        int jobNum     = JobConstants.GetJobNumber(skillId / 10000);
                        int arrayIndex = resource.AddStolenSkill(targetsSkill.SkillId, jobNum);
                        int index      = PhantomSystem.GetJobPositionIndex(arrayIndex);
                        if (arrayIndex >= 0 && index >= 0)
                        {
                            Skill skill = new Skill(skillId, 0, targetsSkill.Level);
                            chr.AddSkillSilent(skill);
                            c.SendPacket(AddStolenSkill(skillId, targetsSkill.Level, jobNum, index));
                        }
                    }
                }
            }
        }
예제 #4
0
        public bool RemovePlayer(int id, bool kicked)
        {
            if (Characters.Remove(id))
            {
                MapleCharacter chr = Program.GetCharacterById(id);
                if (chr != null)
                {
                    //Player is online
                    chr.Party = null;
                }
                if (Characters.Count > 0)
                {
                    if (id == LeaderId) //Player was the party leader
                    {
                        int newLeaderId = -1;
                        foreach (int i in Characters)
                        {
                            MapleCharacter newLeader = Program.GetCharacterById(i); //online players first
                            if (newLeader != null)
                            {
                                newLeaderId = newLeader.Id;
                                break;
                            }
                        }
                        if (newLeaderId == -1)           //No online party members
                        {
                            newLeaderId = Characters[0]; //Then just take the first next character
                        }
                        LeaderId = newLeaderId;

                        for (int i = 0; i < Characters.Count; i++)
                        {
                            MapleClient c = Program.GetClientByCharacterId(Characters[i]);
                            if (c != null)
                            {
                                c.SendPacket(Packets.SetLeader(LeaderId, false));
                                c.SendPacket(Packets.PlayerLeave(this, chr, c.Account.Character, false, kicked));
                            }
                        }
                        chr.Client.SendPacket(Packets.PlayerLeave(this, chr, chr, false, kicked));
                    }
                }
                else //no players left, disband
                {
                    Dispose();
                    chr.Client.SendPacket(Packets.PlayerLeave(this, chr, chr, true));
                }
                chr.Party = null;
                return(true);
            }
            return(false);
        }
예제 #5
0
        public void Disband()
        {
            List <Character> GuildCharacters;

            using (LeattyContext DBContext = new LeattyContext())
            {
                GuildCharacters = DBContext.Characters.Where(x => x.GuildId == GuildId).ToList();
            }
            Guilds.Remove(this.GuildId);

            foreach (Character character in GuildCharacters)
            {
                MapleClient c = Program.GetClientByCharacterId(character.Id);
                c.Account.Character.Guild = null;
                if (c != null)
                {
                    c.SendPacket(GenerateGuildDisbandPacket());
                    UpdateCharacterGuild(c.Account.Character, "");
                    c.Account.Character.GuildContribution = 0;
                    c.Account.Character.AllianceRank      = 5;
                    c.Account.Character.GuildRank         = 5;
                    MapleCharacter.SaveToDatabase(c.Account.Character);
                }
            }
        }
예제 #6
0
        public static void HandleSkillSwipe(MapleClient c, PacketReader pr)
        {
            MapleCharacter chr = c.Account.Character;

            if (!chr.IsPhantom || chr.Map == null)
            {
                return;
            }
            int            targetId = pr.ReadInt();
            MapleCharacter target   = chr.Map.GetCharacter(targetId);

            if (target != null && target.IsExplorer)
            {
                PacketWriter pw = new PacketWriter();
                pw.WriteHeader(SendHeader.ShowStealSkills);

                pw.WriteByte(1);
                var stealableSkills = target.GetSkillList().Where(x => x.IsStealable);
                pw.WriteInt(stealableSkills.Any() ? 4 : 2);
                pw.WriteInt(targetId);
                pw.WriteInt(target.Job);
                pw.WriteInt(stealableSkills.Count());
                foreach (Skill skill in stealableSkills)
                {
                    pw.WriteInt(skill.SkillId);
                }
                c.SendPacket(pw);
            }
        }
예제 #7
0
        public void BuddyChannelChanged(MapleClient listOwnerClient, int characterId, int accountId, string characterName, bool accountBuddy, int channel)
        {
            bool       isMyBuddy = false;
            MapleBuddy buddy;

            if (accountBuddy)
            {
                if (AccountBuddies.TryGetValue(accountId, out buddy))
                {
                    isMyBuddy = !buddy.IsRequest;
                    if (isMyBuddy)
                    {
                        CharacterBuddies.Remove(characterId);
                    }
                }
            }
            else if (CharacterBuddies.TryGetValue(characterId, out buddy))
            {
                isMyBuddy = !buddy.IsRequest;
            }
            if (!isMyBuddy)
            {
                return;
            }
            buddy.Channel = channel;
            buddy.Name    = characterName;
            listOwnerClient.SendPacket(Packets.BuddyChannelUpdate(characterId, accountId, channel, Invisible, characterName));
        }
예제 #8
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            if (c.Account.MigrationData == null)
            {
                c.Disconnect("Account was found to have no migration data");
                return;
            }
            pr.Skip(1);
            pr.Skip(1);
            int    characterId = pr.ReadInt();
            string mac         = pr.ReadMapleString();
            string mac_hdd     = pr.ReadMapleString();
            string newpic      = pr.ReadMapleString();

            if (!c.Account.HasPic() && newpic.Length >= 6 && newpic.Length <= 16 && c.Account.HasCharacter(characterId) && Program.ChannelServers.Keys.Contains(c.Channel))
            {
                ushort port = Program.ChannelServers[c.Channel].Port;
                c.Account.MigrationData.CharacterId      = characterId;
                c.Account.MigrationData.Character        = MapleCharacter.LoadFromDatabase(characterId, false);
                c.Account.MigrationData.Character.Hidden = c.Account.IsGM;
                c.Account.SetPic(newpic);

                Program.EnqueueMigration(characterId, c.Account.MigrationData);

                c.SendPacket(ChooseCharWithPicHandler.ChannelIpPacket(port, characterId));
            }
        }
예제 #9
0
        public static void HandleCraftEffect(MapleClient c, PacketReader pr)
        {
            if (c.Account.Character.Map.MapId != 910001000)
            {
                return;                                             //Not in ardentmill
            }
            String Effect = pr.ReadMapleString();

            if (!EffectList.ContainsKey(Effect))
            {
                return;
            }
            int SkillId = EffectList[Effect];

            if (!c.Account.Character.HasSkill(SkillId))
            {
                return;
            }
            if (pr.Available < 8)
            {
                return;
            }
            int Time = pr.ReadInt();

            if (Time > 6000 || Time < 3000)
            {
                Time = 4000;
            }
            int Type = pr.ReadInt();

            c.SendPacket(ShowOwnCraftingEffect(Effect, Time, Type));
        }
예제 #10
0
        public static void HandleGain(MapleClient c)
        {
            MapleCharacter chr = c.Account.Character;

            if (chr.IsAran)
            {
                AranSystem resource = (AranSystem)chr.Resource;
                resource.LastComboIncreaseTime = DateTime.UtcNow;
                resource.Combo++;
                switch (resource.Combo)
                {
                case 10:
                case 20:
                case 30:
                case 40:
                case 50:
                case 60:
                case 70:
                case 80:
                case 90:
                case 100:
                    int stacks = resource.Combo / 10;
                    if (chr.GetSkillLevel(Aran1.COMBO_ABILITY) >= stacks)
                    {
                        HandleComboBuff(chr, resource.Combo);
                    }
                    break;
                }
                PacketWriter pw = new PacketWriter();
                pw.WriteHeader(SendHeader.ShowAranCombo);
                pw.WriteInt(resource.Combo);
                c.SendPacket(pw);
            }
        }
        public static void Handle(MapleClient c, PacketReader pr)
        {
            MapleCharacter chr = c.Account.Character;

            if (chr.Party?.LeaderId != chr.Id)
            {
                return;
            }
            var availableCharacters = c.Account.Character.Map.GetCharacters().Where(x => !x.Hidden && x.Party == null && Math.Abs(chr.Level - x.Level) <= MAX_LEVEL_DIFFERENCE);
            int count = availableCharacters.Count();

            if (count > 50)
            {
                return;
            }

            //[01] [46 7B 3C 00] [06 00 4B 61 7A 72 6F 6C] [90 01] [00 00] [15]
            PacketWriter pw = new PacketWriter(SendHeader.RecommendedPartyMembers);

            pw.WriteByte((byte)count);
            foreach (MapleCharacter recommendedChr in availableCharacters)
            {
                pw.WriteInt(recommendedChr.Id);
                pw.WriteMapleString(recommendedChr.Name);
                pw.WriteShort(recommendedChr.Job);
                pw.WriteShort(recommendedChr.SubJob);
                pw.WriteByte(recommendedChr.Level);
            }
            c.SendPacket(pw);
        }
예제 #12
0
        public static void RemoveBuff(string[] split, MapleClient c)
        {
            int      buffBit  = int.Parse(split[1]);
            BuffStat buffstat = new BuffStat(buffBit);

            c.SendPacket(Buff.RemoveBuffTestPacket(buffstat));
        }
예제 #13
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            byte type      = pr.ReadByte();
            int  tickCount = pr.ReadInt();

            switch (type)
            {
            case 5:     // Find command
            case 0x44:
            {
                string         name      = pr.ReadMapleString();
                MapleCharacter target    = Program.GetCharacterByName(name);
                bool           buddyList = type == 0x44; //Updates info in the buddylist
                if (target != null && (!target.Hidden || c.Account.IsGM))
                {
                    if (c.Channel == target.Client.Channel)
                    {
                        c.SendPacket(FindResponseSameChannel(name, target.MapId, buddyList));
                    }
                    else
                    {
                        c.SendPacket(FindResponseOtherChannel(name, target.Client.Channel, buddyList));
                    }
                }
                else if (!buddyList)
                {
                    c.SendPacket(FindResponseFailure(name));
                }
                break;
            }

            case 6:     // Whisper
            {
                string         receiverName = pr.ReadMapleString();
                string         message      = pr.ReadMapleString();
                MapleCharacter receiver     = Program.GetCharacterByName(receiverName);
                bool           success      = false;
                if (receiver != null && (!receiver.Hidden || c.Account.IsGM))
                {
                    receiver.Client.SendPacket(ReceiveWhisper(c.Account.Character.Name, message, (short)(c.Channel)));
                    success = true;
                }
                c.SendPacket(WhisperResponse(receiverName, success));
                break;
            }
            }
        }
예제 #14
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            try
            {
                if (c.Account == null)
                {
                    c.Disconnect("Client is not logged in to an account");
                    return;
                }

                string pic         = pr.ReadMapleString();
                int    characterId = pr.ReadInt();
                pr.Skip(1);
                string macs     = pr.ReadMapleString();
                string clientid = pr.ReadMapleString();
                if (c.Account.CheckPic(pic) && c.Account.HasCharacter(characterId) && Program.ChannelServers.ContainsKey(c.Channel))
                {
                    ushort port = Program.ChannelServers[c.Channel].Port;
                    c.Account.MigrationData.CharacterId      = characterId;
                    c.Account.MigrationData.Character        = MapleCharacter.LoadFromDatabase(characterId, false);
                    c.Account.MigrationData.Character.Hidden = c.Account.IsGM;

                    Program.EnqueueMigration(characterId, c.Account.MigrationData);

                    c.SendPacket(ChannelIpPacket(port, characterId));
                }
                else
                {
                    //Incorrect Pic
                    PacketWriter pw = new PacketWriter();
                    pw.WriteHeader(SendHeader.PICResponse);
                    pw.WriteByte(0x14);
                    c.SendPacket(pw);
                }
            }
            catch (Exception ex)
            {
                ServerConsole.Error(ex.ToString());
                FileLogging.Log("Character loading", ex.ToString());
                c.SendPacket(MapleCharacter.ServerNotice("Error loading character", 1));

                /*PacketWriter pw = new PacketWriter();
                 * pw.WriteHeader(SendHeaders.PICResponse);
                 * pw.WriteByte(0x15);
                 * c.SendPacket(pw);*/
            }
        }
예제 #15
0
        private static void ShowCategories(MapleClient c)
        {
            PacketWriter HeaderPw = new PacketWriter();
            PacketWriter pw       = new PacketWriter();

            HeaderPw.WriteHeader(SendHeader.CashShopInfo);
            HeaderPw.WriteByte(3);    //Type
            HeaderPw.WriteBool(true); //Unk

            byte count = 0;

            pw.WriteInt(GetCatInt(Base: 2));
            pw.WriteMapleString("Favorite");
            pw.WriteInt(1);
            pw.WriteInt(0); //Type, 1 = New, 2 = Hot
            pw.WriteInt(0);
            count++;

            List <CashshopCat> Categories;

            using (LeattyContext DBContext = new LeattyContext())
            {
                //Categories = DBContext.CashshopCats.Where(x => x.ParentId == 0).ToList();
                Categories = new List <CashshopCat>();
            }
            foreach (CashshopCat Category in Categories)
            {
                int Id = Category.CsId;
                pw.WriteInt(GetCatInt(Id));
                pw.WriteMapleString(Category.Name);
                pw.WriteInt(1);
                pw.WriteInt(Category.Type);
                pw.WriteInt(0);

                List <CashshopCat> SubCategories;
                using (LeattyContext DBContext = new LeattyContext())
                {
                    //SubCategories = DBContext.CashshopCats.Where(x => x.ParentId == Category.Id).ToList();
                    SubCategories = new List <CashshopCat>();
                }
                foreach (CashshopCat SubCategory in SubCategories)
                {
                    int subId = SubCategory.Id;
                    pw.WriteInt(GetCatInt(Id, subId));
                    pw.WriteMapleString(SubCategory.Name);
                    pw.WriteInt(1);
                    pw.WriteInt(SubCategory.Type);
                    pw.WriteInt(0);
                    count++;
                }
                count++;
            }

            //Somehow setByte stopped working </care>
            HeaderPw.WriteByte(count);
            HeaderPw.WriteBytes(pw.ToArray());

            c.SendPacket(HeaderPw);
        }
        //opcode  ?    serv chan  network ip
        //[43 00] [02] [00] [00] [0A 00 00 03]
        public static void Handle(MapleClient c, PacketReader pr)
        {
            if (c.Account == null)
            {
                c.Disconnect("Account is not logged in"); //something's wrong, isnt logged in
                return;
            }

            pr.Skip(1);
            pr.Skip(1); //server, we only have 1 atm anyway
            byte channel = (byte)(pr.ReadByte());

            c.Account.MigrationData.ToChannel = channel;
            c.Channel = channel;
            //last 4 bytes = network IP

            /*PacketWriter pw = new PacketWriter();
             * pw.WriteHeader(SendHeader.LoginSuccess);
             * pw.WriteByte(0);
             * pw.WriteInt(c.Account.Id); //Accid
             * pw.WriteZeroBytes(10);
             * pw.WriteByte(0x95);
             * pw.WriteMapleString(c.Account.Name);
             * pw.WriteZeroBytes(10);
             * pw.WriteMapleString(c.Account.Name);
             * pw.WriteHexString("00 6E E5 D6 A3 2C C7 01"); //account creation date?
             * pw.WriteInt(10); //no idea
             * pw.WriteHexString("E4 A4 AE E1 C5 54 E9 93"); //no idea
             * pw.WriteShort(0);
             *
             * pw.WriteHexString(options);
             *
             * pw.WriteInt(-1);
             * pw.WriteByte(0);
             * pw.WriteByte(1);
             * pw.WriteByte(1);
             * c.SendPacket(pw);
             *
             * pw = new PacketWriter(SendHeader.WorldId);
             * pw.WriteInt(0); //world 1 = scania
             * c.SendPacket(pw);
             */

            c.SendPacket(ShowCharacters(c.Account));
            c.SendPacket(CreateCharacterOptions());
        }
예제 #17
0
 public void IncreaseBodyCount(MapleClient c)
 {
     if (BodyCount < 5)
     {
         BodyCount++;
         c.SendPacket(GetBuffPacket());
     }
 }
예제 #18
0
        private static void SendUnk1(MapleClient c)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.CSUnk1);
            pw.WriteZeroBytes(5);
            c.SendPacket(pw);
        }
        public static void Handle(MapleClient c, PacketReader pr)
        {
            string hyper = pr.ReadMapleString();
            int    id    = pr.ReadInt();
            int    tab   = pr.ReadInt();

            c.SendPacket(HyperskillInfo(hyper, id, tab, 0));
        }
예제 #20
0
        public int GetAndResetBodyCount(MapleClient c, int newCount)
        {
            int oldCount = BodyCount;

            BodyCount = 0;
            c.SendPacket(GetBuffPacket());
            return(oldCount);
        }
예제 #21
0
        public static void Handle(MapleClient c)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.ClientLoaded);
            //pw.WriteByte(0); //Amount of strings, 0 = none
            Red(pw);
            c.SendPacket(pw);
        }
예제 #22
0
 public bool RemoveCharacterBuddy(int characterId, MapleClient ownerClient)
 {
     if (!CharacterBuddies.Remove(characterId))
     {
         return(false);
     }
     ownerClient.SendPacket(Packets.RemoveBuddy(characterId, false));
     return(true);
 }
        public static void Handle(MapleClient c, String name)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.CharacterNameResponse);
            pw.WriteMapleString(name);
            pw.WriteBool(MapleCharacter.CharacterExists(name));
            c.SendPacket(pw);
        }
예제 #24
0
 public bool RemoveAccountBuddy(int accountId, MapleClient ownerClient)
 {
     if (!AccountBuddies.Remove(accountId))
     {
         return(false);
     }
     ownerClient.SendPacket(Packets.RemoveBuddy(accountId, true));
     return(true);
 }
예제 #25
0
        public void UpdateBuddyList(MapleClient c)
        {
            var buddies = GetAllBuddies();

            if (buddies.Any())
            {
                c.SendPacket(Packets.UpdateBuddyList(buddies));
            }
        }
예제 #26
0
        public static void ReceivePacket(string[] split, MapleClient c)
        {
            string       packet = split.Fuse(1);
            PacketWriter pw     = new PacketWriter();

            pw.WriteHexString(packet);
            c.SendPacket(pw);
            ServerConsole.Info("Player sent packet to himself: " + pw.ToString());
        }
예제 #27
0
        public static void GetBuff(string[] split, MapleClient c)
        {
            int      buffBit  = int.Parse(split[1]);
            int      value    = int.Parse(split[2]);
            bool     stacking = split.Length > 3 && split[3] == "1";
            BuffStat buffstat = new BuffStat(buffBit, false, stacking);

            c.SendPacket(Buff.GiveBuffTestPacket(buffstat, value));
        }
예제 #28
0
 public static void Handle(MapleClient c)
 {
     if (ServerConstants.LocalHost) //Kek
     {
         MapleAccount acc = MapleAccount.GetAccountFromDatabase("Nuclear");
         c.Account = acc;
         c.SendPacket(LoginAccountHandler.LoginAccountSuccess(acc));
     }
 }
        private static void SendActionResponse(MapleClient c, int ObjectId)
        {
            PacketWriter pw = new PacketWriter();

            pw.WriteHeader(SendHeader.AcceptProffesionAction);
            pw.WriteInt(ObjectId);
            pw.WriteInt(0x0D); //Some kind of state?
            c.SendPacket(pw);
        }
예제 #30
0
        public static void Handle(MapleClient c, PacketReader pr)
        {
            if (!c.Account.Character.DisableActions())
            {
                return;
            }
            if (c.Account.Character.Map.ChangeChannelLimit)
            {
                return;
            }
            byte channel = pr.ReadByte();

            if (Program.ChannelServers.ContainsKey(channel))
            {
                ushort port = Program.ChannelServers[channel].Port;
                //Theres also 1 int left, timestamp I asume, against cc spam
                PacketWriter pw = new PacketWriter();
                pw.WriteHeader(SendHeader.ChangeChannelResponse);
                pw.WriteBool(true);
                pw.WriteBytes(ServerConstants.NexonIp[1]);
                pw.WriteUShort(port);
                if (c.Account.MigrationData.ToCashShop)
                {
                    c.Account.MigrationData.ToCashShop = false;
                }
                else
                {
                    pw.WriteByte(0);
                }
                c.Account.MigrationData.ToChannel    = channel;
                c.Account.MigrationData.CheatTracker = c.CheatTracker;
                c.Account.MigrationData.Character    = c.Account.Character;
                Program.EnqueueMigration(c.Account.MigrationData.CharacterId, c.Account.MigrationData);
                c.SendPacket(pw);
            }
            else
            {
                PacketWriter pw = new PacketWriter();
                pw.WriteHeader(SendHeader.ChangeChannelResponse);
                pw.WriteBool(false);
                c.SendPacket(pw);
                c.Account.Character.EnableActions(false);
            }
        }