Example #1
0
        public void GainExp(int amount)
        {
            if (amount <= 0 || !ExpMetadataStorage.LevelExist((short)(Level + 1)))
            {
                return;
            }

            long newExp = Exp + amount + RestExp;

            if (RestExp > 0)
            {
                RestExp -= amount;
            }
            else
            {
                RestExp = 0;
            }

            while (newExp >= ExpMetadataStorage.GetExpToLevel(Level))
            {
                newExp -= ExpMetadataStorage.GetExpToLevel(Level);
                if (!LevelUp()) // If can't level up because next level doesn't exist, exit the loop
                {
                    newExp = 0;
                    break;
                }
            }

            Exp = newExp;
            Player.Session.Send(ExperiencePacket.ExpUp(amount, newExp, RestExp));
        }
Example #2
0
 public void SetLevel(short level)
 {
     Level = level;
     Exp   = 0;
     Player.Session.Send(ExperiencePacket.ExpUp(0, Exp, 0));
     Player.Session.Send(ExperiencePacket.LevelUp(Player.Session.FieldPlayer, Level));
 }
Example #3
0
    public void GainExp(int amount)
    {
        if (amount <= 0 || !ExpMetadataStorage.LevelExist((short)(Level + 1)))
        {
            return;
        }

        long newExp = Exp + amount + RestExp;

        if (RestExp > 0)
        {
            RestExp -= amount;
        }
        else
        {
            RestExp = 0;
        }

        while (newExp >= ExpMetadataStorage.GetExpToLevel(Level))
        {
            newExp -= ExpMetadataStorage.GetExpToLevel(Level);
            if (LevelUp())
            {
                continue;
            }

            newExp = 0;
            break;
        }

        Exp = newExp;
        Session.Send(ExperiencePacket.ExpUp(amount, newExp, RestExp));
    }
Example #4
0
    public void GainExp(long amount)
    {
        if (amount <= 0 || !ExpMetadataStorage.LevelExist((short)(Level + 1)))
        {
            return;
        }

        long newExp = Exp + amount + RestExp;

        if (RestExp > 0)
        {
            RestExp -= amount;
        }
        else
        {
            RestExp = 0;
        }

        bool hasLeveledUp = false;

        while (newExp >= ExpMetadataStorage.GetExpToLevel(Level))
        {
            newExp -= ExpMetadataStorage.GetExpToLevel(Level);
            if (LevelUp())
            {
                hasLeveledUp = true;
                continue;
            }

            newExp = 0;
            break;
        }

        Exp = newExp;
        Session.Send(ExperiencePacket.ExpUp(amount, newExp, RestExp));

        if (!hasLeveledUp)
        {
            return;
        }

        Session.FieldManager.BroadcastPacket(RevivalConfirmPacket.Send(FieldPlayer.ObjectId, 0));
        Session.FieldManager.BroadcastPacket(LevelUpPacket.LevelUp(FieldPlayer.ObjectId, Level));
        Session.FieldManager.BroadcastPacket(FieldObjectPacket.UpdateCharacterLevel(Player));

        // Find all new skills for current level
        HashSet <int> newSkillIds = SkillMetadataStorage.GetJobSkills(Player.Job)
                                    .Where(x => x.SkillLevels.First().SkillUpgrade.LevelRequired == Level)
                                    .Select(x => x.SkillId).ToHashSet();

        Session.FieldManager.BroadcastPacket(JobPacket.UpdateSkillTab(FieldPlayer, newSkillIds));

        Session.Send(StatPacket.SetStats(FieldPlayer));
        Session.FieldManager.BroadcastPacket(StatPacket.SetStats(FieldPlayer), Session);

        Session.Send(KeyTablePacket.SendFullOptions(Player.GameOptions));
        DatabaseManager.Characters.Update(Player);
    }
Example #5
0
    public void SetLevel(short level)
    {
        Level = level;
        Exp   = 0;
        Session.Send(ExperiencePacket.ExpUp(0, Exp, 0));
        Session.Send(ExperiencePacket.LevelUp(FieldPlayer.ObjectId, Level));

        QuestHelper.GetNewQuests(Player);
    }
Example #6
0
    public void SetLevel(short level)
    {
        Level = level;
        Exp   = 0;
        Session.Send(ExperiencePacket.ExpUp(0, Exp, 0));
        Session.FieldManager.BroadcastPacket(LevelUpPacket.LevelUp(FieldPlayer.ObjectId, Level));
        Session.FieldManager.BroadcastPacket(FieldObjectPacket.UpdateCharacterLevel(Player));

        QuestHelper.GetNewQuests(Player);
    }
Example #7
0
        public void SetLevel(short level)
        {
            Level = level;
            Exp   = 0;
            Player.Session.Send(ExperiencePacket.ExpUp(0, Exp, 0));
            Player.Session.Send(ExperiencePacket.LevelUp(Player.Session.FieldPlayer, Level));
            DatabaseManager.Update(this);

            QuestHelper.GetNewQuests(Player.Session, Level);
        }