Files
CalamityModPublic/Items/Weapons/Melee/Murasama.cs
T

107 lines
4.7 KiB
C#

using CalamityMod.Projectiles.Melee;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Weapons.Melee
{
public class Murasama : ModItem, ILocalizedModType
{
public new string LocalizationCategory => "Items.Weapons.Melee";
public int frameCounter = 0;
public int frame = 0;
public bool IDUnlocked(Player player) => DownedBossSystem.downedYharon || player.name == "Jetstream Sam" || player.name == "Samuel Rodrigues";
public override void SetStaticDefaults()
{
Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(6, 13));
ItemID.Sets.AnimatesAsSoul[Type] = true;
}
public override void SetDefaults()
{
Item.height = 128;
Item.width = 56;
Item.damage = 3001;
Item.DamageType = TrueMeleeNoSpeedDamageClass.Instance;
Item.noMelee = true;
Item.noUseGraphic = true;
Item.channel = true;
Item.useAnimation = 25;
Item.useStyle = ItemUseStyleID.Shoot;
Item.useTime = 5;
Item.knockBack = 6.5f;
Item.autoReuse = false;
Item.value = CalamityGlobalItem.Rarity15BuyPrice;
Item.shoot = ModContent.ProjectileType<MurasamaSlash>();
Item.shootSpeed = 24f;
Item.rare = ModContent.RarityType<Violet>();
Main.RegisterItemAnimation(Item.type, new DrawAnimationVertical(5, 14));
}
// Terraria seems to really dislike high crit values in SetDefaults
public override void ModifyWeaponCrit(Player player, ref float crit) => crit += 30;
public override bool PreDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frameI, Color drawColor, Color itemColor, Vector2 origin, float scale)
{
Texture2D texture;
if (IDUnlocked(Main.LocalPlayer))
{
//0 = 6 frames, 8 = 3 frames]
texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, position, Item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), Color.White, 0f, origin, scale, SpriteEffects.None, 0);
}
else
{
texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Melee/MurasamaSheathed").Value;
spriteBatch.Draw(texture, position, null, Color.White, 0f, origin, scale, SpriteEffects.None, 0);
}
return false;
}
public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI)
{
Texture2D texture;
if (IDUnlocked(Main.LocalPlayer))
{
texture = ModContent.Request<Texture2D>(Texture).Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13), lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
}
else
{
texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Melee/MurasamaSheathed").Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, null, lightColor, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
}
return false;
}
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
{
if (!IDUnlocked(Main.LocalPlayer))
return;
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Melee/MurasamaGlow").Value;
spriteBatch.Draw(texture, Item.position - Main.screenPosition, Item.GetCurrentFrame(ref frame, ref frameCounter, frame == 0 ? 36 : frame == 8 ? 24 : 6, 13, false), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0);
}
public override bool CanUseItem(Player player)
{
if (player.ownedProjectileCounts[Item.shoot] > 0)
return false;
return IDUnlocked(player);
}
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
{
Projectile.NewProjectile(source, position, velocity, type, damage, knockback, player.whoAmI, 0f, 0f);
return false;
}
}
}