a few small worldgen fixes, also funny snail

This commit is contained in:
Mortis3 committed 2023-01-30 21:17:36 -05:00
1 parent 4484753a80
commit eb23f15f9a
14 files changed
+501 -18

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
using CalamityMod.Projectiles.Pets;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ModLoader;
namespace CalamityMod.Buffs.Pets
{
public class EidolonSnailBuff : ModBuff
{
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Escargidolon Snail");
Description.SetDefault("It probably doesn't taste good, but is very friendly!");
Main.buffNoTimeDisplay[Type] = true;
Main.vanityPet[Type] = true;
}
public override void Update(Player player, ref int buffIndex)
{
player.buffTime[buffIndex] = 18000;
player.Calamity().eidolonSnailPet = true;
bool PetProjectileNotSpawned = player.ownedProjectileCounts[ModContent.ProjectileType<EidolonSnail>()] <= 0;
if (PetProjectileNotSpawned && player.whoAmI == Main.myPlayer)
{
Projectile.NewProjectile(player.GetSource_Buff(buffIndex), player.Center, Vector2.Zero, ModContent.ProjectileType<EidolonSnail>(), 0, 0f, player.whoAmI);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

+2
View File
@@ -327,6 +327,7 @@ namespace CalamityMod.CalPlayer
public bool bendyPet = false;
public bool littleLightPet = false;
public bool pineapplePet = false;
public bool eidolonSnailPet = false;
#endregion
#region Rage
@@ -1477,6 +1478,7 @@ namespace CalamityMod.CalPlayer
bendyPet = false;
littleLightPet = false;
pineapplePet = false;
eidolonSnailPet = false;
onyxExcavator = false;
rimehound = false;
+48
View File
@@ -0,0 +1,48 @@
using CalamityMod.Buffs.Pets;
using CalamityMod.Projectiles.Pets;
using CalamityMod.Rarities;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Items.Pets
{
public class AbyssShellFossil : ModItem
{
public override void SetStaticDefaults()
{
SacrificeTotal = 1;
DisplayName.SetDefault("Abyss Shell Fossil");
Tooltip.SetDefault("A fossil of a prehistoric creature, long forgotten in the deep abyss"
+ "\nSummons an Escargidolon Snail pet");
}
public override void SetDefaults()
{
Item.damage = 0;
Item.width = 42;
Item.height = 30;
Item.useAnimation = 20;
Item.useTime = 20;
Item.useStyle = ItemUseStyleID.Swing;
Item.noMelee = true;
Item.value = Item.sellPrice(platinum: 1);
Item.rare = ModContent.RarityType<DarkBlue>();
Item.Calamity().devItem = true;
Item.shoot = ModContent.ProjectileType<EidolonSnail>();
Item.buffType = ModContent.BuffType<EidolonSnailBuff>();
Item.UseSound = SoundID.Item2;
}
public override void UseStyle(Player player, Rectangle heldItemFrame)
{
if (player.whoAmI == Main.myPlayer && player.itemTime == 0)
{
player.AddBuff(Item.buffType, 15, true);
}
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

+333
View File
@@ -0,0 +1,333 @@
using CalamityMod.CalPlayer;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria;
using Terraria.ModLoader;
using System;
namespace CalamityMod.Projectiles.Pets
{
public class EidolonSnail : ModProjectile
{
private int playerStill = 0;
private bool fly = false;
private int idleTimer = 0;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Escargidolon Snail");
Main.projFrames[Projectile.type] = 8;
Main.projPet[Projectile.type] = true;
}
public override void SetDefaults()
{
Projectile.netImportant = true;
Projectile.width = 54;
Projectile.height = 38;
Projectile.friendly = true;
Projectile.penetrate = -1;
Projectile.timeLeft *= 5;
Projectile.tileCollide = true;
Projectile.ignoreWater = true;
}
public override bool PreDraw(ref Color lightColor)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Pets/EidolonSnail").Value;
int height = texture.Height / Main.projFrames[Projectile.type];
int frameHeight = height * Projectile.frame;
SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY + 2),
new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), lightColor,
Projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), Projectile.scale, spriteEffects, 0);
return false;
}
public override void PostDraw(Color lightColor)
{
Texture2D texture = ModContent.Request<Texture2D>("CalamityMod/Projectiles/Pets/EidolonSnailGlow").Value;
int height = texture.Height / Main.projFrames[Projectile.type];
int frameHeight = height * Projectile.frame;
SpriteEffects spriteEffects = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY + 2),
new Microsoft.Xna.Framework.Rectangle?(new Rectangle(0, frameHeight, texture.Width, height)), Color.White,
Projectile.rotation, new Vector2(texture.Width / 2f, height / 2f), Projectile.scale, spriteEffects, 0);
}
public override bool TileCollideStyle(ref int width, ref int height, ref bool fallThrough, ref Vector2 hitboxCenterFrac)
{
Player player = Main.player[Projectile.owner];
Vector2 center2 = Projectile.Center;
Vector2 vector48 = player.Center - center2;
float playerDistance = vector48.Length();
fallThrough = playerDistance > 200f;
return true;
}
public override void AI()
{
Player player = Main.player[Projectile.owner];
if (!player.active)
{
Projectile.active = false;
return;
}
CalamityPlayer modPlayer = player.Calamity();
if (player.dead)
{
modPlayer.eidolonSnailPet = false;
}
if (modPlayer.eidolonSnailPet)
{
Projectile.timeLeft = 2;
}
Vector2 vector46 = Projectile.position;
if (!fly)
{
Projectile.rotation = 0;
Vector2 center2 = Projectile.Center;
Vector2 vector48 = player.Center - center2;
float playerDistance = vector48.Length();
if (Projectile.velocity.Y == 0 && (HoleBelow() || (playerDistance > 110f && Projectile.position.X == Projectile.oldPosition.X)))
{
Projectile.velocity.Y = -8f;
}
Projectile.velocity.Y += 0.35f;
if (Projectile.velocity.Y > 15f)
{
Projectile.velocity.Y = 15f;
}
if (playerDistance > 600f)
{
fly = true;
Projectile.velocity.X = 0f;
Projectile.velocity.Y = 0f;
}
if (playerDistance > 100f)
{
if (player.position.X - Projectile.position.X > 0f)
{
Projectile.velocity.X += 0.10f;
if (Projectile.velocity.X > 5f)
{
Projectile.velocity.X = 5f;
}
}
else
{
Projectile.velocity.X -= 0.10f;
if (Projectile.velocity.X < -5f)
{
Projectile.velocity.X = -5f;
}
}
}
if (playerDistance < 100f)
{
if (Projectile.velocity.X != 0f)
{
if (Projectile.velocity.X > 0.8f)
{
Projectile.velocity.X -= 0.25f;
}
else if (Projectile.velocity.X < -0.8f)
{
Projectile.velocity.X += 0.25f;
}
else if (Projectile.velocity.X < 0.8f && Projectile.velocity.X > -0.8f)
{
Projectile.velocity.X = 0f;
}
}
}
if (playerDistance < 70f)
{
Projectile.velocity.X *= 0.5f;
}
//set frames when idle
if (Projectile.position.X == Projectile.oldPosition.X && Projectile.position.Y == Projectile.oldPosition.Y && Projectile.velocity.X == 0)
{
Projectile.frame = 0;
Projectile.frameCounter = 0;
}
//falling frame
if (Projectile.velocity.Y > 0.3f && Projectile.position.Y != Projectile.oldPosition.Y)
{
Projectile.frame = 4;
Projectile.frameCounter = 0;
}
else
{
//moving animation
Projectile.frameCounter++;
if (Projectile.frameCounter > 2)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 4)
{
Projectile.frame = 1;
}
}
if (Projectile.velocity.X > 0.8f)
{
Projectile.spriteDirection = 1;
}
else if (Projectile.velocity.X < -0.8f)
{
Projectile.spriteDirection = -1;
}
}
else if (fly)
{
float num16 = 0.5f;
Projectile.tileCollide = false;
Vector2 vector3 = new Vector2(Projectile.position.X + (float)Projectile.width * 0.5f, Projectile.position.Y + (float)Projectile.height * 0.5f);
float horiPos = Main.player[Projectile.owner].position.X + (float)(Main.player[Projectile.owner].width / 2) - vector3.X;
float vertiPos = Main.player[Projectile.owner].position.Y + (float)(Main.player[Projectile.owner].height / 2) - vector3.Y;
vertiPos += (float)Main.rand.Next(-10, 21);
horiPos += (float)Main.rand.Next(-10, 21);
horiPos += (float)(60 * -(float)player.direction);
vertiPos -= 60f;
float playerDistance = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos));
float num21 = 18f;
float num27 = (float)Math.Sqrt((double)(horiPos * horiPos + vertiPos * vertiPos));
if (playerDistance > 1200f)
{
Projectile.position.X = player.Center.X - (float)(Projectile.width / 2);
Projectile.position.Y = player.Center.Y - (float)(Projectile.height / 2);
Projectile.netUpdate = true;
}
if (playerDistance < 100f)
{
num16 = 0.5f;
if (player.velocity.Y == 0f)
{
++playerStill;
}
else
{
playerStill = 0;
}
if (playerStill > 10 && !Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height))
{
fly = false;
Projectile.velocity *= 0.2f;
Projectile.tileCollide = true;
}
}
if (playerDistance < 50f)
{
if (Math.Abs(Projectile.velocity.X) > 2f || Math.Abs(Projectile.velocity.Y) > 2f)
{
Projectile.velocity *= 0.90f;
}
num16 = 0.02f;
}
else
{
if (playerDistance < 100f)
{
num16 = 0.35f;
}
if (playerDistance > 300f)
{
num16 = 1f;
}
playerDistance = num21 / playerDistance;
horiPos *= playerDistance;
vertiPos *= playerDistance;
}
if (Projectile.velocity.X <= horiPos)
{
Projectile.velocity.X = Projectile.velocity.X + num16;
if (num16 > 0.05f && Projectile.velocity.X < 0f)
{
Projectile.velocity.X = Projectile.velocity.X + num16;
}
}
if (Projectile.velocity.X > horiPos)
{
Projectile.velocity.X = Projectile.velocity.X - num16;
if (num16 > 0.05f && Projectile.velocity.X > 0f)
{
Projectile.velocity.X = Projectile.velocity.X - num16;
}
}
if (Projectile.velocity.Y <= vertiPos)
{
Projectile.velocity.Y = Projectile.velocity.Y + num16;
if (num16 > 0.05f && Projectile.velocity.Y < 0f)
{
Projectile.velocity.Y = Projectile.velocity.Y + num16 * 2f;
}
}
if (Projectile.velocity.Y > vertiPos)
{
Projectile.velocity.Y = Projectile.velocity.Y - num16;
if (num16 > 0.05f && Projectile.velocity.Y > 0f)
{
Projectile.velocity.Y = Projectile.velocity.Y - num16 * 2f;
}
}
Projectile.rotation += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction;
if (Projectile.Center.X < Main.player[Projectile.owner].Center.X)
{
Projectile.spriteDirection = 1;
}
else if (Projectile.Center.X > Main.player[Projectile.owner].Center.X)
{
Projectile.spriteDirection = -1;
}
//funny flying animation
Projectile.frameCounter++;
if (Projectile.frameCounter > 3)
{
Projectile.frame++;
Projectile.frameCounter = 0;
}
if (Projectile.frame > 7)
{
Projectile.frame = 5;
}
idleTimer = 0;
}
}
private bool HoleBelow()
{
int tileWidth = 4;
int tileX = (int)(Projectile.Center.X / 16f) - tileWidth;
if (Projectile.velocity.X > 0)
{
tileX += tileWidth;
}
int tileY = (int)((Projectile.position.Y + Projectile.height) / 16f);
for (int y = tileY; y < tileY + 2; y++)
{
for (int x = tileX; x < tileX + tileWidth; x++)
{
if (Main.tile[x, y].HasTile)
{
return false;
}
}
}
return true;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

+35
View File
@@ -0,0 +1,35 @@
using CalamityMod.Items.Fishing.SulphurCatches;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.DataStructures;
using Terraria.ModLoader;
using Terraria.ObjectData;
namespace CalamityMod.Tiles.Abyss
{
public class AbyssFossilTile : ModTile
{
public override void SetStaticDefaults()
{
Main.tileLighted[Type] = true;
Main.tileFrameImportant[Type] = true;
Main.tileLavaDeath[Type] = true;
Main.tileWaterDeath[Type] = false;
TileObjectData.newTile.CopyFrom(TileObjectData.Style3x2);
TileObjectData.addTile(Type);
AddMapEntry(new Color(29, 37, 58));
DustType = 33;
}
public override void NumDust(int i, int j, bool fail, ref int num)
{
num = fail ? 1 : 3;
}
public override void KillMultiTile(int i, int j, int frameX, int frameY)
{
Item.NewItem(new EntitySource_TileBreak(i, j), i * 16, j * 16, 16, 32, ModContent.ItemType<Items.Pets.AbyssShellFossil>());
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 969 B

+34 -9
View File
@@ -283,7 +283,36 @@ namespace CalamityMod.World
// Place the Terminus shrine.
UndergroundShrines.SpecialHut((ushort)ModContent.TileType<SmoothVoidstone>(), (ushort)ModContent.TileType<Voidstone>(),
(ushort)ModContent.WallType<VoidstoneWallUnsafe>(), UndergroundShrines.UndergroundShrineType.Abyss, abyssChasmX, AbyssChasmBottom);
(ushort)ModContent.WallType<VoidstoneWallUnsafe>(), UndergroundShrines.UndergroundShrineType.Abyss, abyssChasmX, AbyssChasmBottom);
//place eidolon snail fossil
int realFossilY = 0;
bool placedFossil = false;
while (!placedFossil)
{
//make sure it places at the very bottom, below where the terminus shrine is
for (int fossilCheckY = AbyssChasmBottom + 30; fossilCheckY < AbyssChasmBottom + 100; fossilCheckY++)
{
if (Main.tile[abyssChasmX, fossilCheckY].HasTile && Main.tile[abyssChasmX, fossilCheckY].TileType == ModContent.TileType<Voidstone>())
{
realFossilY = fossilCheckY;
//place a box of voidstone for the fossil to spawn on
for (int fossilX = abyssChasmX - 3; fossilX <= abyssChasmX + 3; fossilX++)
{
for (int fossilY = realFossilY - 2; fossilY <= realFossilY + 3; fossilY++)
{
WorldGen.PlaceTile(fossilX, fossilY, ModContent.TileType<Voidstone>());
}
}
WorldGen.PlaceObject(abyssChasmX, realFossilY - 3, (ushort)ModContent.TileType<AbyssFossilTile>());
placedFossil = true;
}
}
}
int islandLocationOffset = 30;
int islandLocationY = rockLayer;
@@ -355,8 +384,7 @@ namespace CalamityMod.World
//pots
if (!Main.tile[abyssIndex, abyssIndex2].HasTile)
{
if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) &&
abyssIndex2 > rockLayer)
if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && abyssIndex2 > rockLayer)
{
if (WorldGen.genRand.NextBool(5))
{
@@ -364,8 +392,7 @@ namespace CalamityMod.World
CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true);
}
}
else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) &&
abyssIndex2 < (int)Main.worldSurface)
else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && abyssIndex2 < (int)Main.worldSurface)
{
if (WorldGen.genRand.NextBool(3))
{
@@ -386,8 +413,7 @@ namespace CalamityMod.World
//pots
if (!Main.tile[abyssIndex, abyssIndex2].HasTile)
{
if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) &&
abyssIndex2 > rockLayer)
if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && abyssIndex2 > rockLayer)
{
if (WorldGen.genRand.NextBool(5))
{
@@ -395,8 +421,7 @@ namespace CalamityMod.World
CalamityUtils.SafeSquareTileFrame(abyssIndex, abyssIndex2, true);
}
}
else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) &&
abyssIndex2 < (int)Main.worldSurface)
else if (WorldGen.SolidTile(abyssIndex, abyssIndex2 + 1) && abyssIndex2 < (int)Main.worldSurface)
{
if (WorldGen.genRand.NextBool(3))
{
+4 -2
View File
@@ -127,11 +127,13 @@ namespace CalamityMod.World
{
float worldEdgeMargin = (float)Main.maxTilesX * 0.08f;
int xLimit = Main.maxTilesX / 2;
int x = Abyss.AtLeftSideOfWorld ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400);
int x = Abyss.AtLeftSideOfWorld ? rand.Next(700, xLimit) : rand.Next(xLimit, Main.maxTilesX - 700);
/*
while ((float)x > (float)Main.spawnTileX - worldEdgeMargin && (float)x < (float)Main.spawnTileX + worldEdgeMargin)
{
x = Abyss.AtLeftSideOfWorld ? rand.Next(400, xLimit) : rand.Next(xLimit, Main.maxTilesX - 400);
x = Abyss.AtLeftSideOfWorld ? rand.Next(600, xLimit) : rand.Next(xLimit, Main.maxTilesX - 600);
}
*/
//world surface = 920 large 740 medium 560 small
int y = (int)(Main.worldSurface * 0.5); //Large = 522, Medium = 444, Small = 336
while (y < Main.maxTilesY)
+2 -6
View File
@@ -119,10 +119,6 @@ namespace CalamityMod.World
int radius = extraWidth - 1;
WorldUtils.Gen(new Point(origin.X + 2, y), new Shapes.Circle(radius), Actions.Chain(new GenAction[]
{
blotchMod.Output(circle)
}));
WorldUtils.Gen(new Point(origin.X + 2, y), new Shapes.Circle(radius), Actions.Chain(new GenAction[]
{
blotchMod.Output(circle)
@@ -142,10 +138,10 @@ namespace CalamityMod.World
//chance to place blocks inside the tree for randomness
if (WorldGen.genRand.Next(20) == 0)
{
WorldUtils.Gen(new Point(origin.X + WorldGen.genRand.Next(-2, 2), y), new ModShapes.All(tinyCircle), Actions.Chain(new GenAction[]
WorldUtils.Gen(new Point(origin.X + WorldGen.genRand.Next(-2, 2), y), new ModShapes.All(circle), Actions.Chain(new GenAction[]
{
new Actions.ClearTile(),
new Actions.PlaceWall(WallID.LivingWood)
new Actions.PlaceTile(TileID.LivingMahogany)
}));
}
+13 -1
View File
@@ -102,7 +102,9 @@ namespace CalamityMod.World
}
}
if (!canGenerateInLocation || corruptStuffInArea < totalTiles * 0.5f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;
@@ -172,7 +174,9 @@ namespace CalamityMod.World
}
}
if (!canGenerateInLocation || crimsonStuffInArea < totalTiles * 0.5f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;
@@ -236,7 +240,9 @@ namespace CalamityMod.World
}
}
if (!canGenerateInLocation || desertTilesInArea < totalTiles * 0.3f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;
@@ -299,7 +305,9 @@ namespace CalamityMod.World
}
}
if (!canGenerateInLocation || graniteWallsInArea < totalTiles * 0.95f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;
@@ -364,8 +372,10 @@ namespace CalamityMod.World
iceTilesInArea++;
}
}
if (!canGenerateInLocation || iceTilesInArea < totalTiles * 0.35f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
if (!canGenerateInLocation || iceTilesInArea < totalTiles * 0.2f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;
@@ -437,7 +447,9 @@ namespace CalamityMod.World
}
if (!canGenerateInLocation || marbleStuffInArea < totalTiles * 0.9f || airTilesBetweenPillar < totalTiles * 0.3f || !structures.CanPlace(new Rectangle(placementPoint.X, placementPoint.Y, (int)schematicSize.X, (int)schematicSize.Y)))
{
tries++;
}
else
{
bool _ = true;