Ejemplo n.º 1
0
        public static int F312_xzzz_CHAMPION_GetStrength(ILiveEntity attackProvider, IStorageType P651_i_SlotIndex)
        {
            int L0935_i_Strength = rand.Next(16) + attackProvider.GetProperty(PropertyFactory <StrengthProperty> .Instance).MaxValue;
            var L0938_T_Thing    = attackProvider.Body.GetStorage(P651_i_SlotIndex).Storage.First();
            //if ((A0936_ui_ObjectWeight = F140_yzzz_DUNGEON_GetObjectWeight(L0938_T_Thing)) <= (A0937_ui_OneSixteenthMaximumLoad = F309_awzz_CHAMPION_GetMaximumLoad(L0939_ps_Champion) >> 4))
            int A0936_ui_ObjectWeight            = (int)L0938_T_Thing.FactoryBase.Weight;
            int A0937_ui_OneSixteenthMaximumLoad = attackProvider.GetProperty(PropertyFactory <LoadProperty> .Instance).MaxValue >> 4;

            if (A0936_ui_ObjectWeight <= A0937_ui_OneSixteenthMaximumLoad)
            {
                L0935_i_Strength += A0936_ui_ObjectWeight - 12;
            }
            else
            {
                int L0941_i_LoadThreshold;
                if (A0936_ui_ObjectWeight <= (L0941_i_LoadThreshold = A0937_ui_OneSixteenthMaximumLoad + ((A0937_ui_OneSixteenthMaximumLoad - 12) >> 1)))
                {
                    L0935_i_Strength += (A0936_ui_ObjectWeight - A0937_ui_OneSixteenthMaximumLoad) >> 1;
                }
                else
                {
                    L0935_i_Strength -= (A0936_ui_ObjectWeight - L0941_i_LoadThreshold) << 1;
                }
            }
            //if (M12_TYPE(L0938_T_Thing) == C05_THING_TYPE_WEAPON)
            if (L0938_T_Thing is Weapon)
            {
                //#ifdef C01_COMPILE_DM10aEN_DM10bEN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                //                L0940_ps_WeaponInfo = &G238_as_Graphic559_WeaponInfo[((WEAPON*)G284_apuc_ThingData[C05_THING_TYPE_WEAPON])[M13_INDEX(L0938_T_Thing)].Type];
                //#endif
                //#ifdef C15_COMPILE_DM11EN_DM12EN_DM12GE_DM13aFR_DM13bFR_CSB20EN_CSB21EN /* CHANGE2_01_OPTIMIZATION Inline code replaced by function calls */
                var L0940_ps_WeaponInfo = L0938_T_Thing as Weapon;
                //#endif
                L0935_i_Strength += L0940_ps_WeaponInfo.FactoryType.Strength;
                int A0936_ui_SkillLevel = 0;
                var A0937_ui_Class      = L0940_ps_WeaponInfo.FactoryType.Class;
                if ((A0937_ui_Class == WeaponClass.C000_CLASS_SWING_WEAPON) || (A0937_ui_Class == WeaponClass.C002_CLASS_DAGGER_AND_AXES))
                {
                    A0936_ui_SkillLevel = attackProvider.GetSkill(SkillFactory <SwingSkill> .Instance).SkillLevel;
                }
                if ((A0937_ui_Class != WeaponClass.C000_CLASS_SWING_WEAPON) && (A0937_ui_Class < WeaponClass.C016_CLASS_FIRST_BOW))
                {
                    A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory <ThrowSkill> .Instance).SkillLevel;
                }
                if ((A0937_ui_Class >= WeaponClass.C016_CLASS_FIRST_BOW) && (A0937_ui_Class < WeaponClass.C112_CLASS_FIRST_MAGIC_WEAPON))
                {
                    A0936_ui_SkillLevel += attackProvider.GetSkill(SkillFactory <ShootSkill> .Instance).SkillLevel;
                }
                L0935_i_Strength += A0936_ui_SkillLevel << 1;
            }
            L0935_i_Strength = F306_xxxx_CHAMPION_GetStaminaAdjustedValue(attackProvider.GetProperty(PropertyFactory <StaminaProperty> .Instance), /*L0939_ps_Champion,*/ L0935_i_Strength);
            //if (M07_GET(L0939_ps_Champion->Wounds, (P651_i_SlotIndex == C00_SLOT_READY_HAND) ? MASK0x0001_READY_HAND : MASK0x0002_ACTION_HAND))
            if (attackProvider.Body.GetBodyStorage(P651_i_SlotIndex).IsWounded)
            {
                L0935_i_Strength >>= 1;
            }
            //return F026_a003_MAIN_GetBoundedValue(0, L0935_i_Strength >> 1, 100);
            return(MathHelper.Clamp(L0935_i_Strength >> 1, 0, 100));
        }
        protected override int ModifyAttackyByResistance(int attack, ILiveEntity entity)
        {
            var antiFire = entity.GetProperty(PropertyFactory <AntiFireProperty> .Instance);

            if (antiFire.Value == 15)
            {
                return(0);
            }

            if (entity.GetProperty(PropertyFactory <NonMaterialProperty> .Instance).Value == 1)
            {
                attack >>= 2;
            }

            attack -= rand.Next((antiFire.Value << 1) + 1);
            return(attack);
        }
