75 lines
3.1 KiB
C#
75 lines
3.1 KiB
C#
using CalamityMod.Projectiles.Magic;
|
|
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class IonBlaster : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Magic";
|
|
|
|
public static int ArmorPenetration = 40;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ItemID.Sets.ItemsThatAllowRepeatedRightClick[Type] = true;
|
|
}
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 68;
|
|
Item.height = 38;
|
|
Item.damage = 24;
|
|
Item.ArmorPenetration = ArmorPenetration;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.mana = 12;
|
|
Item.useAnimation = 7;
|
|
Item.useTime = 7;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.knockBack = 6f;
|
|
Item.autoReuse = true;
|
|
Item.noMelee = true;
|
|
Item.channel = true;
|
|
Item.noUseGraphic = true;
|
|
Item.shoot = ModContent.ProjectileType<IonBlasterHoldout>();
|
|
Item.shootSpeed = 3f;
|
|
|
|
Item.value = CalamityGlobalItem.RarityPinkBuyPrice;
|
|
Item.rare = ItemRarityID.Pink;
|
|
}
|
|
public override bool CanUseItem(Player player) => player.ownedProjectileCounts[Item.shoot] == 0;
|
|
|
|
// Makes the rotation of the mouse around the player sync in multiplayer.
|
|
public override void HoldItem(Player player) => player.Calamity().mouseRotationListener = true;
|
|
public override bool AltFunctionUse(Player player) => true;
|
|
public override void PostDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, float rotation, float scale, int whoAmI)
|
|
{
|
|
Item.DrawItemGlowmaskSingleFrame(spriteBatch, rotation, ModContent.Request<Texture2D>("CalamityMod/Items/Weapons/Magic/IonBlasterGlow").Value);
|
|
}
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
Projectile holdout;
|
|
if (player.Calamity().mouseRight && player.whoAmI == Main.myPlayer && !Main.mapFullscreen && !Main.blockMouse)
|
|
{
|
|
holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, 5);
|
|
}
|
|
else
|
|
holdout = Projectile.NewProjectileDirect(source, player.MountedCenter, Vector2.Zero, type, damage, knockback, player.whoAmI, 0, 0, 0);
|
|
holdout.velocity = player.Calamity().mouseWorld - player.RotatedRelativePoint(player.MountedCenter);
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddRecipeGroup("AnyAdamantiteBar", 10).
|
|
AddIngredient(ItemID.SoulofLight, 5).
|
|
AddTile(TileID.MythrilAnvil).
|
|
Register();
|
|
}
|
|
}
|
|
}
|