Exemplo n.º 1
0
    protected override void OnErinnMidnightTick(ErinnTime time)
    {
        // Run base (color randomization)
        base.OnErinnMidnightTick(time);

        ClearTab(L("Flowers"));
        ClearTab(L("Bouquet of Flowers"));

        Add(L("Flowers"), 40046);                 // Single Rose
        Add(L("Flowers"), 40046);                 // Single Rose
        Add(L("Flowers"), 40046);                 // Single Rose
        Add(L("Flowers"), 40046);                 // Single Rose
        Add(L("Flowers"), 40046);                 // Single Rose
        if (time.Month == ErinnMonth.Samhain)     // Saturday
        {
            Add(L("Flowers"), 40052);             // Single Blue Rose
        }
        Add(L("Bouquet of Flowers"), 40047);      // Rose Bouquet
        Add(L("Bouquet of Flowers"), 40047);      // Rose Bouquet
        Add(L("Bouquet of Flowers"), 40047);      // Rose Bouquet
        Add(L("Bouquet of Flowers"), 40047);      // Rose Bouquet
        Add(L("Bouquet of Flowers"), 40047);      // Rose Bouquet
        if (time.Month == ErinnMonth.AlbanHeruin) // Wednesday
        {
            Add(L("Bouquet of Flowers"), 40054);  // Blue Rose Bouquet
        }
    }
Exemplo n.º 2
0
        public void ErinnTimeCalculation()
        {
            var time1 = new ErinnTime(DateTime.Parse("2015-01-01 00:00"));

            Assert.Equal(550, time1.Year);
            Assert.Equal(4, time1.Month);
            Assert.Equal(1, time1.Day);
            Assert.Equal(0, time1.Hour);
            Assert.Equal(0, time1.Minute);

            var time2 = new ErinnTime(DateTime.Parse("2015-01-01 23:59"));

            Assert.Equal(550, time2.Year);
            Assert.Equal(4, time2.Month);
            Assert.Equal(40, time2.Day);
            Assert.Equal(23, time2.Hour);
            Assert.Equal(20, time2.Minute);

            var time3 = new ErinnTime(ErinnTime.BeginOfTime);

            Assert.Equal(1, time3.Year);
            Assert.Equal(2, time3.Month);
            Assert.Equal(1, time3.Day);
            Assert.Equal(0, time3.Hour);
            Assert.Equal(0, time3.Minute);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called at 6:00 and 18:00 Erinn Time, broadcasts notice about
        /// active events.
        /// </summary>
        /// <param name="now"></param>
        private void OnErinnDaytimeTick(ErinnTime now)
        {
            var activeEvents = this.GetActiveEvents();
            var message      = GetBroadcastMessage(activeEvents);

            Send.Notice(NoticeType.TopGreen, message);
        }
Exemplo n.º 4
0
    protected override void OnErinnMidnightTick(ErinnTime time)
    {
        // Run base (color randomization)
        base.OnErinnMidnightTick(time);

        // Add 0~2 random weapons with random enchants to the
        // Advanced Weapon tab
        var rnd      = RandomProvider.Get();
        var addCount = rnd.Next(0, 3);

        ClearTab("Advanced Weapon");

        for (int i = 0; i < addCount; ++i)
        {
            var itemId          = RandomWeapons[rnd.Next(RandomWeapons.Length)];
            var suffixIdx       = rnd.Next(RandomSuffixes.Length);
            var suffixId        = RandomSuffixes[suffixIdx];
            var priceMultiplier = PriceMultiplier[suffixIdx];

            var item  = Item.CreateEnchanted(itemId, Prefix, suffixId);
            var price = (item.OptionInfo.Price * priceMultiplier);
            var stock = rnd.Next(1, 4);

            Add("Advanced Weapon", item, price, stock);
        }
    }
Exemplo n.º 5
0
    private void UpdateCurrentGates(ErinnTime now)
    {
        var table = GetTable();

        // Add 9 minutes, to compensate for the 6 in-game hours between
        // 18:00 and 00:00, otherwise we get the gates for the next day
        // when starting the server between 00:00 and 05:59.
        var cycles = (int)((DateTime.Now.AddMinutes(9) - ErinnTime.BeginOfTime).TotalSeconds / 2160);

        currentGateKeyword = table[cycles % table.Length];
        nextGateKeyword    = table[(cycles + 1) % table.Length];

        // During the day the "current" gate is the next gate.
        if (now.IsDay)
        {
            currentGateKeyword = nextGateKeyword;
        }

        if (!gatesStr.TryGetValue(currentGateKeyword, out currentGate))
        {
            throw new Exception("Gate '" + currentGateKeyword + "' not found.");
        }

        SendMoonGateInfoRequestR(currentGateKeyword, nextGateKeyword);
    }
Exemplo n.º 6
0
	public void OnErinnDaytimeTick(ErinnTime time)
	{
		if (!time.IsNight)
			NPC.Warp(48, 11100, 30400);
		else
			NPC.Warp(22, 5800, 7100);
	}
Exemplo n.º 7
0
    private void UpdateCurrentGates(ErinnTime now)
    {
        var table         = GetTable();
        var nowDt         = now.DateTime;
        var beginOfTimeDt = ErinnTime.BeginOfTime;

        // The begin of time is at 00:00 on some day, if we used it as is,
        // we'd get a cycle for between 00:00 and 23:59 Erinn time, and the
        // cycle for the *next* day after 00:00 Erinn time, when it's
        // actually still the same, since it's still the same night. Adding
        // 9 minutes (6 Erinn hours) to the begin of time fixes this.
        beginOfTimeDt = beginOfTimeDt.AddMinutes(9);

        var cycles = (int)((nowDt - beginOfTimeDt).TotalSeconds / 2160);

        currentGateKeyword = table[cycles % table.Length];
        nextGateKeyword    = table[(cycles + 1) % table.Length];

        if (!gatesStr.TryGetValue(currentGateKeyword, out currentGate))
        {
            throw new Exception("Gate '" + currentGateKeyword + "' not found.");
        }

        SendMoonGateInfoRequestR(currentGateKeyword, nextGateKeyword);
    }
Exemplo n.º 8
0
    public void OnErinnDaytimeTick(ErinnTime now)
    {
        var firstRun = (currentGateKeyword == null);

        if (now.IsDawn || firstRun)
        {
            UpdateCurrentGates(now);
        }

        // Just update gates on first run, to set initial state.
        if (firstRun)
        {
            UpdateGates(now);
            return;
        }

        // Open gates after 12s, after the Eweca msg disappeared.
        Task.Delay(12000).ContinueWith(_ =>
        {
            UpdateGates(now);
            if (!IsEnabled("MoonTunnel"))
            {
                Send.Notice(NoticeType.MiddleSystem, string.Format(L("Moon Gates leading to {0} have appeared all across Erinn."), currentGate.Name));
            }
        });
    }
Exemplo n.º 9
0
    protected override void OnErinnMidnightTick(ErinnTime time)
    {
        // Run base (color randomization)
        base.OnErinnMidnightTick(time);

        //re-add shop update script here when finished
    }
Exemplo n.º 10
0
 public void OnErinnTimeTick(ErinnTime time)
 {
     if (time.Minute == 0 && (time.Hour == 9 | time.Hour == 15 | time.Hour == 19)) // Warp in
     {
         int plusX = Random(0, 4000);
         int plusY = Random(0, 4000);
         NPC.WarpFlash(53, 102000 + plusX, 106000 + plusY);
     }
     else if (time.Minute == 0 && (time.Hour == 11 | time.Hour == 17 | time.Hour == 21)) // Warp out
     {
         NPC.WarpFlash(22, 6000, 5000);
     }
     else        // If it is not x:00, there's a 0~6 chance to move
     {
         int chanceToMove = Convert.ToInt32(Random() % 6);
         if (chanceToMove == 1)
         {
             Position currentPos = this.NPC.GetPosition();
             int      newX       = currentPos.X;
             int      newY       = currentPos.Y;
             newX += Convert.ToInt32(Random(-300, 300) % 100);
             newY += Convert.ToInt32(Random(-300, 300) % 100);
             Position newPos = new Position(newX, newY);
             this.NPC.Move(newPos, true);
         }
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Called every 5 minutes to synchronize guild information.
 /// </summary>
 /// <param name="now"></param>
 private void OnMabiTick(ErinnTime now)
 {
     // Synchronizing the guilds can take a few milliseconds if there
     // are many in the db. Run it in a thread so we don't block
     // the world thread.
     // Should this be the default for all time events...?
     Task.Factory.StartNew(SynchronizeGuilds);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Broadcasts Eweca notice, called at 6:00 and 18:00.
        /// </summary>
        /// <param name="now"></param>
        private void OnErinnDaytimeTick(ErinnTime now)
        {
            var notice = now.IsNight
                                ? Localization.Get("Eweca is rising.\nMana is starting to fill the air all around.")
                                : Localization.Get("Eweca has disappeared.\nThe surrounding Mana is starting to fade away.");

            Send.Notice(NoticeType.MiddleTop, notice);
        }
Exemplo n.º 13
0
    protected override void OnErinnMidnightTick(ErinnTime time)
    {
        // Run base (color randomization)
        base.OnErinnMidnightTick(time);

        ClearTab(L("Suspicious Item"));

        Add(L("Suspicious Item"), 18089);         // Purple Rose Decoration

        if (Random(100) < 50)
        {
            Add(L("Suspicious Item"), 16519);             // Glove of Extravaganza
        }
        else
        {
            Add(L("Suspicious Item"), 16518);             // Couple Ring Glove
        }
        if ((time.Month == ErinnMonth.Imbolic) || (time.Month == ErinnMonth.AlbanHeruin))
        {
            Add(L("Suspicious Item"), 40053);             // Purple Rose Bouquet
        }
        if (Random(30) < 10)
        {
            switch (time.Month)
            {
            case ErinnMonth.Imbolic:                                                             // Sunday
                Add(L("Suspicious Item"), 40057);                                                // 0 Sign
                Add(L("Suspicious Item"), 14005, 0x00202020, 0x00202020, 0x00202020, 129800, 1); // Drandos Leather Mail (F)
                break;

            case ErinnMonth.AlbanEiler:                                                        // Monday
                Add(L("Suspicious Item"), 40051);                                              // Single Purple Rose
                Add(L("Suspicious Item"), 40011, 0x00202020, 0x00202020, 0x00202020, 3500, 4); // Broadsword
                break;

            case ErinnMonth.Baltane:                                                            // Tuesday
                Add(L("Suspicious Item"), 18521, 0x00202020, 0x00202020, 0x00202020, 43800, 3); // European Comb
                break;

            case ErinnMonth.AlbanHeruin:                                                         // Wednesday
                Add(L("Suspicious Item"), 13015, 0x00202020, 0x00202020, 0x00202020, 242750, 1); // Brigandine
                break;

            case ErinnMonth.Lughnasadh:                                                        // Thursday
                Add(L("Suspicious Item"), 40016, 0x00202020, 0x00202020, 0x00202020, 2900, 2); // Warhammer
                break;

            case ErinnMonth.AlbanElved:                                                         // Friday
                Add(L("Suspicious Item"), 18519, 0x00202020, 0x00202020, 0x00202020, 47850, 3); // Panache Head Protector
                break;

            case ErinnMonth.Samhain:                                                            // Saturday
                Add(L("Suspicious Item"), 40051);                                               // Single Purple Rose
                Add(L("Suspicious Item"), 18515, 0x00202020, 0x00202020, 0x00202020, 47000, 3); // Twin Horn Cap
                break;
            }
        }
    }
Exemplo n.º 14
0
        /// <summary>
        /// Applies regens to creature.
        /// </summary>
        /// <remarks>
        /// (Should be) called once a second.
        /// - Hunger doesn't go beyond 50% of max stamina.
        /// - Stamina regens at 20% efficiency from StaminaHunger onwards.
        /// </remarks>
        public void OnSecondsTimeTick(ErinnTime time)
        {
            if (this.Creature.Region == Region.Limbo || this.Creature.IsDead)
            {
                return;
            }

            // Recover from knock back/down after stun ended
            if (this.Creature.WasKnockedBack && !this.Creature.IsStunned)
            {
                Send.RiseFromTheDead(this.Creature);
                this.Creature.WasKnockedBack = false;
            }

            lock (_regens)
            {
                var toRemove = new List <int>();

                foreach (var regen in _regens.Values)
                {
                    if (regen.TimeLeft == 0)
                    {
                        toRemove.Add(regen.Id);
                        continue;
                    }

                    switch (regen.Stat)
                    {
                    // TODO: Triple mana automatically at night?

                    case Stat.Life: this.Creature.Life += regen.Change; break;

                    case Stat.Mana: this.Creature.Mana += regen.Change; break;

                    case Stat.Stamina:
                        // Only positve regens are affected by the hunger multiplicator.
                        this.Creature.Stamina += regen.Change * (regen.Change > 0 ? this.Creature.StaminaRegenMultiplicator : 1);
                        break;

                    case Stat.Hunger:
                        // Regen can't lower hunger below a certain amount.
                        this.Creature.Hunger += regen.Change;
                        if (this.Creature.Hunger > this.Creature.StaminaMax / 2)
                        {
                            this.Creature.Hunger = this.Creature.StaminaMax / 2;
                        }
                        break;

                    case Stat.LifeInjured: this.Creature.Injuries -= regen.Change; break;
                    }
                }

                foreach (var id in toRemove)
                {
                    this.Remove(id);
                }
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Returns Mabi-style time span string.
        /// </summary>
        /// <example>
        /// If same day: Today night
        /// If tomorrow: Tomorrow dawn
        /// Some day: 3 days morning
        /// </example>
        /// <param name="now"></param>
        /// <param name="future"></param>
        /// <returns></returns>
        public string GetTimeSpanString(ErinnTime now, ErinnTime future)
        {
            // Calculate days
            var m1   = (now.Year * 7 * 40 * 24 * 60) + (now.Month * 40 * 24 * 60) + (now.Day * 24 * 60) + (now.Hour * 60) + now.Minute;
            var m2   = (future.Year * 7 * 40 * 24 * 60) + (future.Month * 40 * 24 * 60) + (future.Day * 24 * 60) + (future.Hour * 60) + future.Minute;
            var days = (m2 - m1) / 60.0 / 24.0;

            if (future.Hour * 100 + future.Minute > now.Hour * 100 + now.Minute)
            {
                days = Math.Floor(days);
            }
            else
            {
                days = Math.Ceiling(days);
            }

            // Get days part
            var time = "";

            if (future.DateTimeStamp == now.DateTimeStamp)
            {
                time = L("Today");
            }
            else if (future.DateTimeStamp == now.DateTimeStamp + 1)
            {
                time = L("Tomorrow");
            }
            else if (future.DateTimeStamp == now.DateTimeStamp + 2)
            {
                time = L("the day after tomorrow");
            }
            else
            {
                time = string.Format(LN("{0} day", "{0} days", (int)days), (int)days);
            }

            // Get time of day part
            var hour = future.Hour;

            if (hour >= 20)
            {
                time += L(" night");
            }
            else if (hour >= 12)
            {
                time += L(" afternoon");
            }
            else if (hour >= 6)
            {
                time += L(" morning");
            }
            else if (hour >= 0)
            {
                time += L(" dawn");
            }

            return(time);
        }
Exemplo n.º 16
0
    protected override SpawnInfo GetNextSpawn()
    {
        var spawn = new SpawnInfo();

        spawn.BossName = L("Pillow Fighters");
        spawn.Time     = ErinnTime.GetNextTime(19, 0).DateTime;
        spawn.LifeSpan = TimeSpan.FromMinutes(6);

        return(spawn);
    }
Exemplo n.º 17
0
 public void OnErinnDaytimeTick(ErinnTime time)
 {
     if (!time.IsNight)
     {
         NPC.Warp(48, 11100, 30400);
     }
     else
     {
         NPC.Warp(22, 5800, 7100);
     }
 }
Exemplo n.º 18
0
 /// <summary>
 /// Adds additional mana regen at night.
 /// </summary>
 /// <param name="time"></param>
 public void OnErinnDaytimeTick(ErinnTime time)
 {
     if (time.IsNight)
     {
         this.Add("NightMana", Stat.Mana, 0.1f, this.Creature.ManaMax);
     }
     else
     {
         this.Remove("NightMana");
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Sets skill's auto cancel time and cool down.
        /// </summary>
        /// <param name="creature"></param>
        /// <param name="skill"></param>
        private void SetTimers(Creature creature, Skill skill)
        {
            var duration = this.GetDuration(creature, skill);

            duration = TimeSpan.FromMilliseconds(Math.Max(1000, duration.TotalMilliseconds * ChannelServer.Instance.Conf.World.PaladinDurationRate));

            creature.Skills.CancelAfter(skill.Info.Id, duration);
            skill.SetCoolDownEnd(ErinnTime.GetNextTime(6, 0).DateTime);

            creature.Death += this.OnDeath;
        }
Exemplo n.º 20
0
        public void ErinnTimeToString()
        {
            var time1 = new ErinnTime(DateTime.Parse("2015-01-01 00:00"));

            Assert.Equal("550-4-01 00:00", time1.ToString());
            Assert.Equal("0550-04-01 0:0", time1.ToString("yyyy-MM-dd H:m"));
            Assert.Equal("00:00 AM", time1.ToString("HH:mm tt"));

            var time2 = new ErinnTime(DateTime.Parse("2015-01-01 23:59"));

            Assert.Equal("23:20 PM", time2.ToString("HH:mm tt"));
        }
Exemplo n.º 21
0
 /// <summary>
 /// 5 min tick, global var saving.
 /// </summary>
 /// <param name="time"></param>
 public void OnMabiTick(ErinnTime time)
 {
     try
     {
         ChannelServer.Instance.Database.SaveVars("Aura System", 0, this.GlobalVars.Perm);
         Log.Info("Saved global script variables.");
     }
     catch (Exception ex)
     {
         Log.Exception(ex, "Failed to save global script variables.");
     }
 }
Exemplo n.º 22
0
        /// <summary>
        /// Removes overdue conditions.
        /// </summary>
        /// <param name="time"></param>
        public void OnSecondsTimeTick(ErinnTime time)
        {
            lock (_durations)
            {
                var deactivate = _durations.Where(a => time.DateTime > a.Value).Select(a => a.Key).ToArray();

                foreach (var conditionId in deactivate)
                {
                    this.Deactivate(conditionId);
                    _durations.Remove(conditionId);
                }
            }
        }
Exemplo n.º 23
0
    public void OnCreatureCompletedPtj(Creature creature, PtjType type)
    {
        // the Diligent
        // Enable if creature completed a PTJ 100 times.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(33))
        {
            var trackRecord = creature.Quests.GetPtjTrackRecord(type);
            if (trackRecord.Done >= 100)
            {
                creature.EnableTitle(33);
                creature.ShowTitle(35);
            }
        }

        // the Super Diligent
        // Enable if creature completed a PTJ 10,000 times.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(35))
        {
            var trackRecord = creature.Quests.GetPtjTrackRecord(type);
            if (trackRecord.Done >= 10000)
            {
                creature.EnableTitle(35);
            }
        }

        // the Busy
        // Enable if creature completed 3 Part-time Jobs in one Erinn day.
        // ------------------------------------------------------------------
        if (!creature.CanUseTitle(10154))
        {
            var now   = ErinnTime.Now;
            var count = 0;

            var trackRecords = creature.Quests.GetPtjTrackRecords();
            foreach (var record in trackRecords)
            {
                var change = new ErinnTime(record.LastChange);
                if (now.Day == change.Day && now.Month == change.Month && now.Year == change.Year)
                {
                    count++;
                }
            }

            if (count >= 3)
            {
                creature.EnableTitle(10154);
            }
        }
    }
Exemplo n.º 24
0
Arquivo: Party.cs Projeto: yukpiz/aura
        /// <summary>
        /// Raised once every minute.
        /// </summary>
        /// <param name="time"></param>
        private void OnMinutesTimeTick(ErinnTime time)
        {
            if (this.Type == PartyType.Dungeon && this.IsOpen)
            {
                if ((_adTimer++) < 5)
                {
                    return;
                }

                Send.PartyAdChat(this);
            }

            _adTimer = 0;
        }
Exemplo n.º 25
0
 public void OnErinnTimeTick(ErinnTime time)
 {
     if (ErinnHour(16, 6))
     {
         if (NPC.RegionId != 52)
         {
             NPC.Warp(NormalLocation);
         }
     }
     else if (NPC.RegionId != 22)
     {
         NPC.Warp(TempLocation);
     }
 }
Exemplo n.º 26
0
 public void OnErinnTimeTick(ErinnTime time)
 {
     if ((ErinnHour(9, 11)) || (ErinnHour(15, 17)) || (ErinnHour(19, 21)))
     {
         if (NPC.RegionId != 53)
         {
             NPC.Warp(53, 103322, 109446);
         }
     }
     else if (NPC.RegionId != 22)
     {
         NPC.Warp(22, 6500, 4800);
     }
 }
Exemplo n.º 27
0
        /// <summary>
        /// Raised every 5 minutes, removes empty dungeons.
        /// </summary>
        /// <remarks>
        /// TODO: Is removing on MabiTick what we want? How long do dungeons
        ///   stay active before they're removed? This could remove a dungeon
        ///   the minute, even the second, the last player leaves it.
        /// </remarks>
        /// <param name="time"></param>
        private void OnMabiTick(ErinnTime time)
        {
            lock (_createAndCleanUpLock)
            {
                List <long> remove;
                lock (_syncLock)
                    remove = _dungeons.Values.Where(a => a.CountPlayers() == 0).Select(b => b.InstanceId).ToList();

                foreach (var instanceId in remove)
                {
                    this.Remove(instanceId);
                }
            }
        }
Exemplo n.º 28
0
    private void OnErinnMidnightTick(ErinnTime now)
    {
        // Stay on GM Island if feature is not enabled.
        if (!IsEnabled("Price"))
        {
            return;
        }

        var timestamp   = (now.Year * 7 * 40 + now.Month * 40 + now.Day);
        var locationIdx = (timestamp % locations.Length);
        var location    = locations[locationIdx];

        NPC.Warp(location);
    }
Exemplo n.º 29
0
        /// <summary>
        /// Applies regens to creature.
        /// </summary>
        /// <remarks>
        /// (Should be) called once a second.
        /// - Hunger doesn't go beyond 50% of max stamina.
        /// - Stamina regens at 20% efficiency from StaminaHunger onwards.
        /// </remarks>
        public void OnSecondsTimeTick(ErinnTime time)
        {
            if (this.Creature.Region == null || this.Creature.IsDead)
            {
                return;
            }

            lock (_regens)
            {
                var toRemove = new List <int>();

                foreach (var regen in _regens.Values)
                {
                    if (regen.TimeLeft == 0)
                    {
                        toRemove.Add(regen.Id);
                        continue;
                    }

                    switch (regen.Stat)
                    {
                    case Stat.Life: this.Creature.Life += regen.Change; break;

                    case Stat.Mana: this.Creature.Mana += regen.Change; break;

                    case Stat.Stamina:
                        // Only positve regens are affected by the hunger multiplicator.
                        this.Creature.Stamina += regen.Change * (regen.Change > 0 ? this.Creature.StaminaRegenMultiplicator : 1);
                        break;

                    case Stat.Hunger:
                        // Regen can't lower hunger below a certain amount.
                        this.Creature.Hunger += regen.Change;
                        if (this.Creature.Hunger > this.Creature.StaminaMax / 2)
                        {
                            this.Creature.Hunger = this.Creature.StaminaMax / 2;
                        }
                        break;

                    case Stat.LifeInjured: this.Creature.Injuries -= regen.Change; break;
                    }
                }

                foreach (var id in toRemove)
                {
                    this.Remove(id);
                }
            }
        }
Exemplo n.º 30
0
        public void ErinnTimeToString()
        {
            var time1 = new ErinnTime(DateTime.Parse("2015-01-01 00:00"));

            Assert.Equal("550-4-01 00:00", time1.ToString());
            Assert.Equal("0550-04-01 0:0", time1.ToString("yyyy-MM-dd H:m"));
            Assert.Equal("00:00 AM", time1.ToString("HH:mm tt"));

            Assert.Equal("01 Lughnasadh 550", time1.ToString("dd MMMM yyy"));
            ErinnTime.SetMonthNames("0", "1", "2", "3", "Foobar", "5", "6");
            Assert.Equal("01 Foobar 550", time1.ToString("dd MMMM yyy"));

            var time2 = new ErinnTime(DateTime.Parse("2015-01-01 23:59"));

            Assert.Equal("23:20 PM", time2.ToString("HH:mm tt"));
        }
Exemplo n.º 31
0
        /// <summary>
        /// Called once a minute, used for custom weather and the change weather event.
        /// </summary>
        /// <param name="time"></param>
        private void OnMinutesTimeTick(ErinnTime time)
        {
            if (time.DateTime.Minute % 20 == 0)
            {
                var ev = this.WeatherChange;
                if (ev != null)
                {
                    foreach (var provider in _providers)
                    {
                        ev(provider.Key, provider.Value.GetWeather(time.DateTime));
                    }
                }
            }

            // TODO: Custom weather?
        }
Exemplo n.º 32
0
    public override void OnUse(Creature creature, Item item, string parameter)
    {
        var erinnNow = ErinnTime.Now;
        var spawnTime = item.MetaData1.GetDateTime("BSGRTM");
        if (spawnTime < erinnNow.DateTime)
        {
            Send.MsgBox(creature, Localization.Get("This Fomor Command Scroll is no longer available."));
            return;
        }

        var erinnSpawn = new ErinnTime(spawnTime);
        var bossName = item.MetaData1.GetString("BSGRNM");
        var locationName = item.MetaData1.GetString("BSGRPS");
        var announcerName = creature.Name;
        var time = GetTimeSpanString(erinnNow, erinnSpawn);
        var msg = string.Format(Localization.Get("{0} has informed that {1} will appear in {2} at {3}."), announcerName, bossName, locationName, time);

        Send.Notice(creature.Region, NoticeType.Top, 20000, msg);
    }
Exemplo n.º 33
0
	private void OnErinnMidnightTick(ErinnTime time)
	{
		// Reset available jobs
		remaining = PerDay;
	}
Exemplo n.º 34
0
	public void OnErinnMidnightTick(ErinnTime time)
	{
		remaining = PerDay;
	}
Exemplo n.º 35
0
	public void OnCreatureCompletedPtj(Creature creature, PtjType type)
	{
		// the Diligent
		// Enable if creature completed a PTJ 100 times.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(33))
		{
			var trackRecord = creature.Quests.GetPtjTrackRecord(type);
			if (trackRecord.Done >= 100)
			{
				creature.Titles.Enable(33);
				creature.Titles.Show(35);
			}
		}

		// the Super Diligent 
		// Enable if creature completed a PTJ 10,000 times.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(35))
		{
			var trackRecord = creature.Quests.GetPtjTrackRecord(type);
			if (trackRecord.Done >= 10000)
				creature.Titles.Enable(35);
		}

		// the Busy 
		// Enable if creature completed 3 Part-time Jobs in one Erinn day.
		// ------------------------------------------------------------------
		if (!creature.Titles.IsUsable(10154))
		{
			var now = ErinnTime.Now;
			var count = 0;

			var trackRecords = creature.Quests.GetPtjTrackRecords();
			foreach (var record in trackRecords)
			{
				var change = new ErinnTime(record.LastChange);
				if (now.Day == change.Day && now.Month == change.Month && now.Year == change.Year)
					count++;
			}

			if (count >= 3)
				creature.Titles.Enable(10154);
		}
	}
Exemplo n.º 36
0
	protected override void OnErinnMidnightTick(ErinnTime time)
	{
		// Run base (color randomization)
		base.OnErinnMidnightTick(time);

		// Add 0~2 random weapons with random enchants to the
		// Advanced Weapon tab
		var rnd = RandomProvider.Get();
		var addCount = rnd.Next(0, 3);

		ClearTab("Advanced Weapon");

		for (int i = 0; i < addCount; ++i)
		{
			var itemId = RandomWeapons[rnd.Next(RandomWeapons.Length)];
			var suffixIdx = rnd.Next(RandomSuffixes.Length);
			var suffixId = RandomSuffixes[suffixIdx];
			var priceMultiplier = PriceMultiplier[suffixIdx];

			var item = Item.CreateEnchanted(itemId, Prefix, suffixId);
			var price = (item.OptionInfo.Price * priceMultiplier);

			Add("Advanced Weapon", item, price);
		}
	}
Exemplo n.º 37
0
	private void UpdateCurrentGates(ErinnTime now)
	{
		var table = GetTable();
		var nowDt = now.DateTime;
		var beginOfTimeDt = ErinnTime.BeginOfTime;

		// The begin of time is at 00:00 on some day, if we used it as is,
		// we'd get a cycle for between 00:00 and 23:59 Erinn time, and the
		// cycle for the *next* day after 00:00 Erinn time, when it's
		// actually still the same, since it's still the same night. Adding
		// 9 minutes (6 Erinn hours) to the begin of time fixes this.
		beginOfTimeDt = beginOfTimeDt.AddMinutes(9);

		var cycles = (int)((nowDt - beginOfTimeDt).TotalSeconds / 2160);

		currentGateKeyword = table[cycles % table.Length];
		nextGateKeyword = table[(cycles + 1) % table.Length];

		if (!gatesStr.TryGetValue(currentGateKeyword, out currentGate))
			throw new Exception("Gate '" + currentGateKeyword + "' not found.");

		SendMoonGateInfoRequestR(currentGateKeyword, nextGateKeyword);
	}
Exemplo n.º 38
0
	private void OnErinnMidnightTick(ErinnTime time)
	{
		remaining = PerDay;
	}
Exemplo n.º 39
0
	public void OnErinnDaytimeTick(ErinnTime now)
	{
		var firstRun = (currentGateKeyword == null);

		if (now.IsDusk || currentGateKeyword == null)
			UpdateCurrentGates();

		// Just update gates on first run, to set initial state.
		if (firstRun)
		{
			UpdateGates(now);
			return;
		}

		// Open gates after 12s, after the Eweca msg disappeared.
		Task.Delay(12000).ContinueWith(_ =>
		{
			UpdateGates(now);
			if (!IsEnabled("MoonTunnel"))
				Send.Notice(NoticeType.MiddleSystem, string.Format(L("Moon Gates leading to {0} have appeared all across Erinn."), currentGate.Name));
		});
	}
Exemplo n.º 40
0
	private void UpdateGates(ErinnTime now)
	{
		var state = now.IsNight || AlwaysOpen || IsEnabled("G18") ? "open" : "closed";

		foreach (var gate in gates.Values)
		{
			gate.Prop.State = state;

			// Adds destination name to prop title and a confirmation request
			// when clicking the prop. With MoonTunnel enabled, this depends on
			// whether you're a pet or a character, Aura doesn't support that atm.
			if (!IsEnabled("MoonTunnel"))
			{
				gate.Prop.Xml.SetAttributeValue("target", currentGateKeyword);
				gate.Prop.Xml.SetAttributeValue("nopick", 0); // 1 disables clicking the prop
				gate.Prop.Extensions.Clear();
				gate.Prop.Extensions.Add(new ConfirmationPropExtension("_devent_ask_warp", string.Format(L("Do you wish to travel to the {0} Moon Gate?"), currentGate.Name), ""));
			}

			Send.PropUpdate(gate.Prop);
		}
	}
Exemplo n.º 41
0
	public void OnErinnDaytimeTick(ErinnTime now)
	{
		var state = now.IsNight || AlwaysOpen ? "open" : "closed";

		foreach (var gate in gates.Values)
			gate.Prop.SetState(state);
	}