コード例 #1
0
        public virtual bool CheckAllowHarmful(Mobile m, Mobile target)
        {
            if (m == null || m.Deleted || target == null || target.Deleted)
            {
                return(false);
            }

            if (State != PvPBattleState.Running)
            {
                return(State == PvPBattleState.Internal || Hidden);
            }

            if (!Options.Rules.AllowHarmful)
            {
                return(false);
            }

            bool checkRegions = false;

            if (m is BaseCreature && target is BaseCreature)
            {
                BaseCreature mC      = (BaseCreature)m;
                BaseCreature targetC = (BaseCreature)target;

                if (BattleNotoriety.HarmfulParent != null)
                {
                    return(BattleNotoriety.HarmfulParent(mC, targetC));
                }

                checkRegions = true;
            }
            else if (m is BaseCreature && target is PlayerMobile)
            {
                BaseCreature mC      = (BaseCreature)m;
                PlayerMobile targetP = (PlayerMobile)target;

                if (IsParticipant(targetP))
                {
                    if (BattleNotoriety.HarmfulParent != null)
                    {
                        return(BattleNotoriety.HarmfulParent(mC, targetP));
                    }
                }
                else
                {
                    checkRegions = true;
                }
            }
            else if (m is PlayerMobile && target is BaseCreature)
            {
                PlayerMobile mP      = (PlayerMobile)m;
                BaseCreature targetC = (BaseCreature)target;

                if (IsParticipant(mP))
                {
                    if (BattleNotoriety.HarmfulParent != null)
                    {
                        return(BattleNotoriety.HarmfulParent(mP, targetC));
                    }
                }
                else
                {
                    checkRegions = true;
                }
            }
            else if (m is PlayerMobile && target is PlayerMobile)
            {
                PvPTeam      teamA, teamB;
                PlayerMobile mP = (PlayerMobile)m, targetP = (PlayerMobile)target;

                if (IsParticipant(mP, out teamA) && IsParticipant(targetP, out teamB))
                {
                    if (teamA == teamB)
                    {
                        if (!CanDamageOwnTeam(mP, targetP))
                        {
                            return(false);
                        }
                    }
                    else if (!CanDamageEnemyTeam(mP, targetP))
                    {
                        return(false);
                    }
                }
                else
                {
                    checkRegions = true;
                }
            }

            return(!checkRegions || m.Region == null || target.Region == null ||
                   ((!m.InRegion(BattleRegion) || !target.InRegion(BattleRegion)) &&
                    (!m.InRegion(SpectateRegion) || !target.InRegion(SpectateRegion)) &&
                    (!m.InRegion(BattleRegion) || !target.InRegion(SpectateRegion)) &&
                    (!m.InRegion(SpectateRegion) || !target.InRegion(BattleRegion))));
        }