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
@@ -1,4 +1,3 @@
using FabusMod.Projectiles.LightBlasts;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
@@ -18,6 +17,7 @@ public class GoldenStinger : ModItem
public override void SetDefaults()
{
Item.damage = 68;
Item.DamageType = DamageClass.Ranged;
Item.width = 32;
Item.height = 38;
Item.useTime = 3;
@@ -28,14 +28,14 @@ public class GoldenStinger : ModItem
Item.value = Item.sellPrice(0, 30, 35, 0);
Item.UseSound = SoundID.Item11;
Item.autoReuse = true;
Item.shoot = ModContent.ProjectileType<GoldenLightBlast>();
Item.shoot = ModContent.ProjectileType<Projectiles.LightBlasts.GoldenLightBlast>();
Item.shootSpeed = 10f;
Item.rare = 12;
}
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 muzzleOffset = Vector2.Normalize(new Vector2(velocity.X, velocity.Y)) * 32f;
Vector2 muzzleOffset = Vector2.Normalize(velocity) * 32f;
if (Collision.CanHit(position, 0, 0, position + muzzleOffset, 0, 0))
{
position += muzzleOffset;
@@ -45,10 +45,10 @@ public class GoldenStinger : ModItem
public override void AddRecipes()
{
Recipe val = CreateRecipe();
val.AddRecipeGroup("FabusMod:TheStinger", 1);
val.AddIngredient(ModContent.ItemType<Items.CraftingIngredients.GoddessGold>(), 6);
val.AddTile(TileID.LunarCraftingStation);
val.Register();
CreateRecipe()
.AddRecipeGroup("FabusMod:TheStinger")
.AddIngredient(ModContent.ItemType<Items.CraftingIngredients.GoddessGold>(), 6)
.AddTile(TileID.LunarCraftingStation)
.Register();
}
}