Eldritch Fish
Terrarian
Im making a mod and want to make a bow convert wooden arrows into custom arrows
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
if (type == ProjectileID.WoodenArrowFriendly) // any projectile/ammo
{
type = mod.ProjectileType("Whatever"); // change "Whatever" to your modded projectile
}
return true;
}
I am trying to do the same thing, but it's giving me errors for the Shoot hook (no suitable method found to override) and that Modthingig (my mod file) doesn't contain a definition for Projectile type (unless mod is supposed to be that?)Code:public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack) { if (type == ProjectileID.WoodenArrowFriendly) // any projectile/ammo { type = mod.ProjectileType("Whatever"); // change "Whatever" to your modded projectile } return true; }
Ok, that did help, but how do I fix the error with [insert my mod's file name here] not containing a definition for ProjectileType?You are using old code, my above reply was from 2021, Shoot() is now updated to have an Entity Source as the first parameter. Let VS create the method and parameters for you.
turns out i figured it out my self.ModContent.ProjectileType<CustomProjName>()
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
if (type == ProjectileID.FrostburnArrow)
{
type = ModContent.ProjectileType<Icicle>();
}
return true;
}
you have to return false/not return anything at allI'm here doing the same thing, I don't get any errors in my code but the arrows don't convert in game.
Would appreciate any helpCode:public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) { if (type == ProjectileID.FrostburnArrow) { type = ModContent.ProjectileType<Icicle>(); } return true; }
I'm not sure if I understand what you mean by am I doing it from a specific item. When I shoot a frostburn arrow it just shoots the frostburn arrow nothing changes.Are you doing this from a specific item? What happens when you shoot a Frostburn Arrow?
Just remove the "return false" part. it worked for me. Also, I totally understand that you feel confused. I'm confused about something that I'm coding, actually.I'm not sure if I understand what you mean by am I doing it from a specific item. When I shoot a frostburn arrow it just shoots the frostburn arrow nothing changes.
And if I understood what Osprey meant correctly changing the return value to false just makes it so that the bow doesn't shoot anything.
Sorry if I'm dumb I'm new to this, I can also provide the item code in its entirety if that helps
I meant to say that you can just change it to ModifyShootStats and remove the return statement. Then it will work fine.He has to have a return statement or he'll get an error.
Check out examplegun, line 72, that does exactly what you are looking to do, changing 1 type of projectile to another. ExampleGun