Пример #1
0
        //One huge ugly method. TODO: Split it up.
        public virtual void HandleAttackCheck(Creature attacker, Creature attacked)
        {
            lock (lockThis) {
                if (attacker == attacked) {
                    //throw new Exception("Attacker == attacked in HandleAttackCheck()");
                    return;
                }

                if (attacked == null || !attacked.LogedIn) {
                    attacker.SetCreatureAttacking(null);
                    return;
                }

                if (attacked.CurrentPosition == null) {
                    throw new Exception("Invalid condition in HandleAttackCheck()");
                }

                if (attacked.CurrentHP == 0) {
                    throw new Exception("Attacked is already dead in HandleAttack()");
                }

                bool usingDistance = attacker.UsingDistance();
                DistanceType shootEffect = DistanceType.EFFECT_NONE;
                if (usingDistance) {
                    if (attacker.GetAmmo() == 0) {
                        return;
                    } else {
                        shootEffect = attacker.GetDistanceType();
                    }
                } else if (!usingDistance &&
                    !attacker.IsNextTo(attacked.CurrentPosition)) {
                    return;
                }

                ThingSet tSet = gameMap.GetThingsInVicinity(attacker.CurrentPosition);
                gameMap.GetThingsInVicinity(attacked.CurrentPosition, tSet);

                if (shootEffect != DistanceType.EFFECT_NONE) {
                    AddShootEffect(shootEffect, attacker.CurrentPosition,
                        attacked.CurrentPosition, tSet);
                }

                int dmg = attacked.GetDamageAmt(attacker);
                if (dmg == Constants.PUFF) {
                    AddMagicEffect(MagicEffect.PUFF, attacked.CurrentPosition);
                    dmg = 0;
                } else if (dmg == Constants.SPARK) {
                    AddMagicEffect(MagicEffect.BLOCKHIT, attacked.CurrentPosition);
                    dmg = 0;
                } else {
                    AddMagicEffect(MagicEffect.DRAW_BLOOD, attacked.CurrentPosition);
                }
                AppendAddDamage(attacker, attacked, dmg, ImmunityType.IMMUNE_PHYSICAL, false);
                SendProtocolMessages();
            }
        }
Пример #2
0
        //One huge ugly method. TODO: Split it up.
        public virtual void HandleAttackCheck(Creature attacker, Creature attacked)
        {
            lock (lockThis) {
                if (attacker == attacked)
                {
                    //throw new Exception("Attacker == attacked in HandleAttackCheck()");
                    return;
                }

                if (attacked == null || !attacked.LogedIn)
                {
                    attacker.SetCreatureAttacking(null);
                    return;
                }

                if (attacked.CurrentPosition == null)
                {
                    throw new Exception("Invalid condition in HandleAttackCheck()");
                }

                if (attacked.CurrentHP == 0)
                {
                    throw new Exception("Attacked is already dead in HandleAttack()");
                }

                bool         usingDistance = attacker.UsingDistance();
                DistanceType shootEffect   = DistanceType.EFFECT_NONE;
                if (usingDistance)
                {
                    if (attacker.GetAmmo() == 0)
                    {
                        return;
                    }
                    else
                    {
                        shootEffect = attacker.GetDistanceType();
                    }
                }
                else if (!usingDistance &&
                         !attacker.IsNextTo(attacked.CurrentPosition))
                {
                    return;
                }

                ThingSet tSet = gameMap.GetThingsInVicinity(attacker.CurrentPosition);
                gameMap.GetThingsInVicinity(attacked.CurrentPosition, tSet);

                if (shootEffect != DistanceType.EFFECT_NONE)
                {
                    AddShootEffect(shootEffect, attacker.CurrentPosition,
                                   attacked.CurrentPosition, tSet);
                }

                int dmg = attacked.GetDamageAmt(attacker);
                if (dmg == Constants.PUFF)
                {
                    AddMagicEffect(MagicEffect.PUFF, attacked.CurrentPosition);
                    dmg = 0;
                }
                else if (dmg == Constants.SPARK)
                {
                    AddMagicEffect(MagicEffect.BLOCKHIT, attacked.CurrentPosition);
                    dmg = 0;
                }
                else
                {
                    AddMagicEffect(MagicEffect.DRAW_BLOOD, attacked.CurrentPosition);
                }
                AppendAddDamage(attacker, attacked, dmg, ImmunityType.IMMUNE_PHYSICAL, false);
                SendProtocolMessages();
            }
        }