69 lines
2.8 KiB
C#
69 lines
2.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
using ForgottenWawiTech.Content.Rarities;
|
|
|
|
namespace ForgottenWawiTech.Content.Items
|
|
{
|
|
public class BoulderCannon: ModItem
|
|
{
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 1;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.width = 40;
|
|
Item.height = 40;
|
|
Item.useTime = 100;
|
|
Item.useAnimation = 100;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.knockBack = 6;
|
|
Item.value = Item.buyPrice(gold: 20);
|
|
Item.rare = ModContent.RarityType<FWTDeveloperItem>();
|
|
Item.UseSound = SoundID.Dig;
|
|
Item.autoReuse = true;
|
|
Item.noMelee = true;
|
|
Item.shoot = ProjectileID.PurificationPowder;
|
|
Item.shootSpeed = 50f;
|
|
Item.useAmmo = AmmoID.None;
|
|
}
|
|
|
|
// On shoot, fire Projectile ID 502 (the rainbow projectile) instead of the default ammo projectile
|
|
public override bool Shoot(Player player, Terraria.DataStructures.EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockBack)
|
|
{
|
|
// Kill the first player with a name containing "Neptune" or "Otter" (case insensitive) in multiplayer
|
|
if (Main.netMode == NetmodeID.MultiplayerClient)
|
|
{
|
|
for (int i = 0; i < Main.maxPlayers; i++)
|
|
{
|
|
Player targetPlayer = Main.player[i];
|
|
if (targetPlayer.active && (targetPlayer.name.ToLower().Contains("neptune") || targetPlayer.name.ToLower().Contains("otter")))
|
|
{
|
|
targetPlayer.KillMe(Terraria.DataStructures.PlayerDeathReason.ByCustomReason($"{targetPlayer.name} was vaporized!"), 99999, 0);
|
|
NetMessage.SendData(MessageID.PlayerDeath, -1, -1, null, i);
|
|
break; // Only kill one player per shot
|
|
}
|
|
}
|
|
}
|
|
|
|
// If no such player was found, suicide.
|
|
player.KillMe(Terraria.DataStructures.PlayerDeathReason.ByCustomReason($"{player.name} was consumed by power!"), 99999, 0);
|
|
return false; // return false to prevent tModLoader from shooting the default projectile
|
|
}
|
|
|
|
public override Vector2? HoldoutOffset() {
|
|
return new Vector2(2f, -2f);
|
|
}
|
|
|
|
public override void ModifyShootStats(Player player, ref Vector2 position, ref Vector2 velocity, ref int type, ref int damage, ref float knockback) {
|
|
Vector2 muzzleOffset = Vector2.Normalize(velocity) * 25f;
|
|
|
|
if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0)) {
|
|
position += muzzleOffset;
|
|
}
|
|
}
|
|
}
|
|
}
|