Esempio n. 1
0
        public string ReportProgress(BossInvasion e)
        {
            if (e.Type > 0 && e.Type < 4)             // Typical Invasions
            {
                if (e.Players.Count == 0)
                {
                    float  num      = (float)Main.dayRate;
                    double distance = 0;
                    if (Main.invasionX > (double)Main.spawnTileX)
                    {
                        distance = Main.invasionX - Main.spawnTileX;
                    }
                    else if (Main.invasionX < (double)Main.spawnTileX)
                    {
                        distance = Main.spawnTileX - Main.invasionX;
                    }
                    return(string.Format("{0} moving into position: {1} ({2} ft)", e.Name, Utils.FormatTime(distance / Main.dayRate / 60), distance / 2));
                }
                int kills = e.InvasionStartSize - Main.invasionSize;
                return(string.Format("{0} progress: {1}/{2} ({3:n0}%) Remaining: {4}", e.Name, kills, e.InvasionStartSize, kills * 100.0 / e.InvasionStartSize, Main.invasionSize));
            }
            else if (e.Type == -4)             // Pumpkin Moon
            {
                if (NPC.waveCount <= pumpkinLevels.Length)
                {
                    try
                    {
                        return(string.Format("{0} Wave {1}/{2} - Points: {3}/{4} - Overall: {5:n0}% Remaining: {6}", e.Name, NPC.waveCount, pumpkinLevels.Length, NPC.waveKills, pumpkinLevels[NPC.waveCount - 1],
                                             ((NPC.waveCount - 1) * 100 / pumpkinLevels.Length) + (NPC.waveKills / pumpkinLevels[NPC.waveCount - 1] * 100 / pumpkinLevels.Length), TimeTilMorning()));
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message);
                        return(ex.Message);
                    }
                }
                else
                {
                    return(string.Format("{0} Final Wave - Points: {1} Remaining: {2}", e.Name, NPC.waveKills, TimeTilMorning()));
                }
            }
            else if (e.Type == -5)             // Frost Moon
            {
                if (NPC.waveCount <= frostLevels.Length)
                {
                    return(string.Format("{0} Wave {1}/{2} - Points: {3}/{4} - Overall: {5:n0}% Remaining: {6}", e.Name, NPC.waveCount, frostLevels.Length, NPC.waveKills, frostLevels[NPC.waveCount - 1],
                                         ((NPC.waveCount - 1) * 100 / frostLevels.Length) + (NPC.waveKills / frostLevels[NPC.waveCount - 1] * 100 / frostLevels.Length), TimeTilMorning()));
                }
                else
                {
                    return(string.Format("{0} Wave {1} - Points: {2} Remaining: {3}", e.Name, NPC.waveCount, NPC.waveKills, TimeTilMorning()));
                }
            }
            else
            {
                return(string.Format("How the f**k did this get executed?! Type: {0}", e.Type));
            }

            //return string.Empty;
        }
Esempio n. 2
0
        private void DoNpcUpdate(int npcID)
        {
            NPC npc = Main.npc[npcID];

            if (npc != null && !npc.active)
            {
                // He died!
                if (npc.boss || bossParents.Contains(npc.netID))
                {
                    int          type = npc.netID == 136 ? 134 : npc.netID;           // the Destroyer's head never updates, so we can watch for the death of the tail
                    BossInvasion boss = bosses.Where(b => b.Type == type && b.Active).FirstOrDefault();
                    if (boss != null && boss.Active)
                    {
                        // Since Eater of Worlds is actually 50 entities, must check on each kill that no other heads are alive
                        // Also, any piece of the Eater of Worlds must have a tail, therefore the minimum number of pieces are 2.
                        if (npc.netID >= 13 && npc.netID <= 15 && Main.npc.Where(n => n.active && n.netID == 14).Count() > 0)
                        {
                            return;
                        }

                        // This is handled in boss.AddDamage for each hit so data should be last update
                        //boss.KilledByPlayer = player.Name;
                        //boss.LastHit = (int)calcDmg;
                        boss.End();
                    }
                }
            }
        }