Ejemplo n.º 3
0
        protected virtual void LevelUp()
        {
            int minorIncrease = rand.Next(2);
            int majorIncrease = 1 + rand.Next(2);

            liveEntity.GetProperty(PropertyFactory <AntiFireProperty> .Instance).BaseValue += rand.Next(2) & ~BaseSkillLevel;
            ApplySkills(majorIncrease, minorIncrease);
        }
Ejemplo n.º 4
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }

            entity.GetProperty(PropertyFactory <PoisonProperty> .Instance).Value = 0;
            return(Used = true);
        }
Ejemplo n.º 5
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }
            var water = entity.GetProperty(PropertyFactory <WaterProperty> .Instance);

            water.Value += 1600;
            return(Used = true);
        }
Ejemplo n.º 6
0
        protected override int ModifyAttackyByResistance(int attack, ILiveEntity entity)
        {
            int L0390_i_PoisonResistance = 0;

            L0390_i_PoisonResistance = entity.GetProperty(PropertyFactory <AntiPoisonProperty> .Instance).Value;
            if (attack == 0 || L0390_i_PoisonResistance == 15)//_IMMUNE_TO_POISON if 15
            {
                return(0);
            }
            return(((attack + rand.Next(4)) << 3) / ++L0390_i_PoisonResistance);
        }
Ejemplo n.º 7
0
        int F307_fzzz_CHAMPION_GetStatisticAdjustedAttack(ILiveEntity P642_ps_Champion, IPropertyFactory P643_ui_StatisticIndex, int P644_ui_Attack)
        {
            int L0927_i_Factor;

            if ((L0927_i_Factor = 170 - P642_ps_Champion.GetProperty(P643_ui_StatisticIndex).Value) < 16) //[C1_CURRENT]
            {
                /* BUG0_41 The Antifire and Antimagic statistics are completely ignored. The Vitality statistic is ignored against poison and to determine the probability of being wounded. Vitality is still used normally to compute the defense against wounds and the speed of health regeneration. A bug in the Megamax C compiler produces wrong machine code for this statement. It always returns 0 for the current statistic value so that L0927_i_Factor = 170 in all cases */
                return(P644_ui_Attack >> 3);
            }
            return(F030_aaaW_MAIN_GetScaledProduct(P644_ui_Attack, 7, L0927_i_Factor));
        }
Ejemplo n.º 8
0
        int F192_ayzz_GROUP_GetResistanceAdjustedPoisonAttack(ILiveEntity creature, int P381_i_PoisonAttack)
        {
            int L0390_i_PoisonResistance = 0;

            L0390_i_PoisonResistance = creature.GetProperty(PropertyFactory <AntiPoisonProperty> .Instance).Value;
            if (P381_i_PoisonAttack == 0 || L0390_i_PoisonResistance == 15)//_IMMUNE_TO_POISON if 15
            {
                return(0);
            }
            return(((P381_i_PoisonAttack + rand.Next(4)) << 3) / ++L0390_i_PoisonResistance);
        }
Ejemplo n.º 9
0
        public bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }

            var food = entity.GetProperty(PropertyFactory <FoodProperty> .Instance);

            food.Value += FoodFactory.FoodValue;
            return(Used = true);
        }
Ejemplo n.º 10
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }
            int L1086_ui_Counter = ((511 - Power) / (32 + (Power + 1) / 8)) >> 1;
            var stamina          = entity.GetProperty(PropertyFactory <StaminaProperty> .Instance);

            stamina.Value += stamina.MaxValue / L1086_ui_Counter;
            return(Used = true);
        }
Ejemplo n.º 11
0
        public static bool F308_vzzz_CHAMPION_IsLucky(ILiveEntity entity, int P646_ui_Percentage)
        {
            if (rand.Next(2) != 0 && (rand.Next(100) > P646_ui_Percentage))
            {
                return(true);
            }

            var  luckProperty     = entity.GetProperty(PropertyFactory <LuckProperty> .Instance);
            bool AP646_ui_IsLucky = rand.Next(luckProperty.MaxValue) > P646_ui_Percentage;

            luckProperty.BaseValue += AP646_ui_IsLucky ? -2 : 2;
            return(AP646_ui_IsLucky);
        }
