Nanoblack Reaper sub-blade rework

This commit is contained in:
SheerExpanse committed 2019-07-14 00:41:34 -04:00
1 parent 02187f611c
commit 0da4d317bc
4 files changed
+141 -111

No files matched your search

+81 -67
View File
@@ -10,7 +10,9 @@ namespace CalamityMod.Projectiles.Melee
{
private static float RotationIncrement = 0.22f;
private static int Lifetime = 240;
private static float ReboundTime = 50f;
private static float ReboundTime = 50f;
private static int MinBladeTimer = 13;
private static int MaxBladeTimer = 18;
public override void SetStaticDefaults()
{
@@ -30,13 +32,20 @@ namespace CalamityMod.Projectiles.Melee
projectile.timeLeft = Lifetime;
projectile.usesLocalNPCImmunity = true;
projectile.localNPCHitCooldown = 2;
}
}
public override void AI()
{
drawOffsetX = -11;
drawOriginOffsetY = -4;
drawOriginOffsetX = 0;
drawOriginOffsetX = 0;
// Initialize the frame counter and random blade delay on the very first frame.
if (projectile.timeLeft == Lifetime)
{
projectile.ai[0] = 0f;
projectile.ai[1] = GetBladeDelay();
}
// Produces electricity and green firework sparks constantly while in flight.
if (Main.rand.Next(3) == 0)
@@ -48,73 +57,73 @@ namespace CalamityMod.Projectiles.Melee
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity = velocityMult * projectile.velocity;
Main.dust[idx].scale = scale;
}
// ai[0] stores whether the scythe is returning. If 0, it isn't. If 1, it is.
if (projectile.ai[0] == 0f)
{
projectile.ai[1] += 1f;
if (projectile.ai[1] >= ReboundTime)
{
projectile.ai[0] = 1f;
projectile.ai[1] = 0f;
projectile.netUpdate = true;
}
}
else
{
projectile.tileCollide = false;
float returnSpeed = NanoblackReaperMelee.Speed;
float acceleration = 2.4f;
}
// ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade.
projectile.ai[0] += 1f;
projectile.ai[1] -= 1f;
// On the frame the scythe begins returning, send a net update.
if (projectile.ai[0] == ReboundTime)
projectile.netUpdate = true;
// The scythe runs its returning AI if the frame counter is greater than ReboundTime.
if (projectile.ai[0] >= ReboundTime)
{
float returnSpeed = NanoblackReaperMelee.Speed;
float acceleration = 2.4f;
Player owner = Main.player[projectile.owner];
// Delete the scythe 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(xDist * xDist + yDist * yDist);
if (dist > 3000f)
projectile.Kill();
Vector2 playerCenter = owner.Center;
float xDist = playerCenter.X - projectile.Center.X;
float yDist = playerCenter.Y - projectile.Center.Y;
float dist = (float)Math.Sqrt(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();
}
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();
}
// Create nanoblack energy blades while in flight after a delay.
if(Lifetime - projectile.timeLeft >= 4 && Main.rand.Next(16) == 0)
SpawnEnergyBlade();
// Create nanoblack energy blades at a somewhat-random rate while in flight.
if (projectile.ai[1] <= 0f)
{
SpawnEnergyBlade();
projectile.ai[1] = GetBladeDelay();
}
// Rotate the scythe as it flies.
float spin = (projectile.direction <= 0) ? -1f : 1f;
@@ -122,6 +131,11 @@ namespace CalamityMod.Projectiles.Melee
return;
}
private int GetBladeDelay()
{
return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1);
}
private void SpawnEnergyBlade()
{
int bladeID = mod.ProjectileType("NanoblackSplitMelee");
+13 -11
View File
@@ -10,12 +10,15 @@ namespace CalamityMod.Projectiles.Melee
public class NanoblackSplitMelee : ModProjectile
{
private static int SpriteWidth = 52;
private static float MaxRotationSpeed = 0.25f;
private static int Lifetime = 90;
private static float HomingStartRange = 100f;
private static float HomingBreakRange = 600f;
private static float HomingBonusRange = 100f;
private static float MaxSpeed = 12f;
private static int Lifetime = 90;
private static float MaxRotationSpeed = 0.25f;
private static float MaxSpeed = 22f;
private static float HomingStartRange = 500f;
private static float HomingBreakRange = 900f;
private static float HomingBonusRangeCap = 200f;
private static float BaseHomingFactor = 1.6f;
private static float MaxHomingFactor = 3.2f;
public override void SetStaticDefaults()
{
@@ -30,7 +33,7 @@ namespace CalamityMod.Projectiles.Melee
projectile.melee = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.penetrate = 6;
projectile.penetrate = 4;
projectile.extraUpdates = 1;
projectile.timeLeft = Lifetime;
projectile.usesLocalNPCImmunity = true;
@@ -153,12 +156,11 @@ namespace CalamityMod.Projectiles.Melee
return target;
}
// Energy blades home more aggressively the closer they are to their target.
// The homing factor ranges from 0.6 to 3.6 at point blank.
// Energy blades home even more aggressively if they are very close to their target.
private float CalcHomingFactor(float dist)
{
float baseFactor = 0.6f;
float bonus = 3f * (1f - dist / HomingBonusRange);
float baseFactor = BaseHomingFactor;
float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap);
if (bonus < 0f)
bonus = 0f;
return baseFactor + bonus;
+34 -21
View File
@@ -3,7 +3,6 @@ using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
using CalamityMod.Items.Weapons;
using CalamityMod.Projectiles;
namespace CalamityMod.Projectiles.Rogue
{
@@ -12,6 +11,8 @@ namespace CalamityMod.Projectiles.Rogue
private static float RotationIncrement = 0.22f;
private static int Lifetime = 240;
private static float ReboundTime = 50f;
private static int MinBladeTimer = 13;
private static int MaxBladeTimer = 18;
public override void SetStaticDefaults()
{
@@ -37,7 +38,14 @@ namespace CalamityMod.Projectiles.Rogue
{
drawOffsetX = -11;
drawOriginOffsetY = -4;
drawOriginOffsetX = 0;
drawOriginOffsetX = 0;
// Initialize the frame counter and random blade delay on the very first frame.
if (projectile.timeLeft == Lifetime)
{
projectile.ai[0] = 0f;
projectile.ai[1] = GetBladeDelay();
}
// Produces electricity and green firework sparks constantly while in flight.
if (Main.rand.Next(3) == 0)
@@ -49,22 +57,19 @@ namespace CalamityMod.Projectiles.Rogue
Main.dust[idx].noGravity = true;
Main.dust[idx].velocity = velocityMult * projectile.velocity;
Main.dust[idx].scale = scale;
}
// ai[0] stores whether the scythe is returning. If 0, it isn't. If 1, it is.
if (projectile.ai[0] == 0f)
{
projectile.ai[1] += 1f;
if (projectile.ai[1] >= ReboundTime)
{
projectile.ai[0] = 1f;
projectile.ai[1] = 0f;
projectile.netUpdate = true;
}
}
else
{
projectile.tileCollide = false;
}
// ai[0] is a frame counter. ai[1] is a countdown to spawning the next nanoblack energy blade.
projectile.ai[0] += 1f;
projectile.ai[1] -= 1f;
// On the frame the scythe begins returning, send a net update.
if (projectile.ai[0] == ReboundTime)
projectile.netUpdate = true;
// The scythe runs its returning AI if the frame counter is greater than ReboundTime.
if (projectile.ai[0] >= ReboundTime)
{
float returnSpeed = NanoblackReaperRogue.Speed;
float acceleration = 2.4f;
Player owner = Main.player[projectile.owner];
@@ -113,14 +118,22 @@ namespace CalamityMod.Projectiles.Rogue
projectile.Kill();
}
// Create nanoblack energy blades while in flight after a delay.
if(Lifetime - projectile.timeLeft >= 4 && Main.rand.Next(16) == 0)
SpawnEnergyBlade();
// Create nanoblack energy blades at a somewhat-random rate while in flight.
if (projectile.ai[1] <= 0f)
{
SpawnEnergyBlade();
projectile.ai[1] = GetBladeDelay();
}
// Rotate the scythe as it flies.
float spin = (projectile.direction <= 0) ? -1f : 1f;
projectile.rotation += spin * RotationIncrement;
return;
}
private int GetBladeDelay()
{
return Main.rand.Next(MinBladeTimer, MaxBladeTimer + 1);
}
private void SpawnEnergyBlade()
+13 -12
View File
@@ -4,19 +4,21 @@ using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using CalamityMod.Projectiles;
namespace CalamityMod.Projectiles.Rogue
{
public class NanoblackSplitRogue : ModProjectile
{
private static int SpriteWidth = 52;
private static float MaxRotationSpeed = 0.25f;
private static int Lifetime = 90;
private static float HomingStartRange = 100f;
private static float HomingBreakRange = 600f;
private static float HomingBonusRange = 100f;
private static float MaxSpeed = 12f;
private static int Lifetime = 90;
private static float MaxRotationSpeed = 0.25f;
private static float MaxSpeed = 22f;
private static float HomingStartRange = 500f;
private static float HomingBreakRange = 900f;
private static float HomingBonusRangeCap = 200f;
private static float BaseHomingFactor = 1.6f;
private static float MaxHomingFactor = 3.2f;
public override void SetStaticDefaults()
{
@@ -31,7 +33,7 @@ namespace CalamityMod.Projectiles.Rogue
projectile.GetGlobalProjectile<CalamityGlobalProjectile>(mod).rogue = true;
projectile.ignoreWater = true;
projectile.tileCollide = false;
projectile.penetrate = 6;
projectile.penetrate = 4;
projectile.extraUpdates = 1;
projectile.timeLeft = Lifetime;
projectile.usesLocalNPCImmunity = true;
@@ -154,12 +156,11 @@ namespace CalamityMod.Projectiles.Rogue
return target;
}
// Energy blades home more aggressively the closer they are to their target.
// The homing factor ranges from 0.6 to 3.6 at point blank.
// Energy blades home even more aggressively if they are very close to their target.
private float CalcHomingFactor(float dist)
{
float baseFactor = 0.6f;
float bonus = 3f * (1f - dist / HomingBonusRange);
float baseFactor = BaseHomingFactor;
float bonus = (MaxHomingFactor - BaseHomingFactor) * (1f - dist / HomingBonusRangeCap);
if (bonus < 0f)
bonus = 0f;
return baseFactor + bonus;