Files
CalamityModPublic/Items/Weapons/Ranged/Meowthrower.cs
T

69 lines
2.4 KiB
C#

using Terraria.DataStructures;
using CalamityMod.Projectiles.Ranged;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Ranged
{
public class Meowthrower : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Ranged";
public override void SetDefaults()
{
Item.damage = 48;
Item.DamageType = DamageClass.Ranged;
Item.width = 74;
Item.height = 24;
Item.useTime = 5;
Item.useAnimation = 5;
Item.useStyle = ItemUseStyleID.Shoot;
Item.noMelee = true;
Item.knockBack = 1.25f;
Item.UseSound = SoundID.Item34;
Item.value = CalamityGlobalItem.Rarity4BuyPrice;
Item.rare = ItemRarityID.LightRed;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<MeowFire>();
Item.shootSpeed = 5.5f;
Item.useAmmo = AmmoID.Gel;
}
public override Vector2? HoldoutOffset()
{
return new Vector2(-10, 0);
}
public override bool CanConsumeAmmo(Item ammo, Player player)
{
if (Main.rand.Next(0, 100) < 85)
return false;
return true;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
int num6 = Main.rand.Next(1, 3);
for (int index = 0; index < num6; ++index)
{
float SpeedX = velocity.X + (float)Main.rand.Next(-15, 16) * 0.05f;
float SpeedY = velocity.Y + (float)Main.rand.Next(-15, 16) * 0.05f;
switch (Main.rand.Next(3))
{
case 1:
type = ModContent.ProjectileType<MeowFire>();
break;
case 2:
type = ModContent.ProjectileType<MeowFire2>();
break;
default:
break;
}
Projectile.NewProjectile(source, position.X, position.Y, SpeedX, SpeedY, type, damage, knockback, player.whoAmI, 0.0f, 0.0f);
}
return false;
}
}
}