Exemplo n.º 1
0
 public void OnKilledEnemy(Entity victim)
 {
     // killed a monster
     if (victim is Monster monster)
     {
         // gain exp if not in a party or if in a party without exp share
         if (!party.InParty() || !party.party.shareExperience)
         {
             skillExperience += Experience.BalanceExperienceReward(monster.rewardSkillExperience, level.current, monster.level.current);
         }
     }
 }
Exemplo n.º 2
0
    // helper function to calculate the experience rewards for sharing parties
    public static long CalculateExperienceShare(long total, int memberCount, float bonusPercentagePerMember, int memberLevel, int killedLevel)
    {
        // bonus percentage based on how many members there are
        float bonusPercentage = (memberCount - 1) * bonusPercentagePerMember;

        // calculate the share via ceil, so that uneven numbers still result in
        // at least 'total' in the end.
        // e.g. 4/2=2 (good); 5/2=2 (1 point got lost)
        long share = (long)Mathf.Ceil(total / (float)memberCount);

        // balance experience reward for the receiver's level. this is important
        // to avoid crazy power leveling where a level 1 hero would get a LOT of
        // level ups if his friend kills a level 100 monster once.
        long balanced = Experience.BalanceExperienceReward(share, memberLevel, killedLevel);
        long bonus    = Convert.ToInt64(balanced * bonusPercentage);

        return(balanced + bonus);
    }
Exemplo n.º 3
0
 public void OnKilledEnemy(Entity victim)
 {
     // killed a monster
     if (victim is Monster monster)
     {
         // give pet the experience without sharing it in party or similar,
         // but balance it
         // => AFTER player exp reward! pet can only ever level up to player
         //    level, so it's best if the player gets exp and level-ups
         //    first, then afterwards we try to level up the pet.
         if (activePet != null)
         {
             activePet.experience.current += Experience.BalanceExperienceReward(monster.rewardExperience, activePet.level.current, victim.level.current);
             // sync to owner item so the progress is saved, e.g. on level up
             // we don't sync all the time, but here it makes sense.
             // see also: https://github.com/vis2k/uMMORPG_CE/issues/35
             activePet.SyncToOwnerItem();
         }
     }
 }