Need some help w/ making a sword

T3rrarian

Terrarian
Made a sword with the code of the example energy (excalibur clone) sword and changed it to work in my mod. But I keep getting one error.

"thingamajing\Content\Items\weapons\HerosBlade.cs(6,28): error code CS0234: The type or namespace name 'Projectiles' does not exist in the namespace 'thingamajing.Content' (are you missing an assembly reference?)"

I tried to remove that line of code that's causing the problem before, and it does remove the error im talking about but generates another. Does anyone know how to do this because im just confused of how it worked in the example energy sword code but not in mine.
 
Last edited:
Is thingamajing.Content.Projectiles the actual namespace of the projectile you are trying to use?
 
I believe so, the projectile is located in the Projectiles folder.
 
The folder location and the namespace are 2 completely different things
 
oh, well how do I make it detect the projectile then?
 
Hm... can you send the code? I have an idea of what it could be.
 
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
using thingamajing.Content.Projectiles;

namespace thingamajing.Content.Items.weapons
{
// This is a copy of the Excalibur
public class HerosBlade : ModItem
{
public override void SetDefaults()
{
Item.useStyle = ItemUseStyleID.Swing;
Item.useAnimation = 20;
Item.useTime = 20;
Item.damage = 72;
Item.knockBack = 4.5f;
Item.width = 40;
Item.height = 40;
Item.scale = 1f;
Item.UseSound = SoundID.Item1;
Item.rare = ItemRarityID.Pink;
Item.value = Item.buyPrice(gold: 23); // Sell price is 5 times less than the buy price.
Item.DamageType = DamageClass.Melee;
Item.shoot = ModContent.ProjectileType<HeroProjectile>();
Item.noMelee = true; // This is set the sword itself doesn't deal damage (only the projectile does).
Item.shootsEveryUse = true; // This makes sure Player.ItemAnimationJustStarted is set when swinging.
Item.autoReuse = true;
}

public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
float adjustedItemScale = player.GetAdjustedItemScale(Item); // Get the melee scale of the player and item.
Projectile.NewProjectile(source, player.MountedCenter, new Vector2(player.direction, 0f), type, damage, knockback, player.whoAmI, player.direction * player.gravDir, player.itemAnimationMax, adjustedItemScale);
NetMessage.SendData(MessageID.PlayerControls, -1, -1, null, player.whoAmI); // Sync the changes in multiplayer.

return base.Shoot(player, source, position, velocity, type, damage, knockback);
}

// Please see Content/ExampleRecipes.cs for a detailed explanation of recipe creation.
public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.BrokenHeroSword, 1);
recipe.AddIngredient(ItemID.SoulofMight, 10);
recipe.AddIngredient(ItemID.SoulofFright, 10);
recipe.AddIngredient(ItemID.SoulofSight, 10);
recipe.AddIngredient(ItemID.ChlorophyteBar, 10);
recipe.AddTile(26);
recipe.Register();
}
}
}

the code is taken from the ExampleEnergySword from the tmodloader example mod.
 
Can you share the code for the projectile?
 
wait a minute... nevermind. now it works for some reason when I added a line of code back although before even with that line of code, it still didnt work.
 
Coding is like that sometimes lol
 
Back
Top Bottom