public CreatureFactory(IGroupLayout layout, string name, int moveDuration, int detectRange, int sightRange, int experience,
                        Texture2D texture, int woundFeet, int woundLegs, int woundTorso, int woundHead, int attack, int poisonAttack, CreatureAttackType attackType, bool attackAny, int attackTicks, int defense, int baseHealth, int dexterity, int poisonResistance, int fireResistance)
 {
     Layout           = layout;
     MoveDuration     = moveDuration;
     Texture          = texture;
     WoundFeet        = woundFeet;
     WoundLegs        = woundLegs;
     WoundTorso       = woundTorso;
     WoundHead        = woundHead;
     Attack           = attack;
     PoisonAttack     = poisonAttack;
     AttackType       = attackType;
     AttackAny        = attackAny;
     AttackTicks      = attackTicks;
     Defense          = defense;
     BaseHealth       = baseHealth;
     Dexterity        = dexterity;
     PoisonResistance = poisonResistance;
     FireResistance   = fireResistance;
     DetectRange      = detectRange;
     SightRange       = sightRange;
     Name             = name;
     Experience       = experience;
     PoisonAttack     = poisonAttack;
 }
Example #2
0
        int F321_AA29_CHAMPION_AddPendingDamageAndWounds_GetDamage(ILiveEntity P662_i_ChampionIndex, int P663_i_Attack, ICollection <IStorageType> P664_i_AllowedWounds, CreatureAttackType P665_i_AttackType)
        {
            int L0977_ui_Defense    = 0;
            int L0978_ui_WoundCount = 0;

            //if ((P662_i_ChampionIndex == CM1_CHAMPION_NONE) || (M00_INDEX_TO_ORDINAL(P662_i_ChampionIndex) == G299_ui_CandidateChampionOrdinal || G302_B_GameWon))
            //{
            //    /* BUG0_00 Useless code. This condition is never true */
            //    return; /* BUG0_01 Coding error without consequence. Undefined return value. No consequence because this code is never executed */
            //}

            if (P663_i_Attack <= 0)
            {
                return(0);
            }

            var L0979_ps_Champion = P662_i_ChampionIndex; //&G407_s_Party.Champions[P662_i_ChampionIndex];

            if (L0979_ps_Champion.GetProperty(PropertyFactory <HealthProperty> .Instance).Value == 0)
            {
                return(0);
            }

            if (P665_i_AttackType != CreatureAttackType.C0_ATTACK_NORMAL)
            {
                //TODO add additional defense modifiers to DefensProperty
                foreach (var bodyPart in L0979_ps_Champion.Body.BodyParts)
                //for (L0978_ui_WoundCount = 0, A0976_i_WoundIndex = C00_SLOT_READY_HAND, L0977_ui_Defense = 0; A0976_i_WoundIndex <= C05_SLOT_FEET; A0976_i_WoundIndex++)
                {
                    if (P664_i_AllowedWounds.Contains(bodyPart.Type))
                    //if (P664_i_AllowedWounds & (1 << A0976_i_WoundIndex))
                    {
                        L0978_ui_WoundCount++;
                        L0977_ui_Defense += F313_xxxx_CHAMPION_GetWoundDefense(P662_i_ChampionIndex, new WoundInfo(P665_i_AttackType == CreatureAttackType.C4_ATTACK_SHARP, bodyPart.Type));
                        //A0976_i_WoundIndex | ((P665_i_AttackType == C4_ATTACK_SHARP) ? MASK0x8000_USE_SHARP_DEFENSE : MASK0x0000_DO_NOT_USE_SHARP_DEFENSE));
                    }
                }

                if (L0978_ui_WoundCount > 0)
                {
                    L0977_ui_Defense /= L0978_ui_WoundCount;
                }

                switch (P665_i_AttackType)
                {
                case CreatureAttackType.C6_ATTACK_PSYCHIC:
                    int A0976_i_WisdomFactor;
                    //->Statistics[C3_STATISTIC_WISDOM][C1_CURRENT]) <= 0)
                    if ((A0976_i_WisdomFactor = 115 - L0979_ps_Champion.GetProperty(PropertyFactory <WisdomProperty> .Instance).Value) <= 0)
                    {
                        P663_i_Attack = 0;
                    }
                    else
                    {
                        P663_i_Attack = F030_aaaW_MAIN_GetScaledProduct(P663_i_Attack, 6, A0976_i_WisdomFactor);
                    }
                    goto T321_024;

                case CreatureAttackType.C5_ATTACK_MAGIC:
                    P663_i_Attack  = F307_fzzz_CHAMPION_GetStatisticAdjustedAttack(L0979_ps_Champion, PropertyFactory <AntiMagicProperty> .Instance, P663_i_Attack);
                    P663_i_Attack -= L0979_ps_Champion.GetProperty(PropertyFactory <SpellShieldDefenseProperty> .Instance).Value;  // G407_s_Party.SpellShieldDefense;
                    goto T321_024;

                case CreatureAttackType.C1_ATTACK_FIRE:
                    P663_i_Attack  = F307_fzzz_CHAMPION_GetStatisticAdjustedAttack(L0979_ps_Champion, PropertyFactory <AntiFireProperty> .Instance, P663_i_Attack);
                    P663_i_Attack -= L0979_ps_Champion.GetProperty(PropertyFactory <FireShieldDefenseProperty> .Instance).Value;   //G407_s_Party.FireShieldDefense;
                    break;

                case CreatureAttackType.C2_ATTACK_SELF:
                    L0977_ui_Defense >>= 1;
                    break;

                case CreatureAttackType.C3_ATTACK_BLUNT:
                case CreatureAttackType.C4_ATTACK_SHARP:
                case CreatureAttackType.C7_ATTACK_LIGHTNING:
                    break;
                }

                P663_i_Attack = F030_aaaW_MAIN_GetScaledProduct(P663_i_Attack, 6, 130 - L0977_ui_Defense); /* BUG0_44 A champion may take much more damage than expected after a Black Flame attack or an impact with a Fireball projectile. If the party has a fire shield defense value higher than the fire attack value then the resulting intermediary attack value is negative and damage should be 0. However, the negative value is still used for further computations and the result may be a very high positive attack value which may kill a champion. This can occur only for ATTACK_FIRE and if P663_i_Attack is negative before calling F030_aaaW_MAIN_GetScaledProduct */
T321_024:
                if (P663_i_Attack <= 0)
                {
                    return(0);
                }

                int A0976_i_AdjustedAttack = F307_fzzz_CHAMPION_GetStatisticAdjustedAttack(L0979_ps_Champion, PropertyFactory <VitalityProperty> .Instance, rand.Next(128) + 10);
                if (P663_i_Attack > A0976_i_AdjustedAttack)
                {
                    /* BUG0_45 This bug is not perceptible because of BUG0_41 that ignores Vitality while determining the probability of being wounded. However if it was fixed, the behavior would be the opposite of what it should: the higher the vitality of a champion, the lower the result of F307_fzzz_CHAMPION_GetStatisticAdjustedAttack and the more likely the champion could get wounded (because of more iterations in the loop below) */
                    do
                    {
                        //M08_SET(G410_ai_ChampionPendingWounds[P662_i_ChampionIndex], (1 << rand.Next(8)) & P664_i_AllowedWounds);
                        var bodyPart = L0979_ps_Champion.Body.BodyParts.ElementAtOrDefault(rand.Next(8));
                        if (bodyPart != null && P664_i_AllowedWounds.Contains(bodyPart.Type))
                        {
                            bodyPart.IsWounded = true;
                        }
                    }while ((P663_i_Attack > (A0976_i_AdjustedAttack <<= 1)) && A0976_i_AdjustedAttack > 0);
                }

                //TODO wake up
                //if (G300_B_PartyIsSleeping)
                //{
                //    F314_gzzz_CHAMPION_WakeUp();
                //}
            }

            //G409_ai_ChampionPendingDamage[P662_i_ChampionIndex] += P663_i_Attack;
            L0979_ps_Champion.GetProperty(PropertyFactory <HealthProperty> .Instance).Value -= P663_i_Attack;
            return(P663_i_Attack);
        }