Fixed crashes for ranged weapons.
Optimized code.
This commit is contained in:
@@ -18,6 +18,7 @@ public class Graffiti : ModItem
|
||||
public override void SetDefaults()
|
||||
{
|
||||
Item.damage = 80;
|
||||
Item.DamageType = DamageClass.Ranged;
|
||||
Item.width = 40;
|
||||
Item.height = 28;
|
||||
Item.useTime = 2;
|
||||
@@ -34,7 +35,7 @@ public class Graffiti : ModItem
|
||||
Item.expert = true;
|
||||
}
|
||||
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player)
|
||||
public override bool CanConsumeAmmo(Item ammo, Player player)
|
||||
{
|
||||
return Utils.NextFloat(Main.rand) >= 0.9f;
|
||||
}
|
||||
@@ -44,11 +45,9 @@ public class Graffiti : ModItem
|
||||
return new Vector2(1f, -2f);
|
||||
}
|
||||
|
||||
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(8f));
|
||||
velocity.X = perturbedSpeed.X;
|
||||
velocity.Y = perturbedSpeed.Y;
|
||||
velocity = Utils.RotatedByRandom(velocity, (double)MathHelper.ToRadians(8f));
|
||||
if (type == 14)
|
||||
{
|
||||
type = ModContent.ProjectileType<RainbowBullet>();
|
||||
@@ -58,10 +57,10 @@ public class Graffiti : ModItem
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
Recipe val = CreateRecipe();
|
||||
val.AddIngredient(ModContent.ItemType<GoldenPulse>());
|
||||
val.AddIngredient(ModContent.ItemType<Bars.RainbowChunk>(), 10);
|
||||
val.AddTile(ModContent.TileType<global::FabusMod.Tiles.RainbowStation>());
|
||||
val.Register();
|
||||
CreateRecipe()
|
||||
.AddIngredient(ModContent.ItemType<GoldenPulse>())
|
||||
.AddIngredient(ModContent.ItemType<Bars.RainbowChunk>(), 10)
|
||||
.AddTile(ModContent.TileType<global::FabusMod.Tiles.RainbowStation>());
|
||||
.Register();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user