using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace TheDankMod.Items.Weapons
{
public class TheLazorShot : ModItem
{
public override void SetDefaults()
{
item.name = "The Lazor Shot";
item.damage = 20;
item.ranged = true;
item.width = 80;
item.height = 60;
item.toolTip = "'IMMA FIRIN' MAH LAZAHHHHH'";
item.useTime = 20;
item.useAnimation = 20;
item.useStyle = 5;
item.noMelee = true; //so the item's animation doesn't do damage
item.knockBack = 4;
item.value = 10000;
item.rare = 2;
item.UseSound = SoundID.Item11;
item.autoReuse = true;
item.shoot = 10; //idk why but all the guns in the vanilla source have this
item.shootSpeed = 16f;
item.useAmmo = AmmoID.Bullet;
}
public override void AddRecipes()
{
ModRecipe recipe = new ModRecipe(mod);
recipe.AddIngredient(ItemID.DirtBlock, 1);
recipe.AddTile(TileID.WorkBenches);
recipe.SetResult(this);
recipe.AddRecipe();
}
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.Bullet) // or ProjectileID.WoodenArrowFriendly
{
type = mod.ProjectileType("The Lazer Shot"); // or ProjectileID.FireArrow;
}
return true; // return true to allow tmodloader to call Projectile.NewProjectile as normal
}
// What if I wanted this gun to have a 38% chance not to consume ammo?
/*public override bool ConsumeAmmo(Player player)
{
return Main.rand.NextFloat() > .38f;
}*/
// What if I wanted it to work like Uzi, replacing regular bullets with High Velocity Bullets?
// Uzi/Molten Fury style: Replace normal Bullets with Highvelocity
/*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.Bullet) // or ProjectileID.WoodenArrowFriendly
{
type = ProjectileID.BulletHighVelocity; // or ProjectileID.FireArrow;
}
return true; // return true to allow tmodloader to call Projectile.NewProjectile as normal
}*/
// What if I wanted it to shoot like a shotgun?
// Shotgun style: Multiple Projectiles, Random spread
/*public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
int numberProjectiles = 4 + Main.rand.Next(2); // 4 or 5 shots
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(30)); // 30 degree spread.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false; // return false because we don't want tmodloader to shoot projectile
}*/
// What if I wanted an inaccurate gun? (Chain Gun)
// Inaccurate Gun style: Single Projectile, Random spread
/*public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedByRandom(MathHelper.ToRadians(30));
speedX = perturbedSpeed.X;
speedY = perturbedSpeed.Y;
return true;
}*/
// What if I wanted multiple projectiles in a even spread? (Vampire Knives)
// Even Arc style: Multiple Projectile, Even Spread
/*public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
{
float numberProjectiles = 3 + Main.rand.Next(3); // 3, 4, or 5 shots
float rotation = MathHelper.ToRadians(45);
position += Vector2.Normalize(new Vector2(speedX, speedY)) * 45f;
for (int i = 0; i < numberProjectiles; i++)
{
Vector2 perturbedSpeed = new Vector2(speedX, speedY).RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numberProjectiles - 1))) * .2f; // Watch out for dividing by 0 if there is only 1 projectile.
Projectile.NewProjectile(position.X, position.Y, perturbedSpeed.X, perturbedSpeed.Y, type, damage, knockBack, player.whoAmI);
}
return false;
}*/
// Help, my gun isn't being held at the handle! Adjust these 2 numbers until it looks right.
/*public override Vector2? HoldoutOffset()
{
return new Vector2(10, 0);
}*/
}
}