tMx/NPCs/CustomLoot/MoltenTabletOnKill.cs
2025-02-11 16:04:10 -05:00

38 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria;
using Terraria.ModLoader.IO;
using static Terraria.GameContent.Bestiary.IL_BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions;
using Microsoft.Xna.Framework;
namespace tMx.NPCs.CustomLoot
{
public class MoltenTabletOnKill : GlobalNPC
{
public override void OnKill(NPC npc)
{
if (Main.rand.NextBool(3)) // ~33%
{
if (npc.type == NPCID.Hellbat
|| npc.type == NPCID.Lavabat
|| npc.type == NPCID.LavaSlime
|| npc.type == NPCID.FireImp)
{
int dropItemType = ModContent.ItemType<Content.Items.Materials.MoltenTablet>();
int newItem = Item.NewItem(npc.GetSource_FromThis(), npc.Hitbox, dropItemType);
if (Main.netMode == NetmodeID.MultiplayerClient && newItem >= 0)
{
NetMessage.SendData(MessageID.SyncItem, -1, -1, null, newItem, 1f);
}
}
}
}
}
}