1 - Astral Altar generation hell fix.
2 - Perf edits.
This commit is contained in:
1 parent
ea1f426a53
commit
e75c5e8b0a
5 files changed
+312
-44
No files matched your search
@@ -524,6 +524,9 @@ namespace CalamityMod.NPCs.Perforator
|
||||
}
|
||||
}
|
||||
|
||||
if (NPC.Distance(player.Center) > 1280f)
|
||||
NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
|
||||
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
|
||||
|
||||
@@ -115,17 +115,23 @@ namespace CalamityMod.NPCs.Perforator
|
||||
if (!Main.player[NPC.target].ZoneCrimson || bossRush)
|
||||
enrageScale += 1f;
|
||||
|
||||
// Percent life remaining
|
||||
float lifeRatio = NPC.life / (float)NPC.lifeMax;
|
||||
// Total body segments
|
||||
float totalSegments = GetMediumPerforatorSegmentsCount();
|
||||
|
||||
float speed = 0.08f;
|
||||
float turnSpeed = 0.06f;
|
||||
// Count body segments remaining
|
||||
float segmentCount = NPC.CountNPCS(ModContent.NPCType<PerforatorBodyMedium>());
|
||||
|
||||
// Percent body segments remaining
|
||||
float lifeRatio = MathHelper.Clamp(segmentCount / totalSegments, 0f, 1f);
|
||||
|
||||
float speed = 0.1f;
|
||||
float turnSpeed = 0.08f;
|
||||
|
||||
if (expertMode)
|
||||
{
|
||||
float velocityScale = (death ? 0.08f : 0.07f) * enrageScale;
|
||||
float velocityScale = (death ? 0.07f : 0.05f) * enrageScale;
|
||||
speed += velocityScale * (1f - lifeRatio);
|
||||
float accelerationScale = (death ? 0.08f : 0.07f) * enrageScale;
|
||||
float accelerationScale = (death ? 0.07f : 0.05f) * enrageScale;
|
||||
turnSpeed += accelerationScale * (1f - lifeRatio);
|
||||
}
|
||||
|
||||
@@ -145,7 +151,6 @@ namespace CalamityMod.NPCs.Perforator
|
||||
{
|
||||
if (NPC.ai[0] == 0f)
|
||||
{
|
||||
int totalSegments = death ? 14 : revenge ? 13 : expertMode ? 12 : 10;
|
||||
NPC.ai[2] = totalSegments;
|
||||
NPC.ai[0] = NPC.NewNPC(NPC.GetSource_FromAI(), (int)(NPC.position.X + (NPC.width / 2)), (int)(NPC.position.Y + NPC.height), ModContent.NPCType<PerforatorBodyMedium>(), NPC.whoAmI);
|
||||
Main.npc[(int)NPC.ai[0]].ai[1] = NPC.whoAmI;
|
||||
@@ -433,6 +438,9 @@ namespace CalamityMod.NPCs.Perforator
|
||||
}
|
||||
}
|
||||
|
||||
if (NPC.Distance(player.Center) > 1280f)
|
||||
NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
|
||||
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
|
||||
@@ -484,6 +492,11 @@ namespace CalamityMod.NPCs.Perforator
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetMediumPerforatorSegmentsCount()
|
||||
{
|
||||
return CalamityWorld.LegendaryMode ? 20 : (CalamityWorld.death || BossRushEvent.BossRushActive) ? 14 : CalamityWorld.revenge ? 13 : Main.expertMode ? 12 : 10;
|
||||
}
|
||||
|
||||
public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor)
|
||||
{
|
||||
if (NPC.IsABestiaryIconDummy)
|
||||
|
||||
@@ -451,6 +451,9 @@ namespace CalamityMod.NPCs.Perforator
|
||||
}
|
||||
}
|
||||
|
||||
if (NPC.Distance(player.Center) > 1280f)
|
||||
NPC.velocity += (player.Center - NPC.Center).SafeNormalize(Vector2.UnitY) * turnSpeed;
|
||||
|
||||
// Calculate contact damage based on velocity
|
||||
float minimalContactDamageVelocity = maxChargeSpeed * 0.25f;
|
||||
float minimalDamageVelocity = maxChargeSpeed * 0.5f;
|
||||
|
||||
@@ -111,12 +111,18 @@ namespace CalamityMod.NPCs.Perforator
|
||||
{
|
||||
writer.Write(biomeEnrageTimer);
|
||||
writer.Write(wormsAlive);
|
||||
writer.Write(small);
|
||||
writer.Write(medium);
|
||||
writer.Write(large);
|
||||
}
|
||||
|
||||
public override void ReceiveExtraAI(BinaryReader reader)
|
||||
{
|
||||
biomeEnrageTimer = reader.ReadInt32();
|
||||
wormsAlive = reader.ReadInt32();
|
||||
small = reader.ReadBoolean();
|
||||
medium = reader.ReadBoolean();
|
||||
large = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
public override void AI()
|
||||
@@ -147,6 +153,7 @@ namespace CalamityMod.NPCs.Perforator
|
||||
|
||||
// Phases based on life percentage
|
||||
bool phase2 = lifeRatio < 0.7f;
|
||||
bool phase3 = lifeRatio < 0.4f && revenge;
|
||||
|
||||
// Enrage
|
||||
if ((!player.ZoneCrimson || (NPC.position.Y / 16f) < Main.worldSurface) && !bossRush)
|
||||
@@ -323,7 +330,7 @@ namespace CalamityMod.NPCs.Perforator
|
||||
// Emit ichor blobs
|
||||
if (phase2)
|
||||
{
|
||||
if (wormsAlive == 0 || bossRush || floatAboveToFireBlobs || (CalamityWorld.LegendaryMode && CalamityWorld.revenge))
|
||||
if (wormsAlive == 0 || large || bossRush || floatAboveToFireBlobs || (CalamityWorld.LegendaryMode && CalamityWorld.revenge))
|
||||
{
|
||||
NPC.ai[2] += 1f;
|
||||
if (NPC.ai[2] >= blobPhaseGateValue)
|
||||
@@ -354,27 +361,31 @@ namespace CalamityMod.NPCs.Perforator
|
||||
}
|
||||
}
|
||||
|
||||
int numBlobs = expertMode ? 6 : 3;
|
||||
bool ichorBlobBigWormPhase = wormsAlive > 0 && large;
|
||||
int numBlobs = expertMode ? (ichorBlobBigWormPhase ? 4 : 6) : (ichorBlobBigWormPhase ? 2 : 4);
|
||||
if (Main.getGoodWorld)
|
||||
numBlobs *= 2;
|
||||
|
||||
int type = ModContent.ProjectileType<IchorBlob>();
|
||||
int damage = NPC.GetProjectileDamage(type);
|
||||
|
||||
int blobSpread = expertMode ? (ichorBlobBigWormPhase ? 66 : 100) : (ichorBlobBigWormPhase ? 33 : 66);
|
||||
for (int i = 0; i < numBlobs; i++)
|
||||
{
|
||||
Vector2 blobVelocity = new Vector2(Main.rand.Next(-100, 101), Main.rand.Next(-100, 101));
|
||||
Vector2 blobVelocity = new Vector2(Main.rand.Next(-blobSpread, blobSpread + 1), Main.rand.Next(-blobSpread, blobSpread + 1));
|
||||
blobVelocity.Normalize();
|
||||
blobVelocity *= Main.rand.Next(400, 801) * (bossRush ? 0.02f : 0.01f);
|
||||
|
||||
if (CalamityWorld.LegendaryMode && CalamityWorld.revenge)
|
||||
blobVelocity *= Main.rand.NextFloat() + 1f;
|
||||
|
||||
float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.5f;
|
||||
float blobVelocityYAdd = Math.Abs(blobVelocity.Y) * 0.25f;
|
||||
if (blobVelocity.Y < 2f)
|
||||
blobVelocity.Y = 2f + blobVelocityYAdd;
|
||||
|
||||
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y);
|
||||
// Fall a bit further or shorter depending on which blob it is
|
||||
float fallFurtherDistance = 48f * (i - numBlobs / 2);
|
||||
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.UnitY * 50f, blobVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y + fallFurtherDistance);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,35 +413,31 @@ namespace CalamityMod.NPCs.Perforator
|
||||
|
||||
if (Main.netMode != NetmodeID.MultiplayerClient)
|
||||
{
|
||||
// Side mouth starts spitting when it opens (WIP)
|
||||
if (phase3)
|
||||
{
|
||||
NPC.localAI[2] += 1f;
|
||||
if (NPC.frame.Y / (TextureAssets.Npc[Type].Value.Height / Main.npcFrameCount[Type]) == 5 && NPC.localAI[2] >= 0f)
|
||||
{
|
||||
// Ensure it only spits once
|
||||
NPC.localAI[2] = -10f;
|
||||
|
||||
//SoundEngine.PlaySound(SoundID.Item17, );
|
||||
}
|
||||
}
|
||||
|
||||
NPC.localAI[0] += 1f;
|
||||
if (NPC.localAI[0] >= (revenge ? 200f : 250f) + wormsAlive * 150f && NPC.position.Y + NPC.height < player.position.Y && Vector2.Distance(player.Center, NPC.Center) > 80f)
|
||||
{
|
||||
NPC.localAI[0] = 0f;
|
||||
SoundEngine.PlaySound(GeyserShoot, NPC.Center);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
int ichorDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Ichor, 0f, 0f, 100, default, 1f);
|
||||
Main.dust[ichorDust].velocity *= 3f;
|
||||
if (Main.rand.NextBool())
|
||||
{
|
||||
Main.dust[ichorDust].scale = 0.25f;
|
||||
Main.dust[ichorDust].fadeIn = 1f + Main.rand.Next(10) * 0.1f;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < 16; j++)
|
||||
{
|
||||
int bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1.5f);
|
||||
Main.dust[bloodDust].noGravity = true;
|
||||
Main.dust[bloodDust].velocity *= 5f;
|
||||
bloodDust = Dust.NewDust(NPC.position, NPC.width, NPC.height, DustID.Blood, 0f, 0f, 100, default, 1f);
|
||||
Main.dust[bloodDust].velocity *= 2f;
|
||||
}
|
||||
|
||||
int type = Main.rand.NextBool() ? ModContent.ProjectileType<IchorShot>() : ModContent.ProjectileType<BloodGeyser>();
|
||||
bool ichor = Main.rand.NextBool();
|
||||
int type = ichor ? ModContent.ProjectileType<IchorShot>() : ModContent.ProjectileType<BloodGeyser>();
|
||||
int damage = NPC.GetProjectileDamage(type);
|
||||
int numProj = death ? 16 : revenge ? 14 : expertMode ? 12 : 10;
|
||||
if (phase3)
|
||||
numProj = death ? 12 : revenge ? 10 : expertMode ? 8 : 6;
|
||||
if (Main.getGoodWorld)
|
||||
numProj *= 2;
|
||||
|
||||
@@ -443,7 +450,31 @@ namespace CalamityMod.NPCs.Perforator
|
||||
{
|
||||
Vector2 perturbedSpeed = projectileVelocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (float)(numProj - 1)));
|
||||
Vector2 randomVelocity = new Vector2(Main.rand.NextFloat() - 0.5f, Main.rand.NextFloat() - 0.5f);
|
||||
Projectile.NewProjectile(NPC.GetSource_FromAI(), NPC.Center + Vector2.Normalize(perturbedSpeed) * 50f, perturbedSpeed + randomVelocity, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y);
|
||||
Vector2 projectileSpawnLocation = NPC.Center + Vector2.Normalize(perturbedSpeed) * 50f;
|
||||
Vector2 projectileVelocityRandomized = perturbedSpeed + randomVelocity;
|
||||
|
||||
if (ichor)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
int ichorDust = Dust.NewDust(NPC.position, 12, 12, DustID.Ichor);
|
||||
Main.dust[ichorDust].position = projectileSpawnLocation;
|
||||
Main.dust[ichorDust].velocity = projectileVelocityRandomized;
|
||||
Main.dust[ichorDust].scale = 1.4f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
int bloodDust = Dust.NewDust(NPC.position, 12, 12, DustID.Blood);
|
||||
Main.dust[bloodDust].position = projectileSpawnLocation;
|
||||
Main.dust[bloodDust].velocity = projectileVelocityRandomized;
|
||||
Main.dust[bloodDust].scale = 1.4f;
|
||||
}
|
||||
}
|
||||
|
||||
Projectile.NewProjectile(NPC.GetSource_FromAI(), projectileSpawnLocation, projectileVelocityRandomized, type, damage, 0f, Main.myPlayer, 0f, player.Center.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+228
-10
@@ -455,32 +455,250 @@ namespace CalamityMod.World
|
||||
if (j < 181)
|
||||
j = 181;
|
||||
|
||||
int xOffset = GenVars.dungeonX < Main.maxTilesX / 2 ? WorldGen.genRand.Next(-100, -50) : WorldGen.genRand.Next(50, 100);
|
||||
IList<ushort> AstralTilesToCheckFor = new List<ushort>(16);
|
||||
int[] AstralTiles = new int[]
|
||||
{
|
||||
ModContent.TileType<AstralSand>(),
|
||||
ModContent.TileType<AstralSandstone>(),
|
||||
ModContent.TileType<HardenedAstralSand>(),
|
||||
ModContent.TileType<CelestialRemains>(),
|
||||
ModContent.TileType<AstralIce>(),
|
||||
ModContent.TileType<AstralSnow>(),
|
||||
ModContent.TileType<AstralDirt>(),
|
||||
ModContent.TileType<AstralStone>(),
|
||||
ModContent.TileType<AstralGrass>(),
|
||||
ModContent.TileType<AstralOre>(),
|
||||
ModContent.TileType<NovaeSlag>(),
|
||||
ModContent.TileType<AstralClay>(),
|
||||
};
|
||||
foreach (int modTile in AstralTiles)
|
||||
AstralTilesToCheckFor.Add((ushort)modTile);
|
||||
|
||||
bool altarPlaced = false;
|
||||
int altarX = i + (GenVars.dungeonX < Main.maxTilesX / 2 ? -50 : 50);
|
||||
int altarY = j - 5;
|
||||
|
||||
// Variables used for checking both the bottom and top of the potential altar location
|
||||
int distanceToCheckForAstralTilesX = 40;
|
||||
int distanceToCheckForAstralTilesY = 10;
|
||||
int startCheckingX = altarX - 20;
|
||||
int startCheckingY = altarY + 10;
|
||||
int startCheckingY2 = altarY - 25;
|
||||
|
||||
// Variables used for checking the bottom of the potential altar location
|
||||
int astralTilesRequired = 200;
|
||||
int emptyTilesRequiredToMove = 200;
|
||||
|
||||
// Variables used for checking the top of the potential altar location
|
||||
int emptyTilesRequired = 200;
|
||||
|
||||
// Whether Magic Storage tiles need to be looked for
|
||||
bool needsToCheckForMSTiles = magicStorage is not null;
|
||||
|
||||
// Variables used for checking the entire potential altar location for critical tiles like chests, torches, etc.
|
||||
int distanceToCheckForCriticalTilesX = 40;
|
||||
int distanceToCheckForCriticalTilesY = 50;
|
||||
|
||||
int attempts = 0;
|
||||
int maxAttempts = 10000;
|
||||
while (!altarPlaced)
|
||||
{
|
||||
WorldGen.gen = true;
|
||||
|
||||
int x = i + xOffset;
|
||||
int y = j - 100;
|
||||
|
||||
while (!WorldGen.SolidTile(x, y) && y <= Main.worldSurface)
|
||||
// Check if there are enough Astral tiles on the bottom of the altar's gen location
|
||||
// 400 tiles checked in total
|
||||
int astralTileCount = 0;
|
||||
bool enoughAstralTilesOnBottom = false;
|
||||
for (int astralTileCheckIndexX = startCheckingX; astralTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; astralTileCheckIndexX++)
|
||||
{
|
||||
y += 5;
|
||||
if (enoughAstralTilesOnBottom)
|
||||
break;
|
||||
|
||||
for (int astralTileCheckIndexY = startCheckingY; astralTileCheckIndexY < startCheckingY + distanceToCheckForAstralTilesY; astralTileCheckIndexY++)
|
||||
{
|
||||
if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY] != null)
|
||||
{
|
||||
if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].HasTile)
|
||||
{
|
||||
if (AstralTilesToCheckFor.Contains(Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].TileType))
|
||||
{
|
||||
astralTileCount++;
|
||||
if (astralTileCount >= astralTilesRequired)
|
||||
{
|
||||
enoughAstralTilesOnBottom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Main.tile[x, y].HasTile || Main.tile[x, y].WallType > 0 && !TileID.Sets.Torch[Main.tile[x, y].TileType] && !TileID.Sets.IsAContainer[Main.tile[x, y].TileType]
|
||||
&& (magicStorage is not null && MSTilesToAvoid.Contains(Main.tile[x, y].TileType))) //AVOID HOUSES
|
||||
// Check if there are too many empty tiles on the bottom of the altar's gen location
|
||||
// 400 tiles checked in total
|
||||
int emptyTileCount = 0;
|
||||
bool tooManyEmptyTilesOnBottom = false;
|
||||
for (int astralTileCheckIndexX = startCheckingX; astralTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; astralTileCheckIndexX++)
|
||||
{
|
||||
if (tooManyEmptyTilesOnBottom)
|
||||
break;
|
||||
|
||||
bool place = true;
|
||||
SchematicManager.PlaceSchematic<Action<Chest>>(SchematicManager.AstralBeaconKey, new Point(x, y - 5), SchematicAnchor.Center, ref place);
|
||||
for (int astralTileCheckIndexY = startCheckingY; astralTileCheckIndexY < startCheckingY + distanceToCheckForAstralTilesY; astralTileCheckIndexY++)
|
||||
{
|
||||
if (Main.tile[astralTileCheckIndexX, astralTileCheckIndexY] == null || !Main.tile[astralTileCheckIndexX, astralTileCheckIndexY].HasTile)
|
||||
{
|
||||
emptyTileCount++;
|
||||
if (emptyTileCount >= emptyTilesRequiredToMove)
|
||||
{
|
||||
tooManyEmptyTilesOnBottom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for the number of empty tiles on the top of the altar's gen location
|
||||
// 800 tiles checked in total
|
||||
int emptyTileCount2 = 0;
|
||||
bool enoughEmptyTilesOnTop = false;
|
||||
for (int emptyTileCheckIndexX = startCheckingX; emptyTileCheckIndexX < startCheckingX + distanceToCheckForAstralTilesX; emptyTileCheckIndexX++)
|
||||
{
|
||||
if (enoughEmptyTilesOnTop)
|
||||
break;
|
||||
|
||||
for (int emptyTileCheckIndexY = startCheckingY2; emptyTileCheckIndexY < startCheckingY2 + distanceToCheckForAstralTilesY; emptyTileCheckIndexY++)
|
||||
{
|
||||
if (Main.tile[emptyTileCheckIndexX, emptyTileCheckIndexY] == null || !Main.tile[emptyTileCheckIndexX, emptyTileCheckIndexY].HasTile)
|
||||
{
|
||||
emptyTileCount2++;
|
||||
if (emptyTileCount2 >= emptyTilesRequired)
|
||||
{
|
||||
enoughEmptyTilesOnTop = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for houses and other critical bullshit
|
||||
// 2000 tiles checked in total
|
||||
bool criticalTileDetected = false;
|
||||
for (int criticalTileCheckIndexX = startCheckingX; criticalTileCheckIndexX < startCheckingX + distanceToCheckForCriticalTilesX; criticalTileCheckIndexX++)
|
||||
{
|
||||
if (criticalTileDetected)
|
||||
break;
|
||||
|
||||
for (int criticalTileCheckIndexY = startCheckingY2; criticalTileCheckIndexY < startCheckingY2 + distanceToCheckForCriticalTilesY; criticalTileCheckIndexY++)
|
||||
{
|
||||
if (Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY] != null)
|
||||
{
|
||||
if (Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].HasTile)
|
||||
{
|
||||
if (needsToCheckForMSTiles)
|
||||
{
|
||||
if (TileID.Sets.Clock[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.Paintings[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.InteractibleByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.CanBeSleptIn[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.AvoidedByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.IsAContainer[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
MSTilesToAvoid.Contains(Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType))
|
||||
{
|
||||
criticalTileDetected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (TileID.Sets.Clock[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.Paintings[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.InteractibleByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.CanBeSleptIn[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.AvoidedByNPCs[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType] ||
|
||||
TileID.Sets.IsAContainer[Main.tile[criticalTileCheckIndexX, criticalTileCheckIndexY].TileType])
|
||||
{
|
||||
criticalTileDetected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool canPlaceAltar = enoughAstralTilesOnBottom && !tooManyEmptyTilesOnBottom && enoughEmptyTilesOnTop && !criticalTileDetected;
|
||||
|
||||
if (canPlaceAltar)
|
||||
{
|
||||
SchematicManager.PlaceSchematic<Action<Chest>>(SchematicManager.AstralBeaconKey, new Point(altarX, altarY), SchematicAnchor.Center, ref canPlaceAltar);
|
||||
|
||||
WorldGen.gen = false;
|
||||
|
||||
altarPlaced = true;
|
||||
}
|
||||
|
||||
// Move the location if the requirements are not met and check again
|
||||
else
|
||||
{
|
||||
altarX += 5;
|
||||
if (altarX >= i + 150)
|
||||
altarX -= 300;
|
||||
|
||||
if (!enoughEmptyTilesOnTop)
|
||||
altarY -= 5;
|
||||
else if (tooManyEmptyTilesOnBottom)
|
||||
altarY += 5;
|
||||
|
||||
if (altarY <= Main.worldSurface - 150)
|
||||
altarY += 150;
|
||||
else if (altarY >= Main.worldSurface + 150)
|
||||
altarY -= 150;
|
||||
|
||||
attempts++;
|
||||
if (attempts >= maxAttempts)
|
||||
{
|
||||
// If all else fails, place the fucking thing anyway, by using the original code :^)
|
||||
int altarX2 = i;
|
||||
int altarY2 = j - 50;
|
||||
bool forcedPlacedAltar = false;
|
||||
while (!forcedPlacedAltar)
|
||||
{
|
||||
while (!WorldGen.SolidTile(altarX2, altarY2 + 15) && altarY2 + 15 <= Main.worldSurface)
|
||||
altarY2 += 5;
|
||||
|
||||
bool canPlaceAltar2 = false;
|
||||
if (needsToCheckForMSTiles)
|
||||
{
|
||||
canPlaceAltar2 = !TileID.Sets.Clock[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.Paintings[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.InteractibleByNPCs[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.CanBeSleptIn[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.AvoidedByNPCs[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.IsAContainer[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!MSTilesToAvoid.Contains(Main.tile[altarX2, altarY2].TileType);
|
||||
}
|
||||
else
|
||||
{
|
||||
canPlaceAltar2 = !TileID.Sets.Clock[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.Paintings[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.InteractibleByNPCs[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.CanBeSleptIn[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.AvoidedByNPCs[Main.tile[altarX2, altarY2].TileType] &&
|
||||
!TileID.Sets.IsAContainer[Main.tile[altarX2, altarY2].TileType];
|
||||
}
|
||||
|
||||
if (canPlaceAltar2)
|
||||
{
|
||||
SchematicManager.PlaceSchematic<Action<Chest>>(SchematicManager.AstralBeaconKey, new Point(altarX2, altarY2), SchematicAnchor.Center, ref canPlaceAltar2);
|
||||
|
||||
WorldGen.gen = false;
|
||||
|
||||
forcedPlacedAltar = true;
|
||||
altarPlaced = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user