Ejemplo n.º 1
0
        public uint[][] GetThresholds(StatsBoostTypeEnum statsid)
        {
            uint[][] result;
            switch (statsid)
            {
            case StatsBoostTypeEnum.Strength:
                result = this.StatsPointsForStrength;
                break;

            case StatsBoostTypeEnum.Vitality:
                result = this.StatsPointsForVitality;
                break;

            case StatsBoostTypeEnum.Wisdom:
                result = this.StatsPointsForWisdom;
                break;

            case StatsBoostTypeEnum.Chance:
                result = this.StatsPointsForChance;
                break;

            case StatsBoostTypeEnum.Agility:
                result = this.StatsPointsForAgility;
                break;

            case StatsBoostTypeEnum.Intelligence:
                result = this.StatsPointsForIntelligence;
                break;

            default:
                throw new System.ArgumentException("statsid");
            }
            return(result);
        }
Ejemplo n.º 2
0
        public uint[][] GetThresholds(StatsBoostTypeEnum statsid)
        {
            switch (statsid)
            {
            case StatsBoostTypeEnum.Agility:
                return(StatsPointsForAgility);

            case StatsBoostTypeEnum.Chance:
                return(StatsPointsForChance);

            case StatsBoostTypeEnum.Intelligence:
                return(StatsPointsForIntelligence);

            case StatsBoostTypeEnum.Strength:
                return(StatsPointsForStrength);

            case StatsBoostTypeEnum.Wisdom:
                return(StatsPointsForWisdom);

            case StatsBoostTypeEnum.Vitality:
                return(StatsPointsForVitality);

            default:
                throw new ArgumentException("statsid");
            }
        }
Ejemplo n.º 3
0
        public uint[][] GetThresholds(StatsBoostTypeEnum statsid)
        {
            uint[][] result = null;
            switch (statsid)
            {
            case StatsBoostTypeEnum.Strength:
                result = this.SPForStrenght.Values;
                break;

            case StatsBoostTypeEnum.Vitality:
                result = this.SPForVitality.Values;
                break;

            case StatsBoostTypeEnum.Wisdom:
                result = this.SPForWisdom.Values;
                break;

            case StatsBoostTypeEnum.Chance:
                result = this.SPForChance.Values;
                break;

            case StatsBoostTypeEnum.Agility:
                result = this.SPForAgility.Values;
                break;

            case StatsBoostTypeEnum.Intelligence:
                result = this.SPForIntelligence.Values;
                break;
            }
            return(result);
        }
        public static void HandleStatsUpgradeRequestMessage(WorldClient client, StatsUpgradeRequestMessage message)
        {
            StatsBoostTypeEnum statId = (StatsBoostTypeEnum)message.statId;

            if (statId < StatsBoostTypeEnum.Strength || statId > StatsBoostTypeEnum.Intelligence)
            {
                throw new System.Exception("Wrong statsid");
            }
            if (message.boostPoint > 0)
            {
                Breed breed = client.Character.Breed;
                int   num   = client.Character.Stats[ContextRoleplayHandler.m_statsEnumRelations[statId]].Base;
                short num2  = (short)message.boostPoint;
                if (num2 >= 1 && message.boostPoint <= (short)client.Character.StatsPoints)
                {
                    uint[][] thresholds     = breed.GetThresholds(statId);
                    int      thresholdIndex = breed.GetThresholdIndex(num, thresholds);
                    while ((long)num2 >= (long)((ulong)thresholds[thresholdIndex][1]))
                    {
                        short num3;
                        short num4;
                        if (thresholdIndex < thresholds.Length - 1 && (double)num2 / thresholds[thresholdIndex][1] > (double)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num)))
                        {
                            num3 = (short)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num));
                            num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1]));
                            if (thresholds[thresholdIndex].Length > 2)
                            {
                                num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2]));
                            }
                        }
                        else
                        {
                            num3 = (short)System.Math.Floor((double)num2 / thresholds[thresholdIndex][1]);
                            num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1]));
                            if (thresholds[thresholdIndex].Length > 2)
                            {
                                num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2]));
                            }
                        }
                        num           += (int)num3;
                        num2          -= num4;
                        thresholdIndex = breed.GetThresholdIndex(num, thresholds);
                    }
                    client.Character.Stats[ContextRoleplayHandler.m_statsEnumRelations[statId]].Base = num;
                    Character expr_1A0 = client.Character;
                    expr_1A0.StatsPoints -= (ushort)(message.boostPoint - num2);
                    ContextRoleplayHandler.SendStatsUpgradeResultMessage(client, (short)message.boostPoint);
                    client.Character.RefreshStats();
                }
            }
        }