Esempio n. 3
0
        public string ReportDps(BossInvasion e, Player player, byte timeElapsed)
        {
            // Uses the player's index to reidentify them in the BossInvasion's player list
            Player plr            = e.Players.FirstOrDefault(p => p.Index == player.Index);
            double intervalDamage = plr.DamageGiven - plr.PrevDamageGiven;

            plr.PrevDamageGiven = plr.DamageGiven;
            return(string.Format("Last {0} seconds: {1:n2}dps", timeElapsed, intervalDamage / timeElapsed));
        }
Esempio n. 4
0
        private void DoSpawnBoss(BinaryReader reader)
        {
            int playerInt = reader.ReadInt32();
            int type      = reader.ReadInt32();

            int t = type;

            if (type < 0)
            {
                if (type == -1)
                {
                    t = 1;
                }
                if (type == -2)
                {
                    t = 2;
                }
                if (type == -3)
                {
                    t = 3;
                }
                BossInvasion _event = invasions.Where(b => b.Type == t).FirstOrDefault();
                if (_event == null || !_event.Active)
                {
                    _event = new BossInvasion(type);
                }

                invasions.Add(_event);
            }
            else
            {
                BossInvasion _boss = bosses.Where(b => b.Type == type).FirstOrDefault();
                if (_boss == null || !_boss.Active)
                {
                    _boss = new BossInvasion(type);
                }

                bosses.Add(_boss);
            }
        }
Esempio n. 5
0
        private void DoNpcStrike(BinaryReader reader, Player player)
        {
            Int16  npcID     = reader.ReadInt16();
            Int16  dmg       = reader.ReadInt16();
            float  knockback = reader.ReadSingle();
            byte   direction = reader.ReadByte();
            bool   critical  = reader.ReadBoolean();
            NPC    npc       = Main.npc[npcID];
            double calcDmg   = dmg;

            if (player != null)
            {
                player.TimesDealtDamage++;

                if (critical)
                {
                    player.CritsGiven++;
                }

                calcDmg             = Main.CalculateDamage(dmg, npc.ichor ? npc.defense - 20 : npc.defense);
                player.DamageGiven += (uint)calcDmg;
                if (calcDmg > player.MaxDamage)
                {
                    player.MaxDamage = (short)calcDmg;
                }

                if (npc.life - calcDmg <= 0)
                {
                    player.Kills++;
                }
            }

            if (npc.boss || bossIDs.Contains(npc.netID))
            {
                // Make sure to count children of boss for damage
                // Especially since some bosses like Golem and Destroyer are multiple parts
                int type = npc.netID;
                if (type == 5)                 // Eye of Cthulu
                {
                    type = 4;
                }
                if (type == 14 || type == 15)                 // Eater of Worlds
                {
                    type = 13;
                }
                if (type == 36)                 // Skeletron
                {
                    type = 35;
                }
                if (type >= 114 && type <= 119)                 // Wall of Flesh
                {
                    type = 113;
                }
                //if (type == 126) // The Twins // Separate entities, do not group together
                //    type = 125;
                if (type >= 128 && type <= 131)                 // Skeletron Prime
                {
                    type = 127;
                }
                if (type == 135 || type == 136 || type == 139)                 // The Destroyer
                {
                    type = 134;
                }
                if (type >= 246 && type <= 249)                 // Golem
                {
                    type = 245;
                }
                if (type >= 263 && type <= 265)                 // Plantera
                {
                    type = 262;
                }
                if (type == 267)                 // Brain of Cthulu
                {
                    type = 266;
                }

                BossInvasion boss = bosses.Where(b => b.Type == type && b.Active).FirstOrDefault();
                if (boss == null)
                {
                    // Disclude Probes, leeches, etc as they can be left over after a boss fight so look for presence of parent boss
                    // Override Destroyer head, it seems to stay "active" too long so look for tail instead
                    if (type == 134 && Main.npc.FirstOrDefault(n => n.type == 136) == null)
                    {
                        return;
                    }
                    if (Main.npc.FirstOrDefault(n => n.active && n.type == type) == null)
                    {
                        return;
                    }
                    //TSPlayer.All.SendInfoMessage(string.Format("New boss on hit! {0} {1}", type, npc.netID));
                    boss = new BossInvasion(type);
                    bosses.Add(boss);
                }

                // Update start time to first hit of encounter
                if (boss.Players.Count == 0)
                {
                    boss.EventStart = DateTime.Now;
                }

                boss.AddDamage(player, (int)calcDmg);
            }

            if (invasionIDs.Contains(npc.netID))
            {
                BossInvasion _event;
                if (Main.pumpkinMoon)
                {
                    _event = invasions.Where(b => b.Type == -4 && b.Active).FirstOrDefault();
                }
                else if (Main.snowMoon)
                {
                    _event = invasions.Where(b => b.Type == -5 && b.Active).FirstOrDefault();
                }
                else
                {
                    _event = invasions.Where(b => b.Type == Main.invasionType && b.Active).FirstOrDefault();
                }

                // It is possible to hit this if lingering event mobs are being attacked
                // after event has finished. Do not record.
                if (_event != null && _event.Active)
                {
                    // Update actual start with first hit
                    if (_event.Players.Count == 0)
                    {
                        _event.EventStart = DateTime.Now;
                    }

                    _event.AddDamage(player, (int)calcDmg);
                }
            }
        }
