コード例 #1
0
        private static void CMDisabled()
        {
            InternalizeAllBattles();

            PvPBattle.Unbind();
            BattleNotoriety.Disable();
        }
コード例 #2
0
        public void Init()
        {
            if (Initialized)
            {
                return;
            }

            InvalidateRegions();
            RegisterSubCommands();

            BattleNotoriety.RegisterNotorietyHandler(this, NotorietyHandler);
            BattleNotoriety.RegisterAllowBeneficialHandler(this, AllowBeneficial);
            BattleNotoriety.RegisterAllowHarmfulHandler(this, AllowHarmful);

            EventSink.Shutdown += ServerShutdownHandler;
            EventSink.Logout   += LogoutHandler;
            EventSink.Login    += LoginHandler;

            _CoreTimer = PollTimer.FromSeconds(1.0, OnCoreTick, () => Initialized && !_StateTransition);

            Schedule.OnGlobalTick += OnScheduleTick;

            Teams.Where(team => team != null && !team.Deleted).ForEach(team => team.Init());

            OnInit();

            Initialized = true;

            if (!Validate())
            {
                State = PvPBattleState.Internal;
            }
        }
コード例 #3
0
        private static void CMInvoke()
        {
            PvPBattle.Bind();
            BattleNotoriety.Enable();

            var scenarios = new List <PvPScenario>();

            foreach (var type in BattleTypes.Where(t => t != null))
            {
                VitaNexCore.TryCatch(
                    () =>
                {
                    var battle = type.CreateInstanceSafe <PvPBattle>();

                    if (battle == null)
                    {
                        throw new Exception("PvPBattle Type could not be constructed, requires a constructor with 0 arguments.");
                    }

                    PvPScenario scenario = battle;
                    scenarios.Add(scenario);
                    battle.Delete();

                    CMOptions.ToConsole("Created scenario ({0}) '{1}'", scenario.TypeOf.Name, scenario.Name);
                },
                    CMOptions.ToConsole);
            }

            Scenarios = scenarios.ToArray();
            scenarios.Clear();

            foreach (var battle in Battles.Values.Where(b => b != null && !b.Deleted).ToArray())
            {
                VitaNexCore.TryCatch(
                    battle.Init,
                    ex =>
                {
                    VitaNexCore.TryCatch(battle.Delete);

                    CMOptions.ToConsole("Failed to initialize battle #{0} '{1}'", battle.Serial, battle.Name);
                    CMOptions.ToConsole(ex);
                });
            }

            foreach (var profile in Profiles.Values.Where(p => p != null && !p.Deleted).ToArray())
            {
                VitaNexCore.TryCatch(
                    profile.Init,
                    ex =>
                {
                    VitaNexCore.TryCatch(profile.Delete);

                    CMOptions.ToConsole("Failed to initialize profile #{0} '{1}'", profile.Owner.Serial.Value, profile.Owner.RawName);
                    CMOptions.ToConsole(ex);
                });
            }
        }
コード例 #4
0
 private static void CMDisabled()
 {
     InternalizeAllBattles();
     SeasonSchedule.OnGlobalTick -= ChangeSeason;
     BattleNotoriety.Disable();
 }
コード例 #5
0
 private static void CMEnabled()
 {
     SeasonSchedule.OnGlobalTick += ChangeSeason;
     BattleNotoriety.Enable();
 }
コード例 #6
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))));
        }
コード例 #7
0
 private static void CMEnabled()
 {
     PvPBattle.Bind();
     BattleNotoriety.Enable();
 }
コード例 #8
0
ファイル: AutoPvP_Init.cs プロジェクト: AllanNisbet/runuo
 private static void CMEnabled()
 {
     BattleNotoriety.Enable();
 }