Now that melee speed isn't everywhere this change that was made as a band aid balance fix once melee speed began effecting projectile weapons can be removed. Also made brimstone sword actually switch between Melee damge and melee no speed damage depending on the attack type and reduced its speed + gave it an extra update so it doesn't phase through enemies when thrown.
101 lines
4.2 KiB
C#
101 lines
4.2 KiB
C#
using Terraria.DataStructures;
|
|
using CalamityMod.Projectiles.Melee;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
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.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.height = 90;
|
|
Item.value = CalamityGlobalItem.Rarity11BuyPrice;
|
|
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 num72 = Main.rand.Next(22, 30);
|
|
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;
|
|
}
|
|
|
|
int num107 = 16;
|
|
for (int num108 = 0; num108 < num107; num108++)
|
|
{
|
|
vector2 = 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);
|
|
vector2.X = (vector2.X + player.Center.X) / 2f;
|
|
vector2.Y -= (float)(100 * num108);
|
|
num78 = (float)Main.mouseX + Main.screenPosition.X - vector2.X;
|
|
num79 = (float)Main.mouseY + Main.screenPosition.Y - vector2.Y;
|
|
num80 = (float)Math.Sqrt((double)(num78 * num78 + num79 * num79));
|
|
num80 = num72 / num80;
|
|
num78 *= num80;
|
|
num79 *= num80;
|
|
float speedX4 = num78 + (float)Main.rand.Next(-360, 361) * 0.02f;
|
|
float speedY5 = num79 + (float)Main.rand.Next(-360, 361) * 0.02f;
|
|
Projectile.NewProjectile(source, vector2.X, vector2.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 num250 = Dust.NewDust(new Vector2((float)hitbox.X, (float)hitbox.Y), hitbox.Width, hitbox.Height, 66, (float)(player.direction * 2), 0f, 150, new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB), 1.3f);
|
|
Main.dust[num250].velocity *= 0.2f;
|
|
Main.dust[num250].noGravity = true;
|
|
}
|
|
}
|
|
}
|
|
}
|