private void OnNpcKill(NpcKilledEventArgs eventArgs) { //Check if it's a boss or betsy, if its normal mode, and if it is not the lunatic cultist (it is not supposed to drop a treasure bag in any circumstances, unobtainable) if ((eventArgs.npc.boss || eventArgs.npc.netID == Terraria.ID.NPCID.DD2Betsy) && Terraria.Main.GameMode == 0 && eventArgs.npc.netID != Terraria.ID.NPCID.CultistBoss) { switch (eventArgs.npc.netID) //Check for the npc type. Eol & queen slime have weird drop mechanics so I'm replacing it { case Terraria.ID.NPCID.HallowBoss: //eol 636 if (eventArgs.npc.AI_120_HallowBoss_IsGenuinelyEnraged()) // Checks if it's the daytime eol and drop terraprisma if so { Terraria.Item.NewItem((int)eventArgs.npc.position.X, (int)eventArgs.npc.position.Y, (int)eventArgs.npc.Size.X, (int)eventArgs.npc.Size.Y, Terraria.ID.ItemID.EmpressBlade, 1); //5005 TerraPrisma } //DropItemInstanced() will tell each client there's an item but will not be an active item slot on the server so it will not be overwritten thus each client can collect the item eventArgs.npc.DropItemInstanced(eventArgs.npc.position, eventArgs.npc.Size, Terraria.ID.ItemID.FairyQueenBossBag); //4782 eol boss bag return; case Terraria.ID.NPCID.QueenSlimeBoss: //queen slime 657 eventArgs.npc.DropItemInstanced(eventArgs.npc.position, eventArgs.npc.Size, Terraria.ID.ItemID.QueenSlimeBossBag); //4957 queen slime boss bag return; default: eventArgs.npc.DropBossBags(); // Drops a treasure bag depending on npc type (most bosses) return; } } }
private void OnNpcKilled(NpcKilledEventArgs args) { var npc = args.npc; //Debug.Print($"DebugId: {debugId}"); Debug.Print($"NpcKilled name: {npc.GivenOrTypeName}"); Debug.Print($"NpcKilled id: {npc.whoAmI}"); Debug.Print($"NpcKilled TypeName: {npc.TypeName}"); Debug.Print($"NpcKilled type: {npc.type}"); //Debug.Print($"Contains name? {npcTypes.Contains(npc.GivenOrTypeName)}"); if (!AnyNcpType && !npcTypes.Contains(npc.GivenOrTypeName)) { return; } //if (LastStrucks.TryGetValue(npc.whoAmI, out var lastStruck) && _party.Any(p => p.Index == lastStruck) && // (_npcName?.Equals(npc.GivenOrTypeName, StringComparison.OrdinalIgnoreCase) ?? true)) int lastStruck = 0; if (LastStrucks.TryGetValue(npc.whoAmI, out lastStruck) && partyMembers.Any(m => m.Player.Index == lastStruck)) { Debug.Print("Kill counted!"); LastStrucks.Remove(npc.whoAmI); --_amount; } return; }
private void OnNPCKilled(NpcKilledEventArgs args) { if (args.npc.boss) { Data.Config config = Data.Config.GetConfig(); config.NPC.Level += config.NPC.LevelUP; config.Save(); TShock.Utils.Broadcast($"击杀boss,全体NPC等级升级:{config.NPC.LevelUP}级,当前" + $"NPC等级为:{config.NPC.Level},玩家受伤加成{config.NPC.Level}倍", Color.Red); } }
private void OnNpcKilled(NpcKilledEventArgs args) { if (CurrentInvasion == null) { return; } var npc = args.npc; var customNpc = NpcManager.Instance?.GetCustomNpc(npc); var npcNameOrType = customNpc?.Definition.Name ?? npc.netID.ToString(); if (npcNameOrType.Equals(_currentMiniboss, StringComparison.OrdinalIgnoreCase)) { try { CurrentInvasion.OnBossDefeated?.Invoke(); } catch (Exception ex) { Utils.LogScriptRuntimeError(ex); CurrentInvasion.OnBossDefeated = null; _currentMiniboss = null; } currentMinibossKilled = true; } else if (CurrentInvasion.NpcPointValues.TryGetValue(npcNameOrType, out var points)) { _currentPoints += points; _currentPoints = Math.Min(_currentPoints, _requiredPoints); NotifyRelevantPlayers(); if (_currentWaveIndex >= 0 && _currentWaveIndex < CurrentInvasion.Waves.Count) { var wave = CurrentInvasion.Waves[_currentWaveIndex]; if (wave != null) { try { CurrentInvasion.OnWaveUpdate?.Invoke(_currentWaveIndex, wave, _currentPoints); } catch (Exception ex) { Utils.LogScriptRuntimeError(ex); CurrentInvasion.OnWaveUpdate = null; } } } } }
private void OnNpcKilled(NpcKilledEventArgs e) { if (!enabled) { return; } Player closest = Main.player[e.npc.FindClosestPlayer()]; var info = data.GetBlock(teams[closest.team]); int val = info.IncreaseValue(e.npc.type.ToString(), 1); if (val % 50 == 0 && val != 0) { TShock.Players[closest.whoAmI].GiveItem(e.npc.BannerID(), "", closest.width, closest.height, 1); MessageAll(string.Concat(teams[closest.team], " has defeated ", val, " ", e.npc.FullName, "!")); } }
private void OnNpcKilled(NpcKilledEventArgs args) { //Debug.Print($"NpcKilled! #{args.npc.whoAmI} - {args.npc.GivenOrTypeName}"); //Debug.Print($"Value: {args.npc.value}"); if (!NpcSpawnHP.TryGetValue(args.npc.whoAmI, out var spawnHp)) { throw new Exception("Unable to retrieve NpcSpawnHP!"); } //Debug.Print($"NpcHP: {spawnHp}"); //NpcStrikeTracker.OnNpcKilled(args.npc); Task.Run(() => { //Debug.Print("Task.Run() => OnNpcKilled!"); NpcStrikeTracker.OnNpcKilled(args.npc, spawnHp); }); }
private void OnNpcKilled(NpcKilledEventArgs args) { var npc = args.npc; //Debug.Print($"DebugId: {debugId}"); Debug.Print($"NpcKilled name: {npc.GivenOrTypeName}"); Debug.Print($"NpcKilled id: {npc.whoAmI}"); Debug.Print($"NpcKilled TypeName: {npc.TypeName}"); Debug.Print($"NpcKilled type: {npc.type}"); //Debug.Print($"Contains name? {npcTypes.Contains(npc.GivenOrTypeName)}"); if (!AnyNcpType && !npcTypes.Contains(MiscFunctions.StripTags(npc.GivenOrTypeName))) { return; } //if (LastStrucks.TryGetValue(npc.whoAmI, out var lastStruck) && _party.Any(p => p.Index == lastStruck) && // (_npcName?.Equals(npc.GivenOrTypeName, StringComparison.OrdinalIgnoreCase) ?? true)) int lastStruck = 0; if (LastStrucks.TryGetValue(npc.whoAmI, out lastStruck) && partyMembers.Any(m => m.Player.Index == lastStruck)) { //Debug.Print("Kill counted!"); if (HasTallyChangedAction) { var member = partyMembers.FirstOrDefault(pm => pm.Player.Index == lastStruck); if (member != null) { TryEnqueueTallyChange(member, 1); } } LastStrucks.Remove(npc.whoAmI); --_amount; } return; }
private void OnNpcKilled(NpcKilledEventArgs args) { var npc = args.npc; var customNpc = GetCustomNpc(npc); if (customNpc == null) { return; } var definition = customNpc.Definition; foreach (var lootEntry in definition.LootEntries) { if (_random.NextDouble() >= lootEntry.Chance) { continue; } var stackSize = _random.Next(lootEntry.MinStackSize, lootEntry.MaxStackSize); var items = TShock.Utils.GetItemByIdOrName(lootEntry.Name); if (items.Count == 1) { Item.NewItem(npc.position, npc.Size, items[0].type, stackSize, false, lootEntry.Prefix); } } try { CustomIDFunctions.CurrentID = definition.Name; definition.OnKilled?.Invoke(customNpc); } catch (Exception ex) { Utils.LogScriptRuntimeError(ex); definition.OnKilled = null; } customNpc.IsNpcValid = false; }
private void NpcKilled(NpcKilledEventArgs args) { if (!Main.expertMode || Main.GameMode == 2) { return; } int relic = 0; int extra = 0; switch (args.npc.type) { case NPCID.KingSlime: relic = 4929; extra = 4797; break; case NPCID.EyeofCthulhu: relic = 4924; extra = 4798; break; case NPCID.EaterofWorldsTail: if (args.npc.boss) { relic = 4925; extra = 4799; } break; case NPCID.BrainofCthulhu: relic = 4926; extra = 4800; break; case NPCID.QueenBee: relic = 4928; extra = 4802; break; case NPCID.SkeletronHead: relic = 4927; extra = 4801; break; case NPCID.WallofFlesh: relic = 4930; extra = 4795; break; case NPCID.QueenSlimeBoss: relic = 4950; extra = 4960; break; case NPCID.TheDestroyer: //Destroyer is the tricky one relic = 4932; extra = 4803; float num1 = 1E+08f; Vector2 center = Main.player[args.npc.target].Center; Vector2 position = args.npc.position; for (int index = 0; index < 200; ++index) { if (Main.npc[index].active && (Main.npc[index].type == 134 || Main.npc[index].type == 135 || Main.npc[index].type == 136)) { float num2 = Math.Abs(Main.npc[index].Center.X - center.X) + Math.Abs(Main.npc[index].Center.Y - center.Y); if (num2 < num1) { num1 = num2; position = Main.npc[index].position; } } } if (PluginRandom.Next(0, 3) == 0) { Item.NewItem(position, args.npc.Size, relic, 1); } if (PluginRandom.Next(0, 6) == 0) { Item.NewItem(position, args.npc.Size / 3, extra, 1); } return; case NPCID.Spazmatism: case NPCID.Retinazer: if (args.npc.boss) { relic = 4931; extra = 4804; } break; case NPCID.SkeletronPrime: relic = 4933; extra = 4805; break; case NPCID.Plantera: relic = 4934; extra = 4806; break; case NPCID.HallowBoss: relic = 4949; extra = 4811; break; case NPCID.Golem: relic = 4935; extra = 4807; break; case NPCID.DukeFishron: relic = 4936; extra = 4808; break; case NPCID.CultistBoss: relic = 4937; extra = 4809; break; case NPCID.MoonLordCore: relic = 4938; extra = 4810; break; case NPCID.DD2DarkMageT1: case NPCID.DD2DarkMageT3: relic = 4946; extra = 4796; break; case NPCID.DD2OgreT2: case NPCID.DD2OgreT3: relic = 4947; extra = 4816; break; case NPCID.DD2Betsy: relic = 4948; extra = 4817; break; case NPCID.MartianSaucerCore: relic = 4939; extra = 4815; break; case NPCID.MourningWood: relic = 4941; extra = 4793; break; case NPCID.Pumpking: relic = 4942; extra = 4812; break; case NPCID.Everscream: relic = 4944; extra = 4813; break; case NPCID.IceQueen: relic = 4943; extra = 4814; break; case NPCID.SantaNK1: relic = 4945; extra = 4794; break; case NPCID.PirateShip: relic = 4940; extra = 4792; break; } if (PluginRandom.Next(1, 6) == 1) { Item.NewItem(args.npc.position + args.npc.Size / 2, args.npc.Size / 3, relic, 1); } if (PluginRandom.Next(1, 10) == 1) { Item.NewItem(args.npc.position + args.npc.Size / 2, args.npc.Size / 3, extra, 1); } }
private void OnNpcKilled(NpcKilledEventArgs args) { if (args.npc.type != NPCID.MoonLordCore) { return; } if (--Count > 0) { TShock.Utils.Broadcast($"离重置地图还需要击败{Count}次月球领主", 0, 255, 255); return; } //Kick all players status = Status.Cleaning; Main.WorldFileMetadata = null; foreach (var player in TShock.Players) { if (player != null) //player.Kick("服务器正在重置,请稍后进入", true); { //TShock.Utils.Kick(player, "服务器正在重置,请稍后进入", true); player.Disconnect("服务器正在重置,请稍后进入,重置进度:"); } } //Reset World Map Main.gameMenu = true; //Main.serverGenLock = true; Main.autoGen = true; generationProgress = new GenerationProgress(); WorldGen.CreateNewWorld(generationProgress); status = Status.Generating; while (Main.autoGen) //Main.serverGenLock) { TShock.Log.ConsoleInfo(GetProgress()); Thread.Sleep(100); } //Reload world map status = Status.Cleaning; Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks); WorldFile.LoadWorld(false); Main.dayTime = WorldFile._tempDayTime; Main.time = WorldFile._tempTime; Main.raining = WorldFile._tempRaining; Main.rainTime = WorldFile._tempRainTime; Main.maxRaining = WorldFile._tempMaxRain; Main.cloudAlpha = WorldFile._tempMaxRain; Main.moonPhase = WorldFile._tempMoonPhase; Main.bloodMoon = WorldFile._tempBloodMoon; Main.eclipse = WorldFile._tempEclipse; //Reset player data TShock.DB.Query("DELETE FROM tsCharacter", Array.Empty <object>()); //Reset status to playing Main.gameMenu = false; generationProgress = null; status = Status.Available; }