116 lines
4.5 KiB
C#
116 lines
4.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons
|
|
{
|
|
public class ConferenceCall : ModItem
|
|
{
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Conclave Crossfire");
|
|
Tooltip.SetDefault("50% chance to not consume ammo\n" +
|
|
"Fires two spreads of bullets, one from the gun and one from the sky");
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
item.damage = 30;
|
|
item.ranged = true;
|
|
item.width = 66;
|
|
item.height = 26;
|
|
item.useTime = 26;
|
|
item.useAnimation = 26;
|
|
item.useStyle = 5;
|
|
item.noMelee = true;
|
|
item.knockBack = 4.5f;
|
|
item.value = Item.buyPrice(0, 80, 0, 0);
|
|
item.rare = 8;
|
|
item.UseSound = SoundID.Item38;
|
|
item.autoReuse = true;
|
|
item.shootSpeed = 13f;
|
|
item.shoot = 10;
|
|
item.useAmmo = 97;
|
|
}
|
|
|
|
public override Vector2? HoldoutOffset()
|
|
{
|
|
return new Vector2(-10, 0);
|
|
}
|
|
|
|
public override bool ConsumeAmmo(Player player)
|
|
{
|
|
if (Main.rand.Next(0, 100) < 50)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
public override bool Shoot(Player player, ref Microsoft.Xna.Framework.Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
|
{
|
|
int num6 = Main.rand.Next(4, 6);
|
|
for (int index = 0; index < num6; ++index)
|
|
{
|
|
float SpeedX = speedX + (float)Main.rand.Next(-30, 31) * 0.05f;
|
|
float SpeedY = speedY + (float)Main.rand.Next(-30, 31) * 0.05f;
|
|
Projectile.NewProjectile(position.X, position.Y, SpeedX, SpeedY, type, damage, knockBack, player.whoAmI, 0f, 0f);
|
|
}
|
|
float num72 = item.shootSpeed;
|
|
Vector2 vector2 = player.RotatedRelativePoint(player.MountedCenter, true);
|
|
float num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
float num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (player.gravDir == -1f)
|
|
{
|
|
num79 = Main.screenPosition.Y + (float)Main.screenHeight - (float)Main.mouseY - vector2.Y;
|
|
}
|
|
float num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
if ((float.IsNaN(num78) && float.IsNaN(num79)) || (num78 == 0f && num79 == 0f))
|
|
{
|
|
num78 = (float)player.direction;
|
|
num79 = 0f;
|
|
num80 = num72;
|
|
}
|
|
else
|
|
{
|
|
num80 = num72 / num80;
|
|
}
|
|
|
|
for (int num108 = 0; num108 < num6; num108++)
|
|
{
|
|
vector2 = new Vector2(player.position.X + (float)player.width * 0.5f + (float)(Main.rand.Next(201) * -(float)player.direction) + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y - 600f);
|
|
vector2.X = (vector2.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201);
|
|
vector2.Y -= (float)(100 * num108);
|
|
num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
if (num79 < 0f)
|
|
{
|
|
num79 *= -1f;
|
|
}
|
|
if (num79 < 20f)
|
|
{
|
|
num79 = 20f;
|
|
}
|
|
num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
num80 = num72 / num80;
|
|
num78 *= num80;
|
|
num79 *= num80;
|
|
float speedX4 = num78 + (float)Main.rand.Next(-30, 31) * 0.02f;
|
|
float speedY5 = num79 + (float)Main.rand.Next(-30, 31) * 0.02f;
|
|
Projectile.NewProjectile(vector2.X, vector2.Y, speedX4, speedY5, type, damage, knockBack, player.whoAmI, 0f, 0f);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
ModRecipe recipe = new ModRecipe(mod);
|
|
recipe.AddIngredient(ItemID.TacticalShotgun);
|
|
recipe.AddIngredient(null, "CoreofChaos", 7);
|
|
recipe.AddTile(TileID.MythrilAnvil);
|
|
recipe.SetResult(this);
|
|
recipe.AddRecipe();
|
|
}
|
|
}
|
|
}
|