Files
CalamityModPublic/Items/SummonItems/DeathWhistle.cs
T
2023-08-10 21:12:50 +07:00

66 lines
2.2 KiB
C#

using CalamityMod.Events;
using CalamityMod.NPCs.Ravager;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.Audio;
using Terraria.DataStructures;
namespace CalamityMod.Items.SummonItems
{
[LegacyName("AncientMedallion")]
public class DeathWhistle : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.SummonItems";
public override void SetStaticDefaults()
{
ItemID.Sets.SortingPriorityBossSpawns[Type] = 17; // Solar Tablet (1 above Lihzahrd Power Cell)
}
public override void SetDefaults()
{
Item.width = 20;
Item.height = 20;
Item.rare = ItemRarityID.Yellow;
Item.useAnimation = 10;
Item.useTime = 10;
Item.useStyle = ItemUseStyleID.HoldUp;
Item.consumable = false;
}
public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
{
itemGroup = ContentSamples.CreativeHelper.ItemGroup.BossItem;
}
public override bool CanUseItem(Player player)
{
return !NPC.AnyNPCs(ModContent.NPCType<RavagerBody>()) && player.ZoneOverworldHeight && !BossRushEvent.BossRushActive;
}
public override bool? UseItem(Player player)
{
SoundEngine.PlaySound(SoundID.ScaryScream, player.Center);
if (Main.netMode != NetmodeID.MultiplayerClient)
{
int npc = NPC.NewNPC(new EntitySource_BossSpawn(player), (int)(player.position.X + Main.rand.Next(-250, 251)), (int)(player.position.Y - 500f), ModContent.NPCType<RavagerBody>(), 1);
Main.npc[npc].timeLeft *= 20;
CalamityUtils.BossAwakenMessage(npc);
}
else
NetMessage.SendData(MessageID.SpawnBossUseLicenseStartEvent, -1, -1, null, player.whoAmI, ModContent.NPCType<RavagerBody>());
return true;
}
public override void AddRecipes()
{
CreateRecipe().
AddIngredient(ItemID.LunarTabletFragment, 15).
AddIngredient(ItemID.LihzahrdBrick, 25).
AddTile(TileID.MythrilAnvil).
Register();
}
}
}