added monstrous knives
This commit is contained in:
1 parent
a74c0bd003
commit
e2d7abb34d
4 files changed
+196
No files matched your search
@@ -0,0 +1,111 @@
|
||||
using CalamityMod.Items.Materials;
|
||||
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 MonstrousKnives : ModItem
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Monstrous Knives");
|
||||
Tooltip.SetDefault("Throws a spread of knives that can heal the user");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
item.width = 18;
|
||||
item.damage = 4;
|
||||
item.melee = true;
|
||||
item.noMelee = true;
|
||||
item.noUseGraphic = true;
|
||||
item.useAnimation = 21;
|
||||
item.useStyle = 1;
|
||||
item.useTime = 21;
|
||||
item.knockBack = 3f;
|
||||
item.UseSound = SoundID.Item39;
|
||||
item.autoReuse = true;
|
||||
item.height = 20;
|
||||
item.value = Item.buyPrice(0, 2, 0, 0);
|
||||
item.rare = 2;
|
||||
item.shoot = ModContent.ProjectileType<MonstrousKnife>();
|
||||
item.shootSpeed = 15f;
|
||||
item.Calamity().customRarity = CalamityRarity.Dedicated;
|
||||
}
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
float speed = item.shootSpeed;
|
||||
Vector2 playerPos = player.RotatedRelativePoint(player.MountedCenter, true);
|
||||
float xDist = Main.mouseX + Main.screenPosition.X - playerPos.X;
|
||||
float yDist = Main.mouseY + Main.screenPosition.Y - playerPos.Y;
|
||||
if (player.gravDir == -1f)
|
||||
{
|
||||
yDist = Main.screenPosition.Y + Main.screenHeight - Main.mouseY - playerPos.Y;
|
||||
}
|
||||
Vector2 vector = new Vector2(xDist, yDist);
|
||||
float speedMult = vector.Length();
|
||||
if ((float.IsNaN(xDist) && float.IsNaN(yDist)) || (xDist == 0f && yDist == 0f))
|
||||
{
|
||||
xDist = player.direction;
|
||||
yDist = 0f;
|
||||
speedMult = speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
speedMult = speed / speedMult;
|
||||
}
|
||||
xDist *= speedMult;
|
||||
yDist *= speedMult;
|
||||
int knifeAmt = 3;
|
||||
if (Main.rand.NextBool(2))
|
||||
{
|
||||
knifeAmt++;
|
||||
}
|
||||
if (Main.rand.NextBool(4))
|
||||
{
|
||||
knifeAmt++;
|
||||
}
|
||||
if (Main.rand.NextBool(8))
|
||||
{
|
||||
knifeAmt++;
|
||||
}
|
||||
if (Main.rand.NextBool(16))
|
||||
{
|
||||
knifeAmt++;
|
||||
}
|
||||
for (int i = 0; i < knifeAmt; i++)
|
||||
{
|
||||
float xVec = xDist;
|
||||
float yVec = yDist;
|
||||
float spreadMult = 0.05f * i;
|
||||
xVec += Main.rand.NextFloat(-25f, 25f) * spreadMult;
|
||||
yVec += Main.rand.NextFloat(-25f, 25f) * spreadMult;
|
||||
Vector2 directionToShoot = new Vector2(xVec, yVec);
|
||||
speedMult = directionToShoot.Length();
|
||||
speedMult = speed / speedMult;
|
||||
xVec *= speedMult;
|
||||
yVec *= speedMult;
|
||||
directionToShoot = new Vector2(xVec, yVec);
|
||||
Projectile.NewProjectile(playerPos, directionToShoot, type, damage, knockBack, player.whoAmI, 0f, 0f);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void AddRecipes()
|
||||
{
|
||||
ModRecipe recipe = new ModRecipe(mod);
|
||||
recipe.AddIngredient(ItemID.ThrowingKnife, 200);
|
||||
recipe.AddIngredient(ItemID.LifeCrystal);
|
||||
recipe.AddIngredient(ItemID.LesserHealingPotion, 5); //I considered making a recipe group for any healing potion but Merchant sells these
|
||||
recipe.AddIngredient(ModContent.ItemType<VictoryShard>(), 10);
|
||||
recipe.AddTile(TileID.Anvils);
|
||||
recipe.SetResult(this);
|
||||
recipe.AddRecipe();
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 588 B |
@@ -0,0 +1,85 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
namespace CalamityMod.Projectiles.Melee
|
||||
{
|
||||
public class MonstrousKnife : ModProjectile
|
||||
{
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Monstrous Knife");
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 14;
|
||||
projectile.height = 14;
|
||||
projectile.aiStyle = 2;
|
||||
projectile.friendly = true;
|
||||
projectile.melee = true;
|
||||
projectile.ignoreWater = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
projectile.ai[0] += 1f;
|
||||
if (projectile.ai[0] >= 30f)
|
||||
{
|
||||
projectile.alpha += 10;
|
||||
if (projectile.damage > 1)
|
||||
projectile.damage = (int)(projectile.damage * 0.9);
|
||||
projectile.knockBack = projectile.knockBack * 0.9f;
|
||||
if (projectile.alpha >= 255)
|
||||
projectile.Kill();
|
||||
}
|
||||
if (projectile.ai[0] < 30f)
|
||||
projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + MathHelper.PiOver2;
|
||||
}
|
||||
|
||||
public override void Kill(int timeLeft)
|
||||
{
|
||||
for (int dustIndex = 0; dustIndex < 3; ++dustIndex)
|
||||
{
|
||||
int redDust = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 182, 0f, 0f, 100, new Color(), 0.8f);
|
||||
Dust dust = Main.dust[redDust];
|
||||
dust.noGravity = true;
|
||||
dust.velocity *= 1.2f;
|
||||
dust.velocity -= projectile.oldVelocity * 0.3f;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
if (target.type == NPCID.TargetDummy || target.lifeMax <= 5 || Main.player[projectile.owner].moonLeech)
|
||||
return;
|
||||
if (Main.player[projectile.owner].lifeSteal <= 0f)
|
||||
return;
|
||||
|
||||
float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f);
|
||||
if (healAmt < 1f)
|
||||
healAmt = 1f;
|
||||
if (Main.rand.NextBool(3))
|
||||
CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f);
|
||||
}
|
||||
|
||||
public override void OnHitPvp(Player target, int damage, bool crit)
|
||||
{
|
||||
if (Main.myPlayer != projectile.owner)
|
||||
return;
|
||||
if (Main.player[projectile.owner].moonLeech)
|
||||
return;
|
||||
if (Main.player[projectile.owner].lifeSteal <= 0f)
|
||||
return;
|
||||
|
||||
float healAmt = damage * Main.rand.NextFloat(0.075f, 0.9f);
|
||||
if (healAmt < 1f)
|
||||
healAmt = 1f;
|
||||
if (Main.rand.NextBool(3))
|
||||
CalamityGlobalProjectile.SpawnLifeStealProjectile(projectile, Main.player[projectile.owner], healAmt, ProjectileID.VampireHeal, 1200f, 1.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 478 B |
Reference in new issue
Block a user