Exemple #1
0
        // sub_3F4EB
        internal static bool AttackTarget01(Item item, int arg_8, Player target, Player attacker)
        {
            int target_ac;
            bool turnComplete = true;
            bool BehindAttack = arg_8 != 0;
            turnComplete = false;
            gbl.bytes_1D2C9[1] = 0;
            gbl.bytes_1D2C9[2] = 0;
            gbl.bytes_1D900[1] = 0;
            gbl.bytes_1D900[2] = 0;
            bool var_11 = false;
            bool targetNotInCombat = false;
            gbl.damage = 0;

            attacker.actions.field_8 = true;

            if (target.IsHeld() == true)
            {
                seg044.PlaySound(Sound.sound_attackHeld);

                while (attacker.AttacksLeft(attacker.actions.attackIdx) == 0)
                {
                    attacker.actions.attackIdx--;
                }

                gbl.bytes_1D900[attacker.actions.attackIdx] += 1;

                DisplayAttackMessage(true, 1, target.hit_point_current + 5, AttackType.Slay, target, attacker);
                ovr024.remove_invisibility(attacker);

                attacker.attack1_AttacksLeft = 0;
                attacker.attack2_AttacksLeft = 0;

                var_11 = true;
                turnComplete = true;
            }
            else
            {
                if (attacker.activeItems.primaryWeapon != null &&
                    (target.field_DE > 0x80 || (target.field_DE & 7) > 1))
                {
                    ItemData itemData = gbl.ItemDataTable[attacker.activeItems.primaryWeapon.type];

                    attacker.attack1_DiceCount = itemData.diceCountLarge;
                    attacker.attack1_DiceSize = itemData.diceSizeLarge;
                    attacker.attack1_DamageBonus -= itemData.bonusNormal;
                    attacker.attack1_DamageBonus += itemData.bonusLarge;
                }

                ovr025.reclac_player_values(target);
                ovr024.CheckAffectsEffect(target, CheckType.Type_11);

                if (CanBackStabTarget(target, attacker) == true)
                {
                    target_ac = target.ac_behind - 4;
                }
                else
                {
                    if (target.actions.AttacksReceived > 1 &&
                        getTargetDirection(target, attacker) == target.actions.direction &&
                        target.actions.directionChanges > 4)
                    {
                        BehindAttack = true;
                    }

                    if (BehindAttack == true)
                    {
                        target_ac = target.ac_behind;
                    }
                    else
                    {
                        target_ac = target.ac;
                    }
                }

                target_ac += RangedDefenseBonus(target, attacker);
                AttackType attack_type = AttackType.Normal;
                if (BehindAttack == true)
                {
                    attack_type = AttackType.Behind;
                }

                if (CanBackStabTarget(target, attacker) == true)
                {
                    attack_type = AttackType.Backstab;
                }

                for (int attackIdx = attacker.actions.attackIdx; attackIdx >= 1; attackIdx--)
                {
                    while (attacker.AttacksLeft(attackIdx) > 0 &&
                        targetNotInCombat == false)
                    {
                        attacker.AttacksLeftDec(attackIdx);
                        attacker.actions.attackIdx = attackIdx;

                        gbl.bytes_1D900[attackIdx] += 1;

                        if (ovr024.PC_CanHitTarget(target_ac, target, attacker) ||
                            target.IsHeld() == true)
                        {
                            gbl.bytes_1D2C9[attackIdx] += 1;

                            seg044.PlaySound(Sound.sound_attackHeld);
                            var_11 = true;
                            sub_3E192(attackIdx, target, attacker);
                            DisplayAttackMessage(true, gbl.damage, gbl.damage, attack_type, target, attacker);

                            if (target.in_combat == true)
                            {
                                ovr024.CheckAffectsEffect(attacker, (CheckType)attackIdx + 1);
                            }

                            if (target.in_combat == false)
                            {
                                targetNotInCombat = true;
                            }

                            if (attacker.in_combat == false)
                            {
                                attacker.AttacksLeftSet(attackIdx, 0);
                            }
                        }
                    }
                }

                if (item != null &&
                    item.count == 0 &&
                    item.type == ItemType.DartOfHornetsNest)
                {
                    attacker.attack1_AttacksLeft = 0;
                    attacker.attack2_AttacksLeft = 0;
                }

                if (var_11 == false)
                {
                    seg044.PlaySound(Sound.sound_9);
                    DisplayAttackMessage(false, 0, 0, attack_type, target, attacker);
                }

                turnComplete = true;
                if (attacker.attack1_AttacksLeft > 0 ||
                    attacker.attack2_AttacksLeft > 0)
                {
                    turnComplete = false;
                }

                attacker.actions.maxSweapTargets = 0;
            }

            if (attacker.in_combat == false)
            {
                turnComplete = true;
            }

            if (turnComplete == true)
            {
                ovr025.clear_actions(attacker);
            }

            return turnComplete;
        }