Custom shotgun issue

CowomiX

Terrarian
I'm trying to make a custom shotgun using the code from the Example Mod with some modifications, and on line 47 character 30 where it says 'Shoot' before everything in parenthesis I'm getting an error, anyone know a fix?

The code I'm using:
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.GameContent.Creative;
using Terraria.ID;
using Terraria.ModLoader;


namespace ComiXsExtras.Items.Weapons
{
public class Soup : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Super Shotgun");
Tooltip.SetDefault("'good soup'");

CreativeItemSacrificesCatalog.Instance.SacrificeCountNeededByItemId[Type] = 1;
}

public override void SetDefaults()
{
// Common Properties
Item.width = 48; // Hitbox width of the item.
Item.height = 12; // Hitbox height of the item.
Item.rare = 6; // The color that the item's name will be in-game.

// Use Properties
Item.useTime = 55; // The item's use time in ticks (60 ticks == 1 second.)
Item.useAnimation = 55; // The length of the item's use animation in ticks (60 ticks == 1 second.)
Item.useStyle = ItemUseStyleID.Shoot; // How you use the item (swinging, holding out, etc.)
Item.autoReuse = true; // Whether or not you can hold click to automatically use it again.
Item.UseSound = SoundID.Item36; // The sound that this item plays when used.

// Weapon Properties
Item.DamageType = DamageClass.Ranged; // Sets the damage type to ranged.
Item.damage = 32; // Sets the item's damage. Note that projectiles shot by this weapon will use its and the used ammunition's damage added together.
Item.knockBack = 6f; // Sets the item's knockback. Note that projectiles shot by this weapon will use its and the used ammunition's knockback added together.
Item.noMelee = true; // So the item's animation doesn't do damage.

// Gun Properties
Item.shoot = ProjectileID.PurificationPowder; // For some reason, all the guns in the vanilla source have this.
Item.shootSpeed = 10f; // The speed of the projectile (measured in pixels per frame.)
Item.useAmmo = AmmoID.Bullet; // The "ammo Id" of the ammo item that this weapon uses. Ammo IDs are magic numbers that usually correspond to the item id of one item that most commonly represent the ammo type.
}

public override bool Shoot(Player player, ProjectileSource_Item_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
const int NumProjectiles = 20; // The humber of projectiles that this gun will shoot.

for (int i = 0; i < NumProjectiles; i++)
{
// Rotate the velocity randomly by 30 degrees at max.
Vector2 newVelocity = velocity.RotatedByRandom(MathHelper.ToRadians(18.5f));

// Decrease velocity randomly for nicer visuals.
newVelocity *= 1f - Main.rand.NextFloat(0.3f);

// Create a projectile.
Projectile.NewProjectileDirect((IEntitySource)source, position, newVelocity, type, damage, knockback, player.whoAmI);
}

return false; // Return false because we don't want tModLoader to shoot projectile
}

// Please see Content/ExampleRecipes.cs for a detailed explanation of recipe creation.

// This method lets you adjust position of the gun in the player's hands. Play with these values until it looks good with your graphics.
public override Vector2? HoldoutOffset()
{
return new Vector2(-2f, -2f);
}
}

public class ProjectileSource_Item_WithAmmo
{
}

internal class ExampleItem
{
}
}
 
What error are you getting? I might not be able to help but if you don't show the error then there's a much smaller chance of getting help
 
What error are you getting? I might not be able to help but if you don't show the error then there's a much smaller chance of getting help
1663181532844.png
 
I’m not a programmer but have high intellect and critical thinking. Anyways what language is this written in? What is your modified shotgun suppose to do? What/where are the normal shotgun references? It’s just the top three variables I could come up with and the path in this thinking may come to a solution. The word “method” in the error is pointing 2 directions in my head. The command is trying to override I’m assuming the normal shotgun “method” perhaps?
 
Last edited:
1. C#
2. Shoot many bullets and be overpowerd af, the downside being it's speed
3. I have no idea I just copied code and hoped it would work I'm fairly new to this stuff myself
 
I just realized the things at the way bottom weren't edited right
edit: i have no clue what I am doing lmao i'm just typing stuff and hoping it works
 
I was guessing C+ but ok. af? I’m thinking the method is referencing what is the code for the normal method of the shotgun but I could be wrong. I’m guessing where you copied this from has references within to terraria code but it may or may not be a copy of the terraria code…it might just redirect to it.

Edit: So xna and modloader references I see among others at the top…ok
 
I tried looking up shotgun tutorials on YouTube but I didn't really find any, I might just search again, copy code and hope it works
 
Your error has the word “soup” in it which is nowhere in the shown code.

Edit: hang on there are 2 soup references in your code…
 
I've completely replaced the code with another tutorials code, edited it to work with my stuff and I'm not seeing any errors, I'm going to reload the mod and see if this works
 
Well it works, not sure what happened with the first try but I used RiptideDev's code for the second try and now it works.
 
Back
Top Bottom