How to recreate burst like clockwork assault rifle

oAbsol

Terrarian
So I've been trying to find out how to recreate the burst effect of the clockwork assault rifle, but I'm a little lost. I was able to recreate it by setting the usetime and useanimation to make it shoot 3 bullets every time the item is used, but once you enable auto fire or even just click fast, it doesn't have that delay that the clockwork has between shots. The public override bool used was based on a thread I found that was made in 2015, but I don't get how or why it works, and even then I get an error because of It, so if there's another way to make this work/if someone could explain how it works and what I'm doing wrong, that would be wonderful.

--------------------------------------------------------------

Code is listed below:

--------------------------------------------------------------

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace CodingPractice.Items
{
public class SuperCommandoRifle : ModItem
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Super Commando Rifle"); // By default, capitalization in classnames will add spaces to the display name. You can customize the display name here by uncommenting this line.
Tooltip.SetDefault("Scavanged from a backyard battlefield");
}

public override void SetDefaults()
{
Item.damage = 42;
Item.DamageType = DamageClass.Ranged;
Item.width = 35;
Item.height = 24;
Item.useTime = 4;
Item.useAnimation = 11;
Item.useStyle = 5;
Item.knockBack = 2;
Item.value = 230000;
Item.rare = 7;
Item.UseSound = SoundID.Item31;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<projectiles.SuperCommandoRifleProjectile>();
Item.shootSpeed = 20f;
}

public override bool UseItem(Player p)
{
if (p.itemAnimation < p.inventory[p.selectedItem].useAnimation - 8)
{
return true;
}
else
{
return false;
}
}

public override void AddRecipes()
{
Recipe recipe = CreateRecipe();
recipe.AddIngredient(ItemID.ClockworkAssaultRifle, 1);
recipe.AddIngredient(ItemID.ChlorophyteBar, 10);
recipe.AddTile(TileID.MythrilAnvil);
recipe.Register();
}
}
}
 
Aight so if you go to tModLoader/ExampleGun.cs at 1.4 · tModLoader/tModLoader you can find ExampleMod, it's got some usefull copy-paste code you can use, on line 111 it shows you:

item.useAnimation = 12; //Total time for shooting
item.useTime = 4; //Time per shot, so 1/3 of useAnimation for 3 shots
item.reuseDelay = 14; //Delay between shots
item.consumeAmmoOnLastShotOnly = true; //Use one piece of Ammo per burst

Try putting that in your SetDefualts, don't think you need the UseItem code there
 
Aight so if you go to tModLoader/ExampleGun.cs at 1.4 · tModLoader/tModLoader you can find ExampleMod, it's got some usefull copy-paste code you can use, on line 111 it shows you:

item.useAnimation = 12; //Total time for shooting
item.useTime = 4; //Time per shot, so 1/3 of useAnimation for 3 shots
item.reuseDelay = 14; //Delay between shots
item.consumeAmmoOnLastShotOnly = true; //Use one piece of Ammo per burst

Try putting that in your SetDefualts, don't think you need the UseItem code there
Thanks. ALso dude I wanna say thanks, Ik it's only twice but you are a hard carry <3
 
Ofc man, always happy to help
Hey mind if I ask you another question? I looked through the example mod, but couldn't find anything on how recall potions work. Would you happen to know anything about this?
 
I'm not 100% but I believe it's just set the player position, make dust, make noise, you'll have to find the players spawn point if you want it, probably attached to the player somehow.
 
Back
Top Bottom