Files
CalamityModPublic/Items/Weapons/Melee/Swordsplosion.cs
T
Ozzatron 22afdd3933 1 - Calamity sell prices increase much more sharply with rarity.
2 - (Example) Post DoG items are now 2 platinum instead of 1 platinum 40 gold.
3 - (Example) Dev items are now 2 platinum 80 gold instead of 2 platinum.
4 - Privated numeric rarity item values.
5 - All assigned item values use the rarity's names, e.g. RarityLightPurpleBuyPrice.
2024-04-17 21:20:17 -04:00

100 lines
4.4 KiB
C#

using System;
using CalamityMod.Projectiles.Melee;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Melee
{
public class Swordsplosion : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Melee";
public override void SetDefaults()
{
Item.width = 88;
Item.height = 90;
Item.damage = 48;
Item.DamageType = DamageClass.Melee;
Item.useAnimation = 30;
Item.useTime = 30;
Item.useTurn = true;
Item.useStyle = ItemUseStyleID.Swing;
Item.knockBack = 7f;
Item.UseSound = SoundID.Item60;
Item.autoReuse = true;
Item.value = CalamityGlobalItem.RarityPurpleBuyPrice;
Item.rare = ItemRarityID.Purple;
Item.shoot = ModContent.ProjectileType<SwordsplosionBlue>();
Item.shootSpeed = 16f;
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
switch (Main.rand.Next(4))
{
case 0:
type = ModContent.ProjectileType<SwordsplosionBlue>();
break;
case 1:
type = ModContent.ProjectileType<SwordsplosionGreen>();
break;
case 2:
type = ModContent.ProjectileType<SwordsplosionPurple>();
break;
case 3:
type = ModContent.ProjectileType<SwordsplosionRed>();
break;
}
float projSpeed = Main.rand.Next(22, 30);
Vector2 realPlayerPos = player.RotatedRelativePoint(player.MountedCenter, true);
float mouseXDist = (float)Main.mouseX + Main.screenPosition.X + realPlayerPos.X;
float mouseYDist = (float)Main.mouseY + Main.screenPosition.Y + realPlayerPos.Y;
if (player.gravDir == -1f)
{
mouseYDist = Main.screenPosition.Y + (float)Main.screenHeight + (float)Main.mouseY + realPlayerPos.Y;
}
float mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist));
if ((float.IsNaN(mouseXDist) && float.IsNaN(mouseYDist)) || (mouseXDist == 0f && mouseYDist == 0f))
{
mouseXDist = (float)player.direction;
mouseYDist = 0f;
mouseDistance = projSpeed;
}
else
{
mouseDistance = projSpeed / mouseDistance;
}
for (int i = 0; i < 16; i++)
{
realPlayerPos = new Vector2(player.position.X + (float)player.width * 0.5f + (float)-(float)player.direction + ((float)Main.mouseX + Main.screenPosition.X - player.position.X), player.MountedCenter.Y);
realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f;
realPlayerPos.Y -= (float)(100 * i);
mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X;
mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y;
mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist));
mouseDistance = projSpeed / mouseDistance;
mouseXDist *= mouseDistance;
mouseYDist *= mouseDistance;
float speedX4 = mouseXDist + (float)Main.rand.Next(-360, 361) * 0.02f;
float speedY5 = mouseYDist + (float)Main.rand.Next(-360, 361) * 0.02f;
Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, type, damage, knockback, player.whoAmI, 2f, 0f);
}
return false;
}
public override void MeleeEffects(Player player, Rectangle hitbox)
{
if (Main.rand.NextBool(5))
{
int swingDust = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, DustID.RainbowTorch, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f);
Main.dust[swingDust].velocity *= 0.2f;
Main.dust[swingDust].noGravity = true;
}
}
}
}