* Several bugfixes: -Desert Prowler and Wulfrum set bonuses now work correctly with the vanilla "Activate Set Bonuses" setting, that allows you to choose whether to activate them by doubletapping up or down. Related bug report: https://discord.com/channels/225030931008847874/1158173634280558744 -Fixed Cryogen's shield counting towards NPC limit and despawning offscreen. Related bug report: https://discord.com/channels/225030931008847874/1166534631458345080 -Fixed Calamity spear projectiles lingering into chained switched item uses. Related bug report: https://discord.com/channels/225030931008847874/1165360766539538432 -Made sure every On_ and IL_ hook is unloaded manually, since testing has verified TML's auto-unloading does not work consistently and properly. --------- Co-authored-by: Jack <jv222rh@student.lnu.se>
80 lines
2.5 KiB
C#
80 lines
2.5 KiB
C#
using Terraria;
|
|
using Terraria.ModLoader;
|
|
using Terraria.ID;
|
|
using Terraria.DataStructures;
|
|
using CalamityMod.Items.Accessories;
|
|
using CalamityMod.Items.Armor.Wulfrum;
|
|
using Terraria.Audio;
|
|
using CalamityMod.Cooldowns;
|
|
using static CalamityMod.CalamityUtils;
|
|
|
|
namespace CalamityMod.Items.Materials
|
|
{
|
|
[LegacyName("WulfrumShard")]
|
|
public class WulfrumMetalScrap : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Materials";
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Item.ResearchUnlockCount = 25;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 13;
|
|
Item.height = 10;
|
|
Item.maxStack = 9999;
|
|
Item.value = Item.sellPrice(copper: 80);
|
|
Item.rare = ItemRarityID.Blue;
|
|
Item.ammo = Item.type;
|
|
}
|
|
|
|
public override void ModifyResearchSorting(ref ContentSamples.CreativeHelper.ItemGroup itemGroup)
|
|
{
|
|
itemGroup = ContentSamples.CreativeHelper.ItemGroup.Material;
|
|
}
|
|
|
|
public override void OnSpawn(IEntitySource source)
|
|
{
|
|
if (source is EntitySource_Loot)
|
|
{
|
|
if (Main.rand.NextBool())
|
|
return;
|
|
|
|
bool closePlayer = false;
|
|
|
|
for (int i = 0; i < Main.maxPlayers; i++)
|
|
{
|
|
if ((Main.player[i].Center - Item.Center).Length() < 1200 && Main.player[i].GetModPlayer<WulfrumBatteryPlayer>().battery)
|
|
{
|
|
closePlayer = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (closePlayer)
|
|
{
|
|
Item.stack++;
|
|
SoundEngine.PlaySound(WulfrumBattery.ExtraDropSound, Item.Center);
|
|
|
|
int numDust = Main.rand.Next(3, 7);
|
|
for (int i = 0; i < numDust; i++)
|
|
{
|
|
Dust.NewDustDirect(Item.position, Item.width, Item.height, Main.rand.NextBool() ? 246 : 247, 0, -3f, Scale: Main.rand.NextFloat(0.9f, 1f));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Load() => Terraria.On_Item.CanFillEmptyAmmoSlot += AvoidDefaultingToAmmoSlot;
|
|
|
|
private bool AvoidDefaultingToAmmoSlot(Terraria.On_Item.orig_CanFillEmptyAmmoSlot orig, Item self)
|
|
{
|
|
if (self.type == Type)
|
|
return false;
|
|
return orig(self);
|
|
}
|
|
}
|
|
}
|