Added Glaive (rogue weapon).
This commit is contained in:
1 parent
1352b895ca
commit
a3f5d0c71b
5 files changed
+213
-1
No files matched your search
@@ -2,7 +2,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Terraria;
|
||||
using Terraria.ModLoader;
|
||||
using CalamityMod.CalPlayer;
|
||||
|
||||
namespace CalamityMod.Items.CalamityCustomThrowingDamage
|
||||
{
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
|
||||
namespace CalamityMod.Items.CalamityCustomThrowingDamage
|
||||
{
|
||||
public class Glaive : CalamityDamageItem
|
||||
{
|
||||
public static int BaseDamage = 23;
|
||||
public static float Knockback = 3f;
|
||||
public static float Speed = 10f;
|
||||
public static float StealthSpeedMult = 1.8f;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Glaive");
|
||||
Tooltip.SetDefault("Stacks up to 3");
|
||||
// Add stealth strike tooltip once stealth strikes are implemented
|
||||
}
|
||||
|
||||
public override void SafeSetDefaults()
|
||||
{
|
||||
item.damage = BaseDamage;
|
||||
item.crit = 4;
|
||||
item.GetGlobalItem<CalamityGlobalItem>(mod).rogue = true;
|
||||
item.noMelee = true;
|
||||
item.noUseGraphic = true;
|
||||
item.width = 1;
|
||||
item.height = 1;
|
||||
item.useTime = 15;
|
||||
item.useAnimation = 15;
|
||||
item.useStyle = 1;
|
||||
item.knockBack = Knockback;
|
||||
item.value = Item.buyPrice(0, 3, 0, 0);
|
||||
item.rare = 3;
|
||||
item.UseSound = SoundID.Item1;
|
||||
item.maxStack = 3;
|
||||
|
||||
item.shootSpeed = Speed;
|
||||
item.shoot = mod.ProjectileType("GlaiveProj");
|
||||
}
|
||||
|
||||
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 ai1 = 0f;
|
||||
if (player.GetCalamityPlayer().StealthStrikeAvailable())
|
||||
{
|
||||
speedX *= StealthSpeedMult;
|
||||
speedY *= StealthSpeedMult;
|
||||
ai1 = 1f;
|
||||
}
|
||||
|
||||
Projectile.NewProjectile(position, new Vector2(speedX, speedY), type, damage, knockBack, player.whoAmI, 0f, ai1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool CanUseItem(Player player)
|
||||
{
|
||||
return player.ownedProjectileCounts[item.shoot] < item.stack;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 711 B |
@@ -0,0 +1,150 @@
|
||||
using CalamityMod.Items.CalamityCustomThrowingDamage;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod.Projectiles.Rogue
|
||||
{
|
||||
public class GlaiveProj : ModProjectile
|
||||
{
|
||||
private static int Lifetime = 180;
|
||||
private static int ReboundTime = 45;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
{
|
||||
DisplayName.SetDefault("Glaive");
|
||||
ProjectileID.Sets.TrailCacheLength[projectile.type] = 3;
|
||||
ProjectileID.Sets.TrailingMode[projectile.type] = 0;
|
||||
}
|
||||
|
||||
public override void SetDefaults()
|
||||
{
|
||||
projectile.width = 16;
|
||||
projectile.height = 16;
|
||||
projectile.friendly = true;
|
||||
projectile.tileCollide = true;
|
||||
projectile.penetrate = 3;
|
||||
projectile.timeLeft = Lifetime;
|
||||
drawOffsetX = -10;
|
||||
projectile.GetGlobalProjectile<CalamityGlobalProjectile>(mod).rogue = true;
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
{
|
||||
// ai[1] = 1 means that the projectile is a stealth strike, in which case it pierces infinitely.
|
||||
if (projectile.ai[1] == 1f)
|
||||
projectile.penetrate = projectile.maxPenetrate = -1;
|
||||
|
||||
// Boomerang rotation
|
||||
projectile.rotation += 0.4f * (float)projectile.direction;
|
||||
|
||||
// Boomerang sound
|
||||
if (projectile.soundDelay == 0)
|
||||
{
|
||||
projectile.soundDelay = 8;
|
||||
Main.PlaySound(SoundID.Item7, projectile.position);
|
||||
}
|
||||
|
||||
// Returns after some number of frames in the air
|
||||
if(projectile.timeLeft < Lifetime - ReboundTime)
|
||||
projectile.ai[0] = 1f;
|
||||
|
||||
if (projectile.ai[0] != 0f)
|
||||
{
|
||||
projectile.tileCollide = false;
|
||||
|
||||
float returnSpeed = Glaive.Speed;
|
||||
float acceleration = 0.45f;
|
||||
|
||||
if (projectile.ai[1] == 1f)
|
||||
{
|
||||
returnSpeed *= Glaive.StealthSpeedMult;
|
||||
acceleration *= Glaive.StealthSpeedMult;
|
||||
}
|
||||
|
||||
Player owner = Main.player[projectile.owner];
|
||||
|
||||
// Delete the projectile if it's excessively far away.
|
||||
Vector2 playerCenter = owner.Center;
|
||||
float xDist = playerCenter.X - projectile.Center.X;
|
||||
float yDist = playerCenter.Y - projectile.Center.Y;
|
||||
float dist = (float)Math.Sqrt((double)(xDist * xDist + yDist * yDist));
|
||||
if (dist > 3000f)
|
||||
projectile.Kill();
|
||||
|
||||
dist = returnSpeed / dist;
|
||||
xDist *= dist;
|
||||
yDist *= dist;
|
||||
|
||||
// Home back in on the player.
|
||||
if (projectile.velocity.X < xDist)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X + acceleration;
|
||||
if (projectile.velocity.X < 0f && xDist > 0f)
|
||||
projectile.velocity.X += acceleration;
|
||||
}
|
||||
else if (projectile.velocity.X > xDist)
|
||||
{
|
||||
projectile.velocity.X = projectile.velocity.X - acceleration;
|
||||
if (projectile.velocity.X > 0f && xDist < 0f)
|
||||
projectile.velocity.X -= acceleration;
|
||||
}
|
||||
if (projectile.velocity.Y < yDist)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y + acceleration;
|
||||
if (projectile.velocity.Y < 0f && yDist > 0f)
|
||||
projectile.velocity.Y += acceleration;
|
||||
}
|
||||
else if (projectile.velocity.Y > yDist)
|
||||
{
|
||||
projectile.velocity.Y = projectile.velocity.Y - acceleration;
|
||||
if (projectile.velocity.Y > 0f && yDist < 0f)
|
||||
projectile.velocity.Y -= acceleration;
|
||||
}
|
||||
|
||||
// Delete the projectile if it touches its owner.
|
||||
if (Main.myPlayer == projectile.owner)
|
||||
if (projectile.Hitbox.Intersects(owner.Hitbox))
|
||||
projectile.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
|
||||
{
|
||||
CalamityGlobalProjectile.DrawCenteredAndAfterimage(projectile, lightColor, ProjectileID.Sets.TrailingMode[projectile.type], 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
|
||||
{
|
||||
// After its last hit, starts returning instead of vanishing. Can pierce infinitely on the way back.
|
||||
if (projectile.penetrate == 1)
|
||||
{
|
||||
projectile.penetrate = -1;
|
||||
projectile.ai[0] = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
// Make it bounce on tiles.
|
||||
public override bool OnTileCollide(Vector2 oldVelocity)
|
||||
{
|
||||
// Impacts the terrain even though it bounces off.
|
||||
Main.PlaySound(SoundID.Dig, projectile.Center);
|
||||
Collision.HitTiles(projectile.position, projectile.velocity, projectile.width, projectile.height);
|
||||
|
||||
if (projectile.velocity.X != oldVelocity.X)
|
||||
{
|
||||
projectile.velocity.X = -oldVelocity.X;
|
||||
}
|
||||
if (projectile.velocity.Y != oldVelocity.Y)
|
||||
{
|
||||
projectile.velocity.Y = -oldVelocity.Y;
|
||||
}
|
||||
projectile.ai[0] = 1f;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 711 B |
Reference in new issue
Block a user