Ejemplo n.º 5
0
 static UInt16ReflectedStat GetReflectedStat(StatsRecord stats, StatsBoostTypeEnum type)
 {
     var fieldInfo = StatsRecord.GetFieldInfo("Base"+type.ToString());
     return new UInt16ReflectedStat(fieldInfo, stats);
 }
Ejemplo n.º 6
0
 public uint[][] GetThresholds(StatsBoostTypeEnum statsid)
 {
     uint[][] result = null;
     switch (statsid)
     {
         case StatsBoostTypeEnum.Strength:
             result = this.SPForStrenght.Values;
             break;
         case StatsBoostTypeEnum.Vitality:
             result = this.SPForVitality.Values;
             break;
         case StatsBoostTypeEnum.Wisdom:
             result = this.SPForWisdom.Values;
             break;
         case StatsBoostTypeEnum.Chance:
             result = this.SPForChance.Values;
             break;
         case StatsBoostTypeEnum.Agility:
             result = this.SPForAgility.Values;
             break;
         case StatsBoostTypeEnum.Intelligence:
             result = this.SPForIntelligence.Values;
             break;
     }
     return result;
 }
Ejemplo n.º 7
0
 public uint[] GetThreshold(short actualpoints, StatsBoostTypeEnum statsid)
 {
     uint[][] thresholds = this.GetThresholds(statsid);
     return thresholds[this.GetThresholdIndex((int)actualpoints, thresholds)];
 }
Ejemplo n.º 8
0
 public uint[] GetThreshold(short actualpoints, StatsBoostTypeEnum statsid)
 {
     uint[][] thresholds = this.GetThresholds(statsid);
     return(thresholds[this.GetThresholdIndex((int)actualpoints, thresholds)]);
 }
        public static void HandleStatsUpgrade(StatsUpgradeRequestMessage message, WorldClient client)
        {
            if (client.Character.IsFighting)
            {
                client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.IN_FIGHT, 0));
                return;
            }
            StatsBoostTypeEnum statId = (StatsBoostTypeEnum)message.statId;

            if (statId < StatsBoostTypeEnum.Strength || statId > StatsBoostTypeEnum.Intelligence)
            {
                Logger.Error("Wrong statsid");
            }
            if (message.boostPoint > 0)
            {
                UInt16ReflectedStat linkedStat = GetReflectedStat(client.Character.StatsRecord, statId);

                BreedRecord breed = BreedRecord.GetBreed(client.Character.Record.Breed);
                int         num   = linkedStat.GetValue();
                ushort      num2  = message.boostPoint;
                if (num2 >= 1 && message.boostPoint <= (short)client.Character.Record.StatsPoints)
                {
                    uint[][] thresholds     = breed.GetThresholds(statId);
                    int      thresholdIndex = breed.GetThresholdIndex(num, thresholds);
                    while ((long)num2 >= (long)((ulong)thresholds[thresholdIndex][1]))
                    {
                        short num3;
                        short num4;
                        if (thresholdIndex < thresholds.Length - 1 && (double)num2 / thresholds[thresholdIndex][1] > (double)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num)))
                        {
                            num3 = (short)((ulong)thresholds[thresholdIndex + 1][0] - (ulong)((long)num));
                            num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1]));
                            if (thresholds[thresholdIndex].Length > 2)
                            {
                                num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2]));
                            }
                        }
                        else
                        {
                            num3 = (short)System.Math.Floor((double)num2 / thresholds[thresholdIndex][1]);
                            num4 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][1]));
                            if (thresholds[thresholdIndex].Length > 2)
                            {
                                num3 = (short)((long)num3 * (long)((ulong)thresholds[thresholdIndex][2]));
                            }
                        }
                        num           += (int)num3;
                        num2          -= (ushort)num4;
                        thresholdIndex = breed.GetThresholdIndex(num, thresholds);
                    }


                    if (statId == StatsBoostTypeEnum.Vitality)
                    {
                        var previousVitality = linkedStat.GetValue();
                        linkedStat.SetValue((short)num);
                        client.Character.StatsRecord.LifePoints  += (short)(client.Character.StatsRecord.BaseVitality - previousVitality);
                        client.Character.CurrentStats.LifePoints += (uint)(client.Character.StatsRecord.BaseVitality - previousVitality);
                    }
                    else
                    {
                        linkedStat.SetValue((short)num);
                    }
                    client.Character.Record.StatsPoints -= (ushort)(message.boostPoint - num2);
                    client.Send(new StatsUpgradeResultMessage((sbyte)StatsUpgradeResultEnum.SUCCESS, message.boostPoint));
                    client.Character.RefreshStats();
                }
            }
        }
        static UInt16ReflectedStat GetReflectedStat(StatsRecord stats, StatsBoostTypeEnum type)
        {
            var fieldInfo = StatsRecord.GetFieldInfo("Base" + type.ToString());

            return(new UInt16ReflectedStat(fieldInfo, stats));
        }