Ejemplo n.º 12
0
        async void F322_lzzz_CHAMPION_Poison(ILiveEntity entity, int attack)
        {
            var health = entity.GetProperty(PropertyFactory <HealthProperty> .Instance);
            var poison = entity.GetProperty(PropertyFactory <PoisonProperty> .Instance);

            poison.Value++;

            var eventCount = attack;

            for (int i = 0; i < eventCount; i++, attack--)
            {
                //Todo add event on value changed to stop poison immediately
                if (poison.Value == 0)
                {
                    return;
                }

                health.Value -= MathHelper.Max(1, attack >> 6);
                await Task.Delay(6000);
            }
            poison.Value--;
        }
Ejemplo n.º 13
0
        public bool ApplyEffect(ILiveEntity entity)
        {
            if (ChargeCount-- > 0)
            {
                var water = entity.GetProperty(PropertyFactory <WaterProperty> .Instance);
                water.Value += WaterFactory.WaterValuePerCharge;

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 14
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }


            int L1086_ui_Counter = ((511 - Power) / (32 + (Power + 1) / 8)) >> 1;
            int A1088_ui_HealWoundIterationCount = MathHelper.Max(1, Power / 42);

            var health = entity.GetProperty(PropertyFactory <HealthProperty> .Instance);

            health.Value += health.MaxValue / L1086_ui_Counter;

            var bodyParts = entity.Body.BodyParts.ToArray();

            if (bodyParts.Any(x => x.IsWounded))
            { /* If the champion is wounded */
                L1086_ui_Counter = 10;
                do
                {
                    bool atLeasOneHealed = false;
                    int  A1085_ui_Counter;
                    for (A1085_ui_Counter = 0; A1085_ui_Counter < A1088_ui_HealWoundIterationCount; A1085_ui_Counter++)
                    {
                        //flowing code should be similar to => // L1083_ps_Champion->Wounds &= M06_RANDOM(65536);
                        var maxHealCount = rand.Next(bodyParts.Length) + 1;
                        var healIndices  = Enumerable.Range(0, maxHealCount)
                                           .Select(x => rand.Next(bodyParts.Length))
                                           .ToArray();

                        atLeasOneHealed = false;
                        foreach (int index in healIndices)
                        {
                            var part = bodyParts[index];
                            atLeasOneHealed |= part.IsWounded;
                            part.IsWounded   = false;
                        }
                    }
                    A1088_ui_HealWoundIterationCount = 1;

                    if (atLeasOneHealed)
                    {
                        break;
                    }
                } while (--L1086_ui_Counter >= 0); /* Loop until at least one wound is healed or there are no more heal iterations */
            }
            return(Used = true);
        }
Ejemplo n.º 15
0
        public override int Apply(MapDirection direction)
        {
            var delay           = Factory.Fatigue;
            var requiredSkill   = attackProvider.GetSkill(Factory.SkillIndex);
            var requiredStamina = Factory.Stamina + rand.Next(2);

            PerformAttack(direction, ref delay);

            if (requiredStamina > 0)
            {
                attackProvider.GetProperty(PropertyFactory <StaminaProperty> .Instance).Value -= requiredStamina;
            }
            if (Factory.ExperienceGain > 0)
            {
                requiredSkill.AddExperience(Factory.ExperienceGain);
            }
            return(delay);
        }
Ejemplo n.º 16
0
        public async void Run(ILiveEntity caster, MapDirection direction)
        {
            var light = caster.GetProperty(PropertyFactory <MagicalLightProperty> .Instance);

            light.Value += Factory.LightPowerToLightAmount[lightPower];

            lightPower *= -1;

            while (true)
            {
                await Task.Delay(duration);

                if (lightPower == 0)
                {
                    return;
                }

                bool negative = lightPower < 0;
                if (negative)
                {
                    lightPower *= -1;
                }

                int weakerLightPower    = lightPower - 1;
                int A0674_i_LightAmount = Factory.LightPowerToLightAmount[lightPower] - Factory.LightPowerToLightAmount[weakerLightPower];
                if (negative)
                {
                    A0674_i_LightAmount = -A0674_i_LightAmount;
                    weakerLightPower   *= -1;
                }

                light.Value += A0674_i_LightAmount;
                if (weakerLightPower != 0)
                {
                    lightPower = weakerLightPower;
                    duration   = 4000 / 6;
                }
                else
                {
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }

            int A1085_ui_AdjustedPotionPower = (Power / 25) + 8;
            var manaProperty  = entity.GetProperty(PropertyFactory <ManaProperty> .Instance);
            int A1088_ui_Mana = MathHelper.Min(900, (manaProperty.Value + A1085_ui_AdjustedPotionPower) + (A1085_ui_AdjustedPotionPower - 8));

            //bounds check should do property itself
            //if (A1088_ui_Mana > L1083_ps_Champion->MaximumMana)
            //{
            //    A1088_ui_Mana -= (A1088_ui_Mana - MathHelper.Max(L1083_ps_Champion->CurrentMana, L1083_ps_Champion->MaximumMana)) >> 1;
            //}
            manaProperty.Value = A1088_ui_Mana;
            return(Used = true);
        }
Ejemplo n.º 18
0
        public override bool ApplyEffect(ILiveEntity entity)
        {
            if (Used)
            {
                return(false);
            }
            int A1085_ui_AdjustedPotionPower = (Power / 25) + 8;

            A1085_ui_AdjustedPotionPower += A1085_ui_AdjustedPotionPower >> 1;

            var shieldDefense = entity.GetProperty(PropertyFactory <ShieldDefenseProperty> .Instance);

            if (shieldDefense.Value > 50)
            {
                A1085_ui_AdjustedPotionPower >>= 2;
            }

            shieldDefense.Value += A1085_ui_AdjustedPotionPower;
            DisableEffectAsync(shieldDefense, (A1085_ui_AdjustedPotionPower * A1085_ui_AdjustedPotionPower) * 1000 / 6, -A1085_ui_AdjustedPotionPower);

            return(Used = true);
        }
Ejemplo n.º 19
0
        protected ProjectileProperties?F327_kzzz_CHAMPION_IsProjectileSpellCast(ILiveEntity L0992_ps_Champion, int P681_i_KineticEnergy, int P682_ui_RequiredManaAmount)
        {
            var mana = L0992_ps_Champion.GetProperty(PropertyFactory <ManaProperty> .Instance);

            if (mana.Value < P682_ui_RequiredManaAmount)
            {
                return(null);
            }

            mana.Value -= P682_ui_RequiredManaAmount;


            //M08_SET(L0992_ps_Champion->Attributes, MASK0x0100_STATISTICS);
            int L0991_i_StepEnergy = 10 - MathHelper.Min(8, mana.MaxValue >> 3);

            if (P681_i_KineticEnergy < (L0991_i_StepEnergy << 2))
            {
                P681_i_KineticEnergy += 3;
                L0991_i_StepEnergy--;
            }
            return(new ProjectileProperties(P681_i_KineticEnergy, L0991_i_StepEnergy, 90));
        }
Ejemplo n.º 20
0
        int F309_awzz_CHAMPION_GetMaximumLoad(/*P647_ps_Champion*/)
        {
            //int L0930_i_Wounds;

            int L0929_ui_MaximumLoad = (liveEntity.GetProperty(PropertyFactory <StrengthProperty> .Instance).Value << 3) + 100;

            L0929_ui_MaximumLoad = MeleeAttack.F306_xxxx_CHAMPION_GetStaminaAdjustedValue(/*P647_ps_Champion,*/ liveEntity.GetProperty(PropertyFactory <StaminaProperty> .Instance), L0929_ui_MaximumLoad);
            //if (L0930_i_Wounds = P647_ps_Champion->Wounds)
            if (liveEntity.Body.BodyParts.Any(b => b.IsWounded))
            {
                L0929_ui_MaximumLoad -= L0929_ui_MaximumLoad >> (liveEntity.Body.BodyParts.First(b => b.Type == LegsStorageType.Instance).IsWounded ? 2 : 3);// (M07_GET(L0930_i_Wounds, MASK0x0010_LEGS) ? 2 : 3);
            }
            //if (F033_aaaz_OBJECT_GetIconIndex(P647_ps_Champion->Slots[C05_SLOT_FEET]) == C119_ICON_ARMOUR_ELVEN_BOOTS)
            //{
            //    L0929_ui_MaximumLoad += L0929_ui_MaximumLoad >> 4;
            //}
            L0929_ui_MaximumLoad += AdditionalValues.Sum(x => x.Value);
            //
            L0929_ui_MaximumLoad += 9;
            L0929_ui_MaximumLoad -= L0929_ui_MaximumLoad % 10; /* Round the value to the next multiple of 10 */
            return(L0929_ui_MaximumLoad);
        }