Exemplo n.º 1
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));
                        }
                    }
                }
            }
        }