Terra B Welch
Empress of Light
So I am trying to get a "Throwing style melee weapon" to work...
What I want the weapon to do is throw a random amount of projectiles in a similar way to vampire knives.
Here's the projectile CS
And this is the item CS itself
Yet whatever I do, I can't get it to fire the projectiles, it does its animations but never shoots.
I'm sure theres an error in there that my newbie brain can't see, so if an expert can tell me where I screwed up I'd be mighty thankful.
EDIT: Turns out having penetration set to 0 on the projectile was the culprit in this issue, it's been resolved!
What I want the weapon to do is throw a random amount of projectiles in a similar way to vampire knives.
Here's the projectile CS
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TerraCompilation.Projectiles
{
public class CopperSS : ModProjectile
{
public override void SetDefaults()
{
projectile.name = "Thrown Copper Shortsword";
projectile.width = 10;
projectile.height = 44;
projectile.timeLeft = 120;
projectile.penetrate = 0;
projectile.friendly = true;
projectile.hostile = false;
projectile.tileCollide = true;
projectile.ignoreWater = true;
projectile.ranged = true;
projectile.aiStyle = 0;
}
}
}
And this is the item CS itself
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using TerraCompilation.Items;
namespace TerraCompilation.Items.Weapons
{
public class Copperhand : ModItem
{
public override bool Autoload(ref string name, ref string texture, IList<EquipType> equips)
{
texture = "TerraCompilation/Items/Weapons/Copperhand";
return true;
}
public override void SetDefaults()
{
item.name = "Copperhand";
item.damage = 85;
item.melee = true;
item.noUseGraphic = true;
item.width = 2;
item.height = 2;
item.toolTip = "Throw copper shortswords at your foes!";
item.toolTip2 = "It's about time the copper shortsword got its revenge!";
item.useTime = 10;
item.useAnimation = 10;
item.useStyle = 1;
item.noMelee = true;
item.knockBack = 2;
item.value = 263000;
item.rare = 4;
item.UseSound = SoundID.Item1;
item.autoReuse = true;
item.shoot = mod.ProjectileType("CopperSS");
item.shootSpeed = 10f;
item.expert = true;
}
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
int numberProjectiles = 2 + Main.rand.Next(8);
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(10));
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.LunarBar, 30);
recipe.AddIngredient(null, "Unknownparts", 1);
recipe.AddTile(TileID.LunarCraftingStation);
recipe.SetResult(this);
recipe.AddRecipe();
}
}
}
Yet whatever I do, I can't get it to fire the projectiles, it does its animations but never shoots.
I'm sure theres an error in there that my newbie brain can't see, so if an expert can tell me where I screwed up I'd be mighty thankful.
EDIT: Turns out having penetration set to 0 on the projectile was the culprit in this issue, it's been resolved!
Last edited: