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
{
}
}
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
{
}
}