Esempio n. 6
0
		public string ReportProgress(BossInvasion e)
		{
			if (e.Type > 0 && e.Type < 4) // Typical Invasions
			{
				if (e.Players.Count == 0)
				{
					float num = (float)Main.dayRate;
					double distance = 0;
					if (Main.invasionX > (double)Main.spawnTileX)
					{
						distance = Main.invasionX - Main.spawnTileX;
					}
					else if (Main.invasionX < (double)Main.spawnTileX)
					{
						distance = Main.spawnTileX - Main.invasionX;
					}
					return string.Format("{0} moving into position: {1} ({2} ft)", e.Name, Utils.FormatTime(distance / Main.dayRate / 60), distance / 2);
				}
				int kills = e.InvasionStartSize - Main.invasionSize;
				return string.Format("{0} progress: {1}/{2} ({3:n0}%) Remaining: {4}", e.Name, kills, e.InvasionStartSize, kills * 100.0 / e.InvasionStartSize, Main.invasionSize);
			}
			else if (e.Type == -4) // Pumpkin Moon
			{
				if (NPC.waveCount <= pumpkinLevels.Length)
				{
					try
					{
						return string.Format("{0} Wave {1}/{2} - Points: {3}/{4} - Overall: {5:n0}% Remaining: {6}", e.Name, NPC.waveCount, pumpkinLevels.Length, NPC.waveKills, pumpkinLevels[NPC.waveCount - 1],
							((NPC.waveCount - 1) * 100 / pumpkinLevels.Length) + (NPC.waveKills / pumpkinLevels[NPC.waveCount - 1] * 100 / pumpkinLevels.Length), TimeTilMorning());
					}
					catch (Exception ex)
					{
						Log.Error(ex.Message);
						return ex.Message;
					}
				}
				else
				{
					return string.Format("{0} Final Wave - Points: {1} Remaining: {2}", e.Name, NPC.waveKills, TimeTilMorning());
				}
			}
			else if (e.Type == -5) // Frost Moon
			{
				if (NPC.waveCount <= frostLevels.Length)
				{
					return string.Format("{0} Wave {1}/{2} - Points: {3}/{4} - Overall: {5:n0}% Remaining: {6}", e.Name, NPC.waveCount, frostLevels.Length, NPC.waveKills, frostLevels[NPC.waveCount - 1],
						((NPC.waveCount - 1) * 100 / frostLevels.Length) + (NPC.waveKills / frostLevels[NPC.waveCount - 1] * 100 / frostLevels.Length), TimeTilMorning());
				}
				else
				{
					return string.Format("{0} Wave {1} - Points: {2} Remaining: {3}", e.Name, NPC.waveCount, NPC.waveKills, TimeTilMorning());
				}
			}
			else
				return string.Format("How the f**k did this get executed?! Type: {0}", e.Type);

			//return string.Empty;
		}
Esempio n. 7
0
		private void DoNpcStrike(BinaryReader reader, Player player)
		{
			Int16 npcID = reader.ReadInt16();
			Int16 dmg = reader.ReadInt16();
			float knockback = reader.ReadSingle();
			byte direction = reader.ReadByte();
			bool critical = reader.ReadBoolean();
			NPC npc = Main.npc[npcID];
			double calcDmg = dmg;

			if (player != null)
			{
				player.TimesDealtDamage++;

				if (critical)
					player.CritsGiven++;

				calcDmg = Main.CalculateDamage(dmg, npc.ichor ? npc.defense - 20 : npc.defense);
				player.DamageGiven += (uint)calcDmg;
				if (calcDmg > player.MaxDamage)
					player.MaxDamage = (short)calcDmg;

				if (npc.life - calcDmg <= 0)
					player.Kills++;
			}

			if (npc.boss || bossIDs.Contains(npc.netID))
			{
				// Make sure to count children of boss for damage
				// Especially since some bosses like Golem and Destroyer are multiple parts
				int type = npc.netID;
				if (type == 5) // Eye of Cthulu
					type = 4;
				if (type == 14 || type == 15) // Eater of Worlds
					type = 13;
				if (type == 36) // Skeletron
					type = 35;
				if (type >= 114 && type <= 119) // Wall of Flesh
					type = 113;
				//if (type == 126) // The Twins // Separate entities, do not group together
				//    type = 125;
				if (type >= 128 && type <= 131) // Skeletron Prime
					type = 127;
				if (type == 135 || type == 136 || type == 139) // The Destroyer
					type = 134;
				if (type >= 246 && type <= 249) // Golem
					type = 245;
				if (type >= 263 && type <= 265) // Plantera
					type = 262;
				if (type == 267) // Brain of Cthulu
					type = 266;

				BossInvasion boss = bosses.Where(b => b.Type == type && b.Active).FirstOrDefault();
				if (boss == null)
				{
					// Disclude Probes, leeches, etc as they can be left over after a boss fight so look for presence of parent boss
					// Override Destroyer head, it seems to stay "active" too long so look for tail instead
					if (type == 134 && Main.npc.FirstOrDefault(n => n.type == 136) == null)
						return;
					if (Main.npc.FirstOrDefault(n => n.active && n.type == type) == null)
						return;
					//TSPlayer.All.SendInfoMessage(string.Format("New boss on hit! {0} {1}", type, npc.netID));
					boss = new BossInvasion(type);
					bosses.Add(boss);
				}

				// Update start time to first hit of encounter
				if (boss.Players.Count == 0)
					boss.EventStart = DateTime.Now;

				boss.AddDamage(player, (int)calcDmg);
			}

			if (invasionIDs.Contains(npc.netID))
			{
				BossInvasion _event;
				if (Main.pumpkinMoon)
				{
					_event = invasions.Where(b => b.Type == -4 && b.Active).FirstOrDefault();
				}
				else if (Main.snowMoon)
				{
					_event = invasions.Where(b => b.Type == -5 && b.Active).FirstOrDefault();
				}
				else
				{
					_event = invasions.Where(b => b.Type == Main.invasionType && b.Active).FirstOrDefault();
				}

				// It is possible to hit this if lingering event mobs are being attacked
				// after event has finished. Do not record.
				if (_event != null && _event.Active)
				{
					// Update actual start with first hit
					if (_event.Players.Count == 0)
					{
						_event.EventStart = DateTime.Now;
					}

					_event.AddDamage(player, (int)calcDmg);
				}
			}
		}
Esempio n. 8
0
		private void DoSpawnBoss(BinaryReader reader)
		{
			int playerInt = reader.ReadInt32();
			int type = reader.ReadInt32();

			int t = type;
			if (type < 0)
			{
				if (type == -1)
					t = 1;
				if (type == -2)
					t = 2;
				if (type == -3)
					t = 3;
				BossInvasion _event = invasions.Where(b => b.Type == t).FirstOrDefault();
				if (_event == null || !_event.Active)
					_event = new BossInvasion(type);

				invasions.Add(_event);
			}
			else
			{
				BossInvasion _boss = bosses.Where(b => b.Type == type).FirstOrDefault();
				if (_boss == null || !_boss.Active)
					_boss = new BossInvasion(type);

				bosses.Add(_boss);
			}
		}