now with actual dancing
This commit is contained in:
1 parent
b4c6e760f7
commit
db1fecc478
2 files changed
+29
-6
No files matched your search
@@ -60,8 +60,8 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
|
||||
public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
|
||||
{
|
||||
int numProjs = 2;
|
||||
for(int i = 0; i < numProjs; ++i)
|
||||
Projectile[] pair = new Projectile[2];
|
||||
for(int i = 0; i < 2; ++i)
|
||||
{
|
||||
// Pick a random direction somewhere behind the player
|
||||
float shootAngle = (float)Math.Atan2(speedY, speedX);
|
||||
@@ -73,8 +73,13 @@ namespace CalamityMod.Items.Weapons.Magic
|
||||
float randSpeed = Main.rand.NextFloat(1f - SpeedRandomness, 1f + SpeedRandomness);
|
||||
float randAngle = Main.rand.NextFloat(-Inaccuracy, Inaccuracy);
|
||||
Vector2 velocity = randSpeed * new Vector2(speedX, speedY).RotatedBy(randAngle);
|
||||
Projectile.NewProjectileDirect(spawnPos, velocity, type, damage, knockBack, player.whoAmI);
|
||||
Projectile p = Projectile.NewProjectileDirect(spawnPos, velocity, type, damage, knockBack, player.whoAmI);
|
||||
pair[i] = p;
|
||||
}
|
||||
|
||||
// Pair the swords up so they home in on each other
|
||||
pair[0].ai[1] = pair[1].whoAmI + 1f;
|
||||
pair[1].ai[1] = pair[0].whoAmI + 1f;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,13 @@ namespace CalamityMod.Projectiles.Magic
|
||||
{
|
||||
public class LightBlade : ModProjectile
|
||||
{
|
||||
private const int Lifetime = 180;
|
||||
private const int Lifetime = 300;
|
||||
private const int NumAfterimages = 8;
|
||||
private const float LightBrightness = 0.7f;
|
||||
private const int DustID = 175;
|
||||
const float SwordHomingStrength = 30f;
|
||||
const float EnemyHomingStrength = 70f;
|
||||
|
||||
private Color lightColor = Color.White;
|
||||
|
||||
public override void SetStaticDefaults()
|
||||
@@ -58,8 +61,23 @@ namespace CalamityMod.Projectiles.Magic
|
||||
else
|
||||
Lighting.AddLight(projectile.Center, lightColor.ToVector3() * LightBrightness);
|
||||
|
||||
// The projectile never slows down, even as it tries to curve towards enemies
|
||||
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 1000f, projectile.ai[0], 80f);
|
||||
// Home in on the paired sword, if one is defined and it exists
|
||||
if (projectile.ai[1] > 0f)
|
||||
{
|
||||
Projectile paired = Main.projectile[(int)(projectile.ai[1] - 1)];
|
||||
if (paired is null || !paired.active || paired.type != ModContent.ProjectileType<LightBlade>())
|
||||
projectile.ai[1] = 0f;
|
||||
else
|
||||
{
|
||||
Vector2 homingVec = projectile.DirectionTo(paired.Center) * projectile.ai[0];
|
||||
projectile.velocity = (projectile.velocity * (SwordHomingStrength - 1f) + homingVec) / SwordHomingStrength;
|
||||
}
|
||||
}
|
||||
|
||||
// Also weakly home in on nearby enemies
|
||||
CalamityGlobalProjectile.HomeInOnNPC(projectile, true, 1000f, projectile.ai[0], EnemyHomingStrength);
|
||||
|
||||
// The projectile never slows down, even as it tries to curve towards enemies and its paired sword.
|
||||
float currentSpeed = projectile.velocity.Length();
|
||||
projectile.velocity *= projectile.ai[0] / currentSpeed;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user