Fixed crashes for ranged weapons.

Optimized code.
This commit is contained in:
Big Duckie
2022-07-05 16:08:31 -06:00
parent 8f5ec80722
commit eb2cb27e79
51 changed files with 513 additions and 501 deletions
@@ -17,6 +17,7 @@ public class MachinePistolGolden : ModItem
public override void SetDefaults()
{
Item.damage = 66;
Item.DamageType = DamageClass.Ranged;
Item.width = 50;
Item.height = 38;
Item.useTime = 2;
@@ -38,25 +39,23 @@ public class MachinePistolGolden : ModItem
return new Vector2(-12f, -8f);
}
public override bool CanConsumeAmmo(Item ammo, Player player)
public override bool CanConsumeAmmo(Item ammo, Player player)
{
return Utils.NextFloat(Main.rand) >= 0.8f;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Vector2 perturbedSpeed = Utils.RotatedByRandom(new Vector2(velocity.X, velocity.Y), (double)MathHelper.ToRadians(5f));
velocity.X = perturbedSpeed.X;
velocity.Y = perturbedSpeed.Y;
velocity = Utils.RotatedByRandom(velocity, (double)MathHelper.ToRadians(5f));
return true;
}
public override void AddRecipes()
{
Recipe val = CreateRecipe();
val.AddRecipeGroup("FabusMod:Verano", 1);
val.AddIngredient(ModContent.ItemType<Items.CraftingIngredients.GoddessGold>(), 6);
val.AddTile(TileID.LunarCraftingStation);
val.Register();
CreateRecipe()
.AddRecipeGroup("FabusMod:Verano")
.AddIngredient(ModContent.ItemType<Items.CraftingIngredients.GoddessGold>(), 6)
.AddTile(TileID.LunarCraftingStation)
.Register();
}
}