70 lines
2.6 KiB
C#
70 lines
2.6 KiB
C#
using Terraria.DataStructures;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Projectiles.Typeless;
|
|
using CalamityMod.Tiles.Furniture.CraftingStations;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Ranged
|
|
{
|
|
public class Goobow : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Ranged";
|
|
public override void SetDefaults()
|
|
{
|
|
Item.damage = 33;
|
|
Item.DamageType = DamageClass.Ranged;
|
|
Item.width = 30;
|
|
Item.height = 50;
|
|
Item.useTime = 31;
|
|
Item.useAnimation = 31;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 3f;
|
|
Item.value = CalamityGlobalItem.Rarity4BuyPrice;
|
|
Item.rare = ItemRarityID.LightRed;
|
|
Item.UseSound = SoundID.Item5;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ProjectileID.WoodenArrowFriendly;
|
|
Item.shootSpeed = 12f;
|
|
Item.useAmmo = AmmoID.Arrow;
|
|
Item.Calamity().canFirePointBlankShots = true;
|
|
}
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo spawnSource, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
Vector2 source = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float piOver10 = 0.1f * MathHelper.Pi;
|
|
int projAmt = 2;
|
|
|
|
velocity.Normalize();
|
|
velocity *= 20f;
|
|
bool canHit = Collision.CanHit(source, 0, 0, source + velocity, 0, 0);
|
|
for (int i = 0; i < projAmt; i++)
|
|
{
|
|
float offsetAmt = i - (projAmt - 1f) / 2f;
|
|
Vector2 offset = velocity.RotatedBy((double)(piOver10 * offsetAmt), default);
|
|
if (!canHit)
|
|
{
|
|
offset -= velocity;
|
|
}
|
|
int index = Projectile.NewProjectile(spawnSource, source + offset, velocity * 0.6f, ModContent.ProjectileType<SlimeStream>(), damage / 4, 0f, player.whoAmI, i);
|
|
if (index.WithinBounds(Main.maxProjectiles))
|
|
Main.projectile[index].DamageType = DamageClass.Ranged;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient<PurifiedGel>(18).
|
|
AddIngredient<BlightedGel>(18).
|
|
AddTile<StaticRefiner>().
|
|
Register();
|
|
}
|
|
}
|
|
}
|