Пример #1
0
        public static void MeleeAttack(Unit attacker, Unit victim)
        {
            Weapon attackerWeapon = attacker.Inv.Wielded;

            if (attackerWeapon != null)
            {
                if (!attackerWeapon.targetInMeleeRange(attacker.CoordX, attacker.CoordY, victim.CoordX, victim.CoordY))
                {
                    //Zomg error
                    _DEBUG.AddDebugMessage("ERROR: attempt to melee from non-melee range.");
                }

                attacker.Timing.AddActionTime(TimeCost.MeleeAttackCost(attacker));
                int  finalDamage   = CalculateMeleeDamage(attacker, victim);
                bool victimStabbed = false;

                if (attacker.Inv.Wielded.TypeOfMeleeDamage == Weapon.MeleeDamageTypes.Stab && victim.IsUnaware())
                {
                    finalDamage *= 6; //zomg
                    Log.AddOneFromList(StringFactory.AttackerStabsVictim(attacker, victim));
                    victimStabbed = true;
                }
                else
                {
                    if (attacker is Player)
                    {
                        Log.AddLine("You hit " + victim.Name + " with your " + attacker.Inv.Wielded.DisplayName + "!");
                    }
                    else
                    {
                        Log.AddLine(attacker.Name + " hits " + victim.Name + " with the " + attacker.Inv.Wielded.DisplayName + "!");
                    }
                }

                victim.Hitpoints -= finalDamage;
                if (attacker is Player)
                {
                    _DEBUG.AddDebugMessage(" " + finalDamage.ToString() + " damage");
                }

                if (victim is Player)
                {
                    Gameover.KilledBy = attacker.Name;
                    if (victim.Hitpoints < victim.GetMaxHitpoints() / 3 || victim.Hitpoints < 3)
                    {
                        Log.AddAlertMessage("!!LOW HITPOINT WARNING!!");
                    }
                }
                if (victimStabbed)
                {
                    Log.AddOneFromList(StringFactory.stabbedVictimReacts(victim));
                }
            }
        }