Rock pillars anti jank, death changes
This commit is contained in:
1 parent
6e33c4aca7
commit
c1a4b03f11
3 files changed
+159
-117
No files matched your search
+128
-103
@@ -4315,126 +4315,151 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
//This is the ravager rock pillar collision logic. It should only apply to rock pillars that are mostly opaque to ensure players don't get stopped by invisible pillars right when they spawn.
|
||||
//This could also potentially be limited to only run with the pillar is stationary if desired.
|
||||
if (npc.type == ModContent.NPCType<RockPillar>() && npc.Opacity > 0.9f)
|
||||
if (npc.type == ModContent.NPCType<RockPillar>() && npc.Opacity > 0.9f && npc.damage < 1)
|
||||
{
|
||||
bool LandedOnPlayer = false;
|
||||
float origX = Player.velocity.X;
|
||||
float origY = Player.velocity.Y;
|
||||
//Yes, testing intercepts on th X, Y, and X+Y individually has a purpose. It makes it far more stable and consistent.
|
||||
bool intersectX = false;
|
||||
Player.position.X += Player.velocity.X;
|
||||
npc.position += npc.velocity;
|
||||
bool intersectPreVel = false;
|
||||
Player.position += Player.velocity;
|
||||
|
||||
if (Player.Hitbox.Intersects(npc.Hitbox))
|
||||
intersectX = true;
|
||||
Player.position.X -= Player.velocity.X;
|
||||
bool intersectY = false;
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
if (Player.Hitbox.Intersects(npc.Hitbox))
|
||||
intersectY = true;
|
||||
Player.position.Y -= Player.velocity.Y;
|
||||
bool intersect = false;
|
||||
//We only bother checking the X+Y together if individually they return false.
|
||||
//This accounts for moving diagonal onto a corner.
|
||||
if (!intersectX && !intersectY)
|
||||
intersectPreVel = true;
|
||||
Player.position -= Player.velocity;
|
||||
if (intersectPreVel)
|
||||
{
|
||||
Player.position += Player.velocity;
|
||||
Player.position += npc.velocity;
|
||||
if (Collision.SolidCollision(Player.position, Player.Hitbox.Width, Player.Hitbox.Height) || Main.npc.Any(x => x.active && x.type == ModContent.NPCType<RockPillar>() && x.Opacity > 0.9f && x.whoAmI != npc.whoAmI && x.Hitbox.Intersects(Player.Hitbox)))
|
||||
{
|
||||
npc.damage = npc.defDamage;
|
||||
npc.ai[0] = 1;
|
||||
LandedOnPlayer = true;
|
||||
Player.position -= npc.velocity;
|
||||
}
|
||||
}
|
||||
npc.position -= npc.velocity;
|
||||
|
||||
if (!LandedOnPlayer)
|
||||
{
|
||||
//Yes, testing intercepts on th X, Y, and X+Y individually has a purpose. It makes it far more stable and consistent.
|
||||
bool intersectX = false;
|
||||
Player.position.X += Player.velocity.X;
|
||||
if (Player.Hitbox.Intersects(npc.Hitbox))
|
||||
intersect = true;
|
||||
Player.position -= Player.velocity;
|
||||
}
|
||||
if (intersectX || intersect)
|
||||
{
|
||||
//This checks if the player is to the left of the pillar
|
||||
if (Player.Center.X < npc.Center.X)
|
||||
intersectX = true;
|
||||
Player.position.X -= Player.velocity.X;
|
||||
bool intersectY = false;
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
if (Player.Hitbox.Intersects(npc.Hitbox))
|
||||
intersectY = true;
|
||||
Player.position.Y -= Player.velocity.Y;
|
||||
bool intersect = false;
|
||||
//We only bother checking the X+Y together if individually they return false.
|
||||
//This accounts for moving diagonal onto a corner.
|
||||
if (!intersectX && !intersectY)
|
||||
{
|
||||
float playerEdge = Player.Hitbox.X + Player.Hitbox.Width;
|
||||
float pillarEdge = npc.Hitbox.X;
|
||||
float goalEdge = playerEdge + Player.velocity.X;
|
||||
if (goalEdge > pillarEdge)
|
||||
Player.position += Player.velocity;
|
||||
if (Player.Hitbox.Intersects(npc.Hitbox))
|
||||
intersect = true;
|
||||
Player.position -= Player.velocity;
|
||||
}
|
||||
if (intersectX || intersect)
|
||||
{
|
||||
//This checks if the player is to the left of the pillar
|
||||
if (Player.Center.X < npc.Center.X)
|
||||
{
|
||||
Player.velocity.X += pillarEdge - goalEdge;
|
||||
if (Player.velocity.X < 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.X += Player.velocity.X;
|
||||
Player.velocity.X = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.X = origX;
|
||||
}
|
||||
float playerEdge = Player.Hitbox.X + Player.Hitbox.Width;
|
||||
float pillarEdge = npc.Hitbox.X;
|
||||
float goalEdge = playerEdge + Player.velocity.X;
|
||||
if (goalEdge > pillarEdge)
|
||||
{
|
||||
Player.velocity.X += pillarEdge - goalEdge;
|
||||
if (Player.velocity.X < 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.X += Player.velocity.X;
|
||||
Player.velocity.X = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.X = origX;
|
||||
}
|
||||
}
|
||||
}
|
||||
//This is for if the player is to the right of the pillar
|
||||
else
|
||||
{
|
||||
float playerEdge = Player.Hitbox.X;
|
||||
float pillarEdge = npc.Hitbox.X + npc.Hitbox.Width;
|
||||
float goalEdge = playerEdge + Player.velocity.X;
|
||||
if (goalEdge < pillarEdge)
|
||||
{
|
||||
Player.velocity.X += pillarEdge - goalEdge;
|
||||
if (Player.velocity.X > 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.X += Player.velocity.X;
|
||||
Player.velocity.X = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.X = origX;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//This is for if the player is to the right of the pillar
|
||||
else
|
||||
//For the vertical axis, we don't distinguish between top and bottom, and always move players to the top
|
||||
//This is so being placed inside a pillar teleports a player to the top, which applies primarily to teleporting or pillar spawning
|
||||
//Additionally, this is set to only work when the pillar is stationary vertically to prevent janky interations when pillars are moving.
|
||||
if ((intersectY || intersect))
|
||||
{
|
||||
float playerEdge = Player.Hitbox.X;
|
||||
float pillarEdge = npc.Hitbox.X + npc.Hitbox.Width;
|
||||
float goalEdge = playerEdge + Player.velocity.X;
|
||||
if (goalEdge < pillarEdge)
|
||||
if (Player.Center.Y < npc.Center.Y)
|
||||
{
|
||||
Player.velocity.X += pillarEdge - goalEdge;
|
||||
if (Player.velocity.X > 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(Player.velocity.X, 0), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.X += Player.velocity.X;
|
||||
Player.velocity.X = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.X = origX;
|
||||
}
|
||||
float playerEdge = Player.Hitbox.Y + Player.Hitbox.Height;
|
||||
float pillarEdge = npc.Hitbox.Y;
|
||||
float goalEdge = playerEdge + Player.velocity.Y;
|
||||
if (goalEdge > pillarEdge)
|
||||
{
|
||||
Player.velocity.Y += pillarEdge - goalEdge;
|
||||
if (Player.velocity.Y < 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.Y = origY;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float playerEdge = Player.Hitbox.Y;
|
||||
float pillarEdge = npc.Hitbox.Y + npc.Hitbox.Height;
|
||||
float goalEdge = playerEdge + Player.velocity.Y;
|
||||
if (goalEdge < pillarEdge)
|
||||
{
|
||||
Player.velocity.Y += pillarEdge - goalEdge;
|
||||
if (Player.velocity.Y > 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.Y = origY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//For the vertical axis, we don't distinguish between top and bottom, and always move players to the top
|
||||
//This is so being placed inside a pillar teleports a player to the top, which applies primarily to teleporting or pillar spawning
|
||||
//Additionally, this is set to only work when the pillar is stationary vertically to prevent janky interations when pillars are moving.
|
||||
if ((intersectY || intersect) && npc.velocity.Y == 0)
|
||||
{
|
||||
if (Player.Center.Y < npc.Center.Y)
|
||||
//This is to guarantee we can stand on top of rock pillars instead of looking like we're "floating" on top of them.
|
||||
if (intersectY && Player.velocity.Y < 0.25f && Player.velocity.Y > -0.25f)
|
||||
{
|
||||
float playerEdge = Player.Hitbox.Y + Player.Hitbox.Height;
|
||||
float pillarEdge = npc.Hitbox.Y;
|
||||
float goalEdge = playerEdge + Player.velocity.Y;
|
||||
if (goalEdge > pillarEdge)
|
||||
{
|
||||
Player.velocity.Y += pillarEdge - goalEdge;
|
||||
if (Player.velocity.Y < 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.Y = origY;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
float playerEdge = Player.Hitbox.Y;
|
||||
float pillarEdge = npc.Hitbox.Y + npc.Hitbox.Height;
|
||||
float goalEdge = playerEdge + Player.velocity.Y;
|
||||
if (goalEdge < pillarEdge)
|
||||
{
|
||||
Player.velocity.Y += pillarEdge - goalEdge;
|
||||
if (Player.velocity.Y > 0)
|
||||
if (!Collision.SolidCollision(Player.position + new Vector2(0, Player.velocity.Y), Player.Hitbox.Width, Player.Hitbox.Height))
|
||||
{
|
||||
Player.position.Y += Player.velocity.Y;
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Player.velocity.Y = origY;
|
||||
}
|
||||
}
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
}
|
||||
//This is to guarantee we can stand on top of rock pillars instead of looking like we're "floating" on top of them.
|
||||
if (intersectY && Player.velocity.Y < 0.25f && Player.velocity.Y > -0.25f)
|
||||
{
|
||||
Player.velocity.Y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,7 +515,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
player = Main.player[NPC.target];
|
||||
|
||||
bool shouldFall = player.position.Y >= NPC.Bottom.Y;
|
||||
float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
|
||||
float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio);
|
||||
float velocityX = 4f + velocityXBoost;
|
||||
|
||||
if (velocityY != 16)
|
||||
@@ -548,13 +548,13 @@ namespace CalamityMod.NPCs.Ravager
|
||||
{
|
||||
velocityX *= 2f;
|
||||
if (!shouldFall)
|
||||
velocityY *= 0.5f;
|
||||
velocityY *= 0.75f;
|
||||
}
|
||||
else if (calamityGlobalNPC.newAI[0] % 2f == 0f)
|
||||
{
|
||||
velocityX *= 1.5f;
|
||||
if (!shouldFall)
|
||||
velocityY *= 0.75f;
|
||||
velocityY *= 1f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,11 +632,28 @@ namespace CalamityMod.NPCs.Ravager
|
||||
}
|
||||
|
||||
int spawnDistance = 360;
|
||||
{
|
||||
if (death && phase2)
|
||||
spawnDistance = 300;
|
||||
SoundEngine.PlaySound(PillarSound, NPC.Center);
|
||||
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X - spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType<RockPillar>());
|
||||
NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X + spawnDistance * 1.25f), (int)player.Center.Y - 100, ModContent.NPCType<RockPillar>());
|
||||
}
|
||||
|
||||
if (death && !leftClawActive && !rightClawActive)
|
||||
{
|
||||
|
||||
var index = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(player.Center.X), (int)player.Center.Y - spawnDistance - 100, ModContent.NPCType<RockPillar>());
|
||||
if (Main.npc.IndexInRange(index))
|
||||
{
|
||||
var npc = Main.npc[index];
|
||||
(int, int) H_W = (npc.height, npc.width);
|
||||
npc.position = npc.Center;
|
||||
npc.height = H_W.Item2;
|
||||
npc.width = H_W.Item1;
|
||||
npc.rotation = -MathHelper.PiOver2;
|
||||
npc.Center = npc.position;
|
||||
npc.ModNPC.DrawOffsetY = npc.width / 2 - npc.height / 2;
|
||||
}
|
||||
}
|
||||
if (!anyFlamePillars)
|
||||
{
|
||||
float distanceMultiplier = finalPhase ? 2.5f : 2f;
|
||||
@@ -708,7 +725,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
else
|
||||
calamityGlobalNPC.newAI[2] = player.direction;
|
||||
|
||||
float maxOffsetScale = death ? 320f : 240f;
|
||||
float maxOffsetScale = 240f;
|
||||
float maxOffset = maxOffsetScale * (1f - lifeRatio);
|
||||
float offset = phase2 ? maxOffset * calamityGlobalNPC.newAI[2] : 0f;
|
||||
int quarterWidth = (int)(NPC.width * 0.25f);
|
||||
@@ -750,7 +767,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
|
||||
if (NPC.Bottom.Y < player.position.Y)
|
||||
{
|
||||
float fallSpeedBoost = !anyHeadActive ? 0.9f : death ? 0.9f * (1f - lifeRatio) : 0.6f * (1f - lifeRatio);
|
||||
float fallSpeedBoost = !anyHeadActive ? 0.9f : 0.6f * (1f - lifeRatio);
|
||||
float fallSpeed = (bossRush ? 0.9f : 0.6f) + fallSpeedBoost;
|
||||
|
||||
if (calamityGlobalNPC.newAI[1] > 1f)
|
||||
@@ -765,7 +782,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
float velocityMult = bossRush ? 2f : 1.8f;
|
||||
float velocityXChange = 0.2f + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f;
|
||||
|
||||
float velocityXBoost = !anyHeadActive ? 6f : death ? 6f * (1f - lifeRatio) : 4f * (1f - lifeRatio);
|
||||
float velocityXBoost = !anyHeadActive ? 6f : 4f * (1f - lifeRatio);
|
||||
float velocityXCap = 8f + velocityXBoost + Math.Abs(NPC.Center.X - player.Center.X) * 0.001f;
|
||||
|
||||
if (!rightClawActive)
|
||||
|
||||
@@ -79,10 +79,6 @@ namespace CalamityMod.NPCs.Ravager
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive)
|
||||
NPC.damage = (int)(NPC.defDamage * 1.5);
|
||||
else
|
||||
NPC.damage = NPC.defDamage;
|
||||
}
|
||||
|
||||
if (NPC.ai[0] == 0)
|
||||
@@ -113,10 +109,14 @@ namespace CalamityMod.NPCs.Ravager
|
||||
}
|
||||
|
||||
NPC.noTileCollide = true;
|
||||
NPC.velocity.X = (BossRushEvent.BossRushActive ? 15 : 12) * NPC.direction;
|
||||
if (NPC.rotation == 0)
|
||||
NPC.velocity.X = (BossRushEvent.BossRushActive ? 15 : 12) * NPC.direction;
|
||||
NPC.velocity.Y = -28.5f;
|
||||
NPC.ai[0] = 1f;
|
||||
NPC.ai[1] = 0;
|
||||
NPC.damage = NPC.defDamage;
|
||||
if (DownedBossSystem.downedProvidence && !BossRushEvent.BossRushActive)
|
||||
NPC.damage = (int)(NPC.defDamage * 1.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace CalamityMod.NPCs.Ravager
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool? CanFallThroughPlatforms() => (NPC.alpha > 10) || (NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height);
|
||||
public override bool? CanFallThroughPlatforms() => NPC.ai[0] != 0 || ((NPC.alpha > 10) || (NPC.target >= 0 && Main.player[NPC.target].position.Y > NPC.position.Y + NPC.height));
|
||||
public override bool CheckActive() => false;
|
||||
|
||||
public override void OnHitPlayer(Player target, Player.HurtInfo hurtInfo)
|
||||
|
||||
Reference in new issue
Block a user