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.
98 lines
4.1 KiB
C#
98 lines
4.1 KiB
C#
using System;
|
|
using CalamityMod.Projectiles.Magic;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.DataStructures;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Items.Weapons.Magic
|
|
{
|
|
public class IcicleStaff : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Weapons.Magic";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
Item.staff[Item.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 38;
|
|
Item.height = 42;
|
|
Item.damage = 10;
|
|
Item.DamageType = DamageClass.Magic;
|
|
Item.mana = 6;
|
|
Item.useTime = 7;
|
|
Item.useAnimation = 14;
|
|
Item.useStyle = ItemUseStyleID.Shoot;
|
|
Item.noMelee = true;
|
|
Item.knockBack = 2f;
|
|
Item.value = CalamityGlobalItem.RarityBlueBuyPrice;
|
|
Item.rare = ItemRarityID.Blue;
|
|
Item.UseSound = SoundID.Item8;
|
|
Item.autoReuse = true;
|
|
Item.shoot = ModContent.ProjectileType<IcicleStaffProj>();
|
|
Item.shootSpeed = 11f;
|
|
}
|
|
|
|
|
|
public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback)
|
|
{
|
|
int i = Main.myPlayer;
|
|
float icicleSpeed = velocity.Length();
|
|
float playerKnockback = knockback;
|
|
playerKnockback = player.GetWeaponKnockback(Item, playerKnockback);
|
|
player.itemTime = Item.useTime;
|
|
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 = icicleSpeed;
|
|
}
|
|
else
|
|
{
|
|
mouseDistance = icicleSpeed / mouseDistance;
|
|
}
|
|
|
|
realPlayerPos = 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);
|
|
realPlayerPos.X = (realPlayerPos.X + player.Center.X) / 2f + (float)Main.rand.Next(-200, 201);
|
|
mouseXDist = (float)Main.mouseX + Main.screenPosition.X - realPlayerPos.X;
|
|
mouseYDist = (float)Main.mouseY + Main.screenPosition.Y - realPlayerPos.Y;
|
|
if (mouseYDist < 0f)
|
|
{
|
|
mouseYDist *= -1f;
|
|
}
|
|
if (mouseYDist < 20f)
|
|
{
|
|
mouseYDist = 20f;
|
|
}
|
|
mouseDistance = (float)Math.Sqrt((double)(mouseXDist * mouseXDist + mouseYDist * mouseYDist));
|
|
mouseDistance = icicleSpeed / mouseDistance;
|
|
mouseXDist *= mouseDistance;
|
|
mouseYDist *= mouseDistance;
|
|
float speedX4 = mouseXDist;
|
|
float speedY5 = mouseYDist + (float)Main.rand.Next(-40, 41) * 0.02f;
|
|
Projectile.NewProjectile(source, realPlayerPos.X, realPlayerPos.Y, speedX4, speedY5, ModContent.ProjectileType<IcicleStaffProj>(), damage, playerKnockback, i, 0f, (float)Main.rand.Next(10));
|
|
return false;
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddRecipeGroup("AnyIceBlock", 25).
|
|
AddIngredient(ItemID.Shiverthorn, 3).
|
|
AddTile(TileID.Anvils).
|
|
Register();
|
|
}
|
|
}
|
|
}
|