From ea1f4d4fbc5debe4aee5a656f6c1aef2da7688bf Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 19 Jun 2022 00:34:10 -0500 Subject: [PATCH 01/20] Added old Puff Shroom code of mine --- Buffs/Summon/PuffWarriorBuff.cs | 33 +++++ Buffs/Summon/PuffWarriorBuff.png | Bin 0 -> 576 bytes CalPlayer/CalamityPlayer.cs | 2 + Items/Weapons/Summon/PuffShroom.cs | 48 ++++++++ Items/Weapons/Summon/PuffShroom.png | Bin 0 -> 576 bytes Projectiles/Summon/PuffCloud.cs | 43 +++++++ Projectiles/Summon/PuffCloud.png | Bin 0 -> 945 bytes Projectiles/Summon/PuffWarrior.cs | 184 ++++++++++++++++++++++++++++ Projectiles/Summon/PuffWarrior.png | Bin 0 -> 2339 bytes 9 files changed, 310 insertions(+) create mode 100644 Buffs/Summon/PuffWarriorBuff.cs create mode 100644 Buffs/Summon/PuffWarriorBuff.png create mode 100644 Items/Weapons/Summon/PuffShroom.cs create mode 100644 Items/Weapons/Summon/PuffShroom.png create mode 100644 Projectiles/Summon/PuffCloud.cs create mode 100644 Projectiles/Summon/PuffCloud.png create mode 100644 Projectiles/Summon/PuffWarrior.cs create mode 100644 Projectiles/Summon/PuffWarrior.png diff --git a/Buffs/Summon/PuffWarriorBuff.cs b/Buffs/Summon/PuffWarriorBuff.cs new file mode 100644 index 0000000000..4d02def7b0 --- /dev/null +++ b/Buffs/Summon/PuffWarriorBuff.cs @@ -0,0 +1,33 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class PuffWarriorBuff : ModBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Puff Warrior"); + Description.SetDefault("It confidently and excitedly protects you"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.puffWarrior = true; + + if (modPlayer.puffWarrior) + player.buffTime[buffIndex] = 18000; + else + { + player.DelBuff(buffIndex); + buffIndex--; + } + } + } +} diff --git a/Buffs/Summon/PuffWarriorBuff.png b/Buffs/Summon/PuffWarriorBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..354a7cfa73a69c0bf50d1e8ec4f1c11f9276f7e5 GIT binary patch literal 576 zcmV-G0>AxPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0o6%FK~z{r&6hn$ zLQx#WwYFONaFT++GDK(!qK~;~5F3KTAjp=2f}jtYBAOe5f&z&)F=!Eos4b{OXbR-v zBOx$^NUEiVK&tz{_eAeck5>?OfABbe2lbxw&b|8F{`MZ1z`V}B(NHDoyk57^8hZ7Q zh*gmD#o2@qTT1;wHCgeV=hXB)R}X4Xn9m2KH>nhC4N%cFW~otz&gMF%>3 z)*t+VkbKetXX&g|BTtImq~HI6-zM-=^iSa9DV2toQi+nN7MeUAyIk+vvEz}4fdQ-l O0000 PendingProjectilesToRespawn = new List(); @@ -2076,6 +2077,7 @@ namespace CalamityMod.CalPlayer eyeOfNight = false; soulSeeker = false; perditionBeacon = false; + puffWarrior = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; diff --git a/Items/Weapons/Summon/PuffShroom.cs b/Items/Weapons/Summon/PuffShroom.cs new file mode 100644 index 0000000000..5218a9ab70 --- /dev/null +++ b/Items/Weapons/Summon/PuffShroom.cs @@ -0,0 +1,48 @@ +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.DataStructures; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class PuffShroom : ModItem + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Puff Shroom"); + Tooltip.SetDefault("Summons a cute mushroom warrior to fight for you"); + } + + public override void SetDefaults() + { + Item.damage = 14; + Item.mana = 10; + Item.width = 32; + Item.height = 32; + Item.useTime = Item.useAnimation = 35; + Item.useStyle = ItemUseStyleID.Swing; + Item.noMelee = true; + Item.knockBack = 2f; + Item.value = CalamityGlobalItem.Rarity2BuyPrice; + Item.rare = ItemRarityID.Green; + Item.UseSound = SoundID.Item42; + Item.autoReuse = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.DamageType = DamageClass.Summon; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse != 2) + { + int puffGuy = Projectile.NewProjectile(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI); + if (Main.projectile.IndexInRange(puffGuy)) + Main.projectile[puffGuy].originalDamage = Item.damage; + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/PuffShroom.png b/Items/Weapons/Summon/PuffShroom.png new file mode 100644 index 0000000000000000000000000000000000000000..3900cc431faa4c6c4f72e40e9a0d891d3cd0e86f GIT binary patch literal 576 zcmV-G0>AxPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0o6%FK~zXfy_H=k zLtz-l&wLH*Ol)qj@{wuC4JGq2E=(?%3;8U?y>cbFk}KT0bf<_?T65!)Mk!0tEQ+c5 zxUkdG!NnBj|Gtl$(-t?cU!C)Ro_BTnz0diWLE^Ya)_KLqwB#b+l-CawDafvm;~J;? z+vsn+USt~10x*ziUKT=nic1%aMNH5le2I?r7M50#c~&coRHG5S!E8qA z5pO&`)r|!`G~1_l_TP4P5k?=myhNr#oUzSrhw;qx7#5WCYb3F<<40O$8OA4p0Q%n$ zX8e8OFVmm4p{qw6L{wFA{1tICZgV+Ngdd`sH;= Main.projFrames[Projectile.type]) + Projectile.Kill(); + } + } + } +} diff --git a/Projectiles/Summon/PuffCloud.png b/Projectiles/Summon/PuffCloud.png new file mode 100644 index 0000000000000000000000000000000000000000..5b35dcb43b116c1de5366aa57e5cbf5ed89a9e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Summon/PuffWarrior.cs b/Projectiles/Summon/PuffWarrior.cs new file mode 100644 index 0000000000..4908f63cd8 --- /dev/null +++ b/Projectiles/Summon/PuffWarrior.cs @@ -0,0 +1,184 @@ +using CalamityMod.Buffs.Summon; +using Microsoft.Xna.Framework; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.WorldBuilding; + +namespace CalamityMod.Projectiles.Summon +{ + public class PuffWarrior : ModProjectile + { + public Player Owner => Main.player[Projectile.owner]; + + public Tile GroundTile => CalamityUtils.ParanoidTileRetrieval((int)(Projectile.Bottom.X / 16), (int)(Projectile.Bottom.Y / 16) + 1); + + public bool Jumping => !GroundTile.IsTileSolidGround() || Math.Abs(Projectile.velocity.Y) > 5f; + + public ref float JumpCountdown => ref Projectile.localAI[1]; + + public const float Gravity = 0.425f; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Puff Warrior"); + Main.projFrames[Projectile.type] = 10; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 36; + Projectile.netImportant = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.minionSlots = 1f; + Projectile.timeLeft = 90000; + Projectile.penetrate = -1; + Projectile.minion = true; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = 18; + Projectile.tileCollide = true; + } + + public override void AI() + { + ProvidePlayerMinionBuffs(); + DetermineFrames(); + + NPC potentialTarget = Projectile.Center.MinionHoming(660f, Owner); + if (potentialTarget is null) + { + HopToOwner(out Vector2 guardSpot); + TeleportToFarOffDestination(guardSpot); + } + else + HopToTarget(potentialTarget); + + Projectile.spriteDirection = (Projectile.velocity.X > 0).ToDirectionInt(); + Projectile.rotation = Jumping ? Projectile.rotation + MathHelper.Pi / 10f * Projectile.spriteDirection : 0f; + + while (Collision.SolidCollision(Projectile.position, Projectile.width, Projectile.height)) + Projectile.position.Y -= 10f; + + // Enforce gravity. + if (Projectile.velocity.Y < 16f) + Projectile.velocity.Y += Gravity; + } + + internal void ProvidePlayerMinionBuffs() + { + Owner.AddBuff(ModContent.BuffType(), 3600); + + // Verify player/minion state integrity. The minion cannot stay alive if the + // owner is dead or if the caller of the AI is invalid. + if (Projectile.type != ModContent.ProjectileType()) + return; + + if (Owner.dead) + Owner.Calamity().puffWarrior = false; + if (Owner.Calamity().puffWarrior) + Projectile.timeLeft = 2; + } + + internal void DetermineFrames() + { + int startingFrame = Jumping ? Main.projFrames[Projectile.type] - 3 : 0; + int endingFrame = Jumping ? Main.projFrames[Projectile.type] - 4 : Main.projFrames[Projectile.type] - 4; + + if (Jumping) + JumpCountdown = 12f; + else if (Math.Abs(Projectile.velocity.Y) <= Gravity && JumpCountdown > 0) + { + startingFrame = Main.projFrames[Projectile.type] - 1; + endingFrame = Main.projFrames[Projectile.type] - 1; + JumpCountdown--; + } + + if (Projectile.frame < startingFrame) + Projectile.frame = startingFrame; + + Projectile.frameCounter++; + if (Projectile.frameCounter % 6 == 5) + Projectile.frame++; + + if (Projectile.frame >= endingFrame) + Projectile.frame = startingFrame; + } + + internal void TeleportToFarOffDestination(Vector2 guardSpot) + { + bool obstructionBetweenSpot = Collision.CanHitLine(Projectile.position, Projectile.width, Projectile.height, guardSpot, 4, 4); + bool outOfRangeOfSpot = !Projectile.WithinRange(guardSpot, obstructionBetweenSpot ? 700f : 1900f); + if (Main.myPlayer == Projectile.owner && outOfRangeOfSpot) + { + Projectile.Center = guardSpot; + Projectile.netUpdate = true; + } + } + + internal void HopToOwner(out Vector2 guardSpot) + { + guardSpot = Owner.Center; + guardSpot.X += Owner.direction * 40f * (Projectile.identity % 14f + Projectile.identity / 14 * 0.2f); + + Vector2 searchPoint = guardSpot - Vector2.UnitY * 420f; + + // Ensure that the search point is not outside of the world (which would result in index problems in the search). + searchPoint.Y = MathHelper.Clamp(searchPoint.Y, 32f, Main.maxTilesY * 16f - 32f); + + // Adjust the destination to be at the lowest point. + WorldUtils.Find(searchPoint.ToTileCoordinates(), Searches.Chain(new Searches.Down(Main.maxTilesY + 2), new Conditions.IsSolid()), out Point guardPoint); + guardSpot = guardPoint.ToWorldCoordinates(8f, 16f); + + if (!Jumping && MathHelper.Distance(guardSpot.X, Projectile.Center.X) > 10f) + { + Projectile.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(Projectile.Center, guardSpot, Gravity, 12f); + Projectile.netUpdate = true; + } + } + + internal void HopToTarget(NPC target) + { + Vector2 attackPosition = target.Center; + float attackPositionOffsetDirection = (target.velocity.X > 0).ToDirectionInt() * Math.Sign(Projectile.Center.X - target.Center.X); + attackPosition.X += attackPositionOffsetDirection * 22f * (Projectile.identity % 14f + Projectile.identity / 14 * 0.2f); + + Vector2 searchPoint = attackPosition - Vector2.UnitY * 360f; + + // Ensure that the search point is not outside of the world (which would result in index problems in the search). + searchPoint.Y = MathHelper.Clamp(searchPoint.Y, 32f, Main.maxTilesY * 16f - 32f); + + // Adjust the destination to be at the lowest point. + WorldUtils.Find(searchPoint.ToTileCoordinates(), Searches.Chain(new Searches.Down(Main.maxTilesY + 2), new Conditions.IsSolid()), out Point guardPoint); + attackPosition = guardPoint.ToWorldCoordinates(); + + if (!Jumping) + { + Projectile.position += new Vector2(Projectile.spriteDirection * 4f, -4f); + Projectile.velocity = CalamityUtils.GetProjectilePhysicsFiringVelocity(Projectile.Center, attackPosition, Gravity, 17f); + if (Main.myPlayer == Projectile.owner && Projectile.WithinRange(attackPosition, 360f)) + { + for (int i = 0; i < 3; i++) + { + Vector2 shootPosition = Projectile.Top + Vector2.UnitY * (8f + i * 3f); + Vector2 shootVelocity = (target.Center - shootPosition).SafeNormalize(Vector2.UnitY) * 14f; + Projectile.NewProjectile(Projectile.GetSource_FromThis(), shootPosition, shootVelocity, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner); + } + } + Projectile.netUpdate = true; + } + } + + public override bool OnTileCollide(Vector2 oldVelocity) + { + if (Projectile.oldVelocity.Length() > 6f) + Projectile.velocity = oldVelocity * 0.5f; + else + Projectile.velocity.X = 0f; + return false; + } + } +} diff --git a/Projectiles/Summon/PuffWarrior.png b/Projectiles/Summon/PuffWarrior.png new file mode 100644 index 0000000000000000000000000000000000000000..55eb0dd8de977c9c47141deae5800a589472652c GIT binary patch literal 2339 zcmV+;3EcLHP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D2)Ic^K~#8N?VVkS z7F8I>*NkquDK&~nh?Z71%_||wjc&pSQoAS;gCIjFDhT=@2>JpciXez6kPL#vC@3q4 zq?<_F8?Pi=+}H?=Xlb=>x(UQMXXa<`{&$`|GrOj8m^=f<$*B&b(f-B#?E2e)vS>*kRvoX2A z<~8Mml21=pE8$0hx{?3Bb$*$k^n=!d`_?~DJ}OWp{3?(t^+4(W;n0gQ1&tj1DzJWR zEGjU*<>mOCQcP)2q3r-rhNvalF8FH)P-6A?czixA&P`3l^z`)fyuayB0Z=9OjINDo zim91DV>(&JWTH)ZOvk2eJfvYdODjpN#8|EFb z_NE)+!Rw(mQKPExTL#Gc9oznoE)b$y49WoQ0UVt=71QptgsK3gI^_Q#+8*q^XCkIw z94R8cakS`Gf1WA2!{a|5bFP3!PF|9SC_v=oDJ7j6F+N&+4kbXp=SKm?gnK_f5TEbA zcTY^|&43Zp)bS$KQl0vp+h6%4ri>x|DWEWR)7H#t<5Rz*@3*c%CR16G7bCl5*(I~c zE?IWTAiHFcT{6fn8Dy8t8b$k8;L%f)@p)61?7a=Q#?*=&T35h4fpF&G`0VB#BjJD$ zxkf+8xu>6vM_v3XU{Tj4tBc=S0P2`Db;&Gu4E!oU1$gSYt>c)!%cYK*lTsDJ-{)yseAhTA*me+*5}B zxnxk+E$fd<1}V>|e=Zr+b<0!%AX4a#O9oBdGD^Re`tG@8Fl@K1doCFa+b!#!O9oBd zvi`VaP}eQ%pGyWIf^gJz%lhw7D{$^#y<;-Sr8<@(a0c`2MB)V`}+?W98@OxVt_* zU8E(gE0Aml>iUIsN6+rAjx(8LEwI2nYw8Os{@Vdir&N8z?38Awbmcmw{h3b)OLa=S zKc5g7yEk=8wH<)$ltOk&yXz02z{+(>@dMQXwXTl)>y+YvhP)^LtLU6ly5tkUBUY~% zcsu9zj@tpUUy85z%zEg?s$PusJ`H2xo#MA9w89Xu9oeP3}iD$Zmwnab8|G1M{bzgL{{h#{{%?~hm9)G5tt&-2>z z{&>Y)+2pn7>Siq0EAFmSy6^m%s08(V;+k(`n&RjmcgB=8C@-v9YyORZUj+capzi*J zz~`*Iht?Hnd;)mK_<$T1{qYIw`oG=x2`z^dR0$%sNGai80en9EJ@pAKEXUNZ0*r{P zeFand5<=>Cy0<@}`h$>CKw$)=@3*c%CX>ljwq}cweZuS$T4bLv`-G5vLdZTLWS=nm zgxM#w@*Y}Opz#T0pD;!C36<;*DVa9pf?3Bj)d7U~f}@D1v^D1-Q|1)x4* zin{v}f?oxQ9A{(L`x1hG1@MZ9Y*_meLU-DMkf-G9AlB=l?1UrqDfBB=j|tZe%iWg{T35iVqn6*NzG2`h80YKMGipLn`kr*F04w{3!6u6NLht zu|}+~TX~;qFK8!@9Ng_h0rH-^VR*h)p5q-`v*$pSQf2(yJy!+vPKbrN=zLG_oQz#Q z|Na5B%#8v=JAshbRW&2@iu8NR3qmmhu z8u7&TTgpcTI%+mi;t+Y&6*BMh`MUU5;OvQa;!&5dlVjc890UFp zP;~9NwFaHnLwjQR(1F$!NVWs&9fjx?Lswv@)*t&-KqF86zhia9QoHg&_i6#qB8G^< zVYQGc{FMPl$4lL((E7gmgZ@UvKm-bBtgV`*KngbstaL_3{sUY-Z~C)J0QCR>002ov JPDHLkV1h}!gBSn+ literal 0 HcmV?d00001 From 7b41ec3497ea5a42535a0aaa30655da98db9d1ab Mon Sep 17 00:00:00 2001 From: Dominic Date: Tue, 5 Jul 2022 17:46:33 -0500 Subject: [PATCH 02/20] Added Warlok's Moon Fist --- Buffs/Summon/MoonFistBuff.cs | 34 +++ Buffs/Summon/MoonFistBuff.png | Bin 0 -> 383 bytes CalPlayer/CalamityPlayer.cs | 2 + Items/Weapons/Summon/WarloksMoonFist.cs | 60 +++++ Items/Weapons/Summon/WarloksMoonFist.png | Bin 0 -> 1421 bytes Projectiles/Summon/MoonFist.cs | 251 ++++++++++++++++++ Projectiles/Summon/MoonFist.png | Bin 0 -> 15539 bytes Projectiles/Summon/MoonFistTeleportVisual.cs | 69 +++++ Projectiles/Summon/MoonFistTeleportVisual.png | Bin 0 -> 4689 bytes 9 files changed, 416 insertions(+) create mode 100644 Buffs/Summon/MoonFistBuff.cs create mode 100644 Buffs/Summon/MoonFistBuff.png create mode 100644 Items/Weapons/Summon/WarloksMoonFist.cs create mode 100644 Items/Weapons/Summon/WarloksMoonFist.png create mode 100644 Projectiles/Summon/MoonFist.cs create mode 100644 Projectiles/Summon/MoonFist.png create mode 100644 Projectiles/Summon/MoonFistTeleportVisual.cs create mode 100644 Projectiles/Summon/MoonFistTeleportVisual.png diff --git a/Buffs/Summon/MoonFistBuff.cs b/Buffs/Summon/MoonFistBuff.cs new file mode 100644 index 0000000000..d0de3b52a9 --- /dev/null +++ b/Buffs/Summon/MoonFistBuff.cs @@ -0,0 +1,34 @@ +using CalamityMod.CalPlayer; +using CalamityMod.Projectiles.DraedonsArsenal; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ModLoader; + +namespace CalamityMod.Buffs.Summon +{ + public class MoonFistBuff : ModBuff + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Moon Fist"); + Description.SetDefault("Catch these hands"); + Main.buffNoTimeDisplay[Type] = true; + Main.buffNoSave[Type] = true; + } + + public override void Update(Player player, ref int buffIndex) + { + CalamityPlayer modPlayer = player.Calamity(); + if (player.ownedProjectileCounts[ModContent.ProjectileType()] > 0) + modPlayer.MoonFist = true; + + if (!modPlayer.MoonFist) + { + player.DelBuff(buffIndex); + buffIndex--; + } + else + player.buffTime[buffIndex] = 18000; + } + } +} diff --git a/Buffs/Summon/MoonFistBuff.png b/Buffs/Summon/MoonFistBuff.png new file mode 100644 index 0000000000000000000000000000000000000000..4f56b1091d8604e3cfc280d75624a516fa76e71e GIT binary patch literal 383 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyjKx9jP7LeL$-D$|SkfJR9T^xl z_H+M9WCijK0(?STxp@?HwS8@)Cu&I<{K-9~K7IAto2L|X>Xf55=pFm7TJxV%!0!Lw z|EqZ}|Ihvb)O2Ev+fg7TP!i-9{2vuCJW!661j=z1ctjR6Fz_7)VaDV6D^h@hdpunn zLoEE4PCm%jqQK*Fuu0eT>Hq&_l3f=kUwgA#!m2;SgL7>wd(|(k76JCtLdvBMDOev1LJ|}RKMtaD84wsBVPKMC+2HJBUo-6f=W89yj+P$8)j?tidN*|xgj^Ne) z31O}+>pQaM8k`qf&ooifNF(*Oi@^0);tM1M&i$C3Fuj@K&_3t3N8<0qTP2Q%?%i4; zm=jSD@$B&dwvID~zgmhD^v~VUesD2iPXlj%>jC9IKX*m{W(<1GzjLixwH(kN44$rj JF6*2UngA}om^J_a literal 0 HcmV?d00001 diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index 981c84a756..5c56bf4a53 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -988,6 +988,7 @@ namespace CalamityMod.CalPlayer public bool eyeOfNight = false; public bool soulSeeker = false; public bool perditionBeacon = false; + public bool MoonFist = false; public List PendingProjectilesToRespawn = new List(); @@ -2062,6 +2063,7 @@ namespace CalamityMod.CalPlayer eyeOfNight = false; soulSeeker = false; perditionBeacon = false; + MoonFist = false; disableVoodooSpawns = false; disablePerfCystSpawns = false; diff --git a/Items/Weapons/Summon/WarloksMoonFist.cs b/Items/Weapons/Summon/WarloksMoonFist.cs new file mode 100644 index 0000000000..e304205ac6 --- /dev/null +++ b/Items/Weapons/Summon/WarloksMoonFist.cs @@ -0,0 +1,60 @@ +using Terraria.DataStructures; +using CalamityMod.Projectiles.Summon; +using Microsoft.Xna.Framework; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Weapons.Summon +{ + public class WarloksMoonFist : ModItem + { + public const int SlotCount = 4; + + public const int PunchCooldownTime = 36; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Warloks's Moon Fist"); + Tooltip.SetDefault("Summons a celestial fist to punch enemies for you\n" + + $"Takes up {SlotCount} minion slots"); + SacrificeTotal = 1; + } + + public override void SetDefaults() + { + Item.damage = 330; + Item.mana = 10; + Item.width = 50; + Item.height = 50; + Item.useTime = Item.useAnimation = 25; + Item.useStyle = ItemUseStyleID.Swing; + Item.noMelee = true; + Item.knockBack = 2f; + Item.value = CalamityGlobalItem.RarityPureGreenBuyPrice; + Item.rare = ItemRarityID.Purple; + Item.Calamity().customRarity = CalamityRarity.PureGreen; + Item.UseSound = SoundID.Item104; + Item.autoReuse = true; + Item.noUseGraphic = true; + Item.shoot = ModContent.ProjectileType(); + Item.shootSpeed = 10f; + Item.DamageType = DamageClass.Summon; + } + + public override bool Shoot(Player player, EntitySource_ItemUse_WithAmmo source, Vector2 position, Vector2 velocity, int type, int damage, float knockback) + { + if (player.altFunctionUse != 2) + { + int existingFists = player.ownedProjectileCounts[type]; + int p = Projectile.NewProjectile(source, Main.MouseWorld, Vector2.Zero, type, damage, knockback, player.whoAmI); + if (Main.projectile.IndexInRange(p)) + { + Main.projectile[p].originalDamage = Item.damage; + Main.projectile[p].ai[0] = existingFists; + } + } + return false; + } + } +} diff --git a/Items/Weapons/Summon/WarloksMoonFist.png b/Items/Weapons/Summon/WarloksMoonFist.png new file mode 100644 index 0000000000000000000000000000000000000000..75b87c20018f85555d272488aac23db6e5729d73 GIT binary patch literal 1421 zcmV;81#D-00001b5ch_0Itp) z=>Px)M@d9MRA_OaS8Vm^P zL#-k{1xZ0cFo;hgibZN)EEKd=D73b;h)rp&y(A`95*s8plg1=Aw}xbM@%S+N?e5H; zP2vU4>Hp>IoS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nvsCM4n;z3+8^5S(tYx0Kv2@ zt->ezY-Wuy=E^%sg->9fGvT>RVmiDCK;Mx17ei^m79jS9mCrW-F!NU{00$%U>Wx!V ziOD2#ku!+?;c;!8`;7k_8wFrpjylUf{QV^@KdyM-9t$AktFR$CbFl;F8H8stiDgey zO+59?BLIAT_>{(6P*z+A!0Lccldbm|`~6D%i;K=tXWa`=0C4)`703UB$f-;JK)2(3 b*BJi|`eG7D9xA^700000NkvXXu0mjfUy-6M literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/MoonFist.cs b/Projectiles/Summon/MoonFist.cs new file mode 100644 index 0000000000..962f0947ee --- /dev/null +++ b/Projectiles/Summon/MoonFist.cs @@ -0,0 +1,251 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using Terraria.Audio; +using CalamityMod.Items.Weapons.Summon; +using CalamityMod.Buffs.Summon; +using System.IO; +using Terraria.GameContent.Drawing; +using CalamityMod.Dusts; + +namespace CalamityMod.Projectiles.Summon +{ + public class MoonFist : ModProjectile + { + public int DelayUntilNextPunch; + + public int FistIndex => (int)Projectile.ai[0]; + + public ref float AttackTimer => ref Projectile.ai[1]; + + public ref float FrameTimer => ref Projectile.localAI[0]; + + public float FistInterpolant + { + get + { + float projectileCounts = Owner.ownedProjectileCounts[Type]; + + // Use a midway interpolant if the projectile count is one. This makes the fist use middle positions instead of + // sitting awkwardly to the left. + if (projectileCounts <= 1f) + return 0.5f; + + return FistIndex / (projectileCounts - 1f); + } + } + + public Player Owner => Main.player[Projectile.owner]; + + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Cosmic Fist"); + Main.projFrames[Type] = 18; + ProjectileID.Sets.MinionSacrificable[Projectile.type] = true; + ProjectileID.Sets.MinionTargettingFeature[Projectile.type] = true; + } + + public override void SetDefaults() + { + Projectile.width = 48; + Projectile.height = 48; + Projectile.minion = true; + Projectile.friendly = true; + Projectile.ignoreWater = true; + Projectile.tileCollide = false; + Projectile.netImportant = true; + Projectile.alpha = 255; + Projectile.minionSlots = WarloksMoonFist.SlotCount; + Projectile.penetrate = -1; + Projectile.MaxUpdates = 2; + Projectile.usesLocalNPCImmunity = true; + Projectile.localNPCHitCooldown = Projectile.MaxUpdates * 10; + Projectile.netImportant = true; + Projectile.timeLeft = 90000; + Projectile.DamageType = DamageClass.Summon; + } + + public override void SendExtraAI(BinaryWriter writer) => writer.Write(DelayUntilNextPunch); + + public override void ReceiveExtraAI(BinaryReader reader) => DelayUntilNextPunch = reader.ReadInt32(); + + public override void AI() + { + ApplyMinionBuffs(); + + NPC potentialTarget = Owner.Center.ClosestNPCAt(1650f); + if (potentialTarget is null) + HoverNearOwner(); + else + AttackTarget(potentialTarget); + + FrameTimer++; + Projectile.frameCounter++; + if (DelayUntilNextPunch > 0) + DelayUntilNextPunch--; + + // Fade in. + Projectile.Opacity = MathHelper.Clamp(Projectile.Opacity + 0.1f, 0f, 1f); + } + + public void ApplyMinionBuffs() + { + // Maintain or remove the Mechworm buff from the owner. + Owner.AddBuff(ModContent.BuffType(), 3600); + if (Owner.dead) + Owner.Calamity().MoonFist = false; + if (Owner.Calamity().MoonFist) + Projectile.timeLeft = 2; + } + + public void HoverNearOwner() + { + float hoverOffsetAngle = MathHelper.Lerp(-MathHelper.PiOver2, MathHelper.PiOver2, FistInterpolant); + Vector2 hoverDestination = Owner.Center - Vector2.UnitY.RotatedBy(hoverOffsetAngle) * (Owner.height + 70f); + Projectile.velocity *= 0.7f; + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.13333f); + + // Use idle frames. + float frameInterpolant = (FrameTimer / 50f + FistInterpolant) % 1f; + Projectile.frame = (int)Math.Round(MathHelper.Lerp(0f, 5f, frameInterpolant)); + + // Determine direction and rotation. + Projectile.rotation = Projectile.rotation.AngleTowards(0f, 0.333f); + Projectile.spriteDirection = Owner.direction; + + // Reset the attack timer. + AttackTimer = 0f; + } + + public void AttackTarget(NPC target) + { + int reelBackTime = 32; + int homeDelay = 27; + int attackTime = 150; + int attackCycleInterval = reelBackTime + attackTime; + + // Teleport to the enemy if it's far away. + if (!Projectile.WithinRange(target.Center, 1200f)) + { + Vector2 teleportDestination = target.Center + Main.rand.NextVector2Unit() * Main.rand.NextFloat(250f, 300f); + DoTeleport(teleportDestination); + } + + Projectile.rotation = Projectile.AngleTo(target.Center); + Projectile.spriteDirection = (target.Center.X < Projectile.Center.X).ToDirectionInt(); + if (Projectile.spriteDirection == -1) + Projectile.rotation += MathHelper.Pi; + + // Clench the fist and hover near the target. + if (AttackTimer <= reelBackTime) + { + Projectile.frame = (int)Math.Round(MathHelper.Lerp(6f, 11f, AttackTimer / reelBackTime)); + + // Reel back and look at the target. + float hoverOffset = MathHelper.Lerp(200f, 480f, AttackTimer / reelBackTime); + hoverOffset += MathHelper.Lerp(-10f, 75f, Projectile.identity % 9f / 1f); + float spin = MathHelper.Lerp(-0.27f, 0.27f, Projectile.identity / 7f % 1f); + Vector2 hoverDestination = target.Center - target.SafeDirectionTo(target.Center, Vector2.UnitY).RotatedBy(spin) * hoverOffset; + Vector2 idealVelocity = Projectile.SafeDirectionTo(hoverDestination) * MathHelper.Min(25f, Projectile.Distance(hoverDestination)); + + Projectile.Center = Vector2.Lerp(Projectile.Center, hoverDestination, 0.02f); + Projectile.velocity = Vector2.Lerp(Projectile.velocity, idealVelocity, 0.03f).MoveTowards(idealVelocity, 0.5f); + + // Fly towards the target at an incredibly fast speed. + if (AttackTimer == reelBackTime) + { + SoundEngine.PlaySound(SoundID.DD2_WyvernDiveDown, Projectile.Center); + Projectile.velocity = CalamityUtils.CalculatePredictiveAimToTarget(Projectile.Center, target, 40f); + Projectile.netUpdate = true; + } + } + else if (DelayUntilNextPunch <= 0) + { + // Home towards the target briefly after the initial charge. + if (AttackTimer >= reelBackTime + homeDelay) + Projectile.velocity = Projectile.SuperhomeTowardsTarget(target, 34f, 24f); + } + + // Increment the attack timer. + AttackTimer = (AttackTimer + 1f) % attackCycleInterval; + } + + public void DoTeleport(Vector2 end) + { + Vector2 start = Projectile.Center; + for (int i = 0; i < 75; i++) + { + Vector2 dustDrawPosition = Vector2.Lerp(start, end, i / 74f); + + Dust magic = Dust.NewDustPerfect(dustDrawPosition, 267); + magic.velocity = -Vector2.UnitY * Main.rand.NextFloat(0.2f, 0.235f); + magic.color = Color.LightCyan; + magic.color.A = 0; + magic.scale = 0.8f; + magic.fadeIn = 1.4f; + magic.noGravity = true; + } + + if (Main.netMode == NetmodeID.MultiplayerClient) + return; + + for (int i = 0; i < 6; i++) + { + int magic = Projectile.NewProjectile(Projectile.GetSource_FromAI(), start, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + Main.projectile[magic].timeLeft -= i * 2; + magic = Projectile.NewProjectile(Projectile.GetSource_FromAI(), end, Vector2.Zero, ModContent.ProjectileType(), 0, 0f); + Main.projectile[magic].timeLeft -= i * 2; + } + Projectile.Center = end; + Projectile.netUpdate = true; + } + + public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) + { + // Rebound on collision. + if (DelayUntilNextPunch > 0 || AttackTimer <= 0f) + return; + + // Create some cool particles to go with the hit. + Vector2 impactPoint = Vector2.Lerp(Projectile.Center, target.Hitbox.ClosestPointInRect(Projectile.Center), 0.5f); + for (int i = 0; i < 7; i++) + { + ParticleOrchestrator.RequestParticleSpawn(false, ParticleOrchestraType.StardustPunch, new() + { + PositionInWorld = impactPoint + Vector2.UnitY * Main.rand.NextFloatDirection() * 10f, + MovementVector = Main.rand.NextVector2Unit() * Main.rand.NextFloat(3f, 9.6f) + }); + } + for (int i = 0; i < 15; i++) + { + int dustID = Main.rand.NextBool() ? (int)CalamityDusts.BlueCosmilite : (int)CalamityDusts.PurpleCosmilite; + + Dust cosmicDust = Dust.NewDustPerfect(impactPoint + Main.rand.NextVector2Circular(10f, 10f), dustID); + cosmicDust.velocity = Projectile.velocity.RotatedByRandom(0.6f) * 0.2f; + cosmicDust.scale = Main.rand.NextFloat(1f, 1.4f); + cosmicDust.noGravity = true; + if (Main.rand.NextBool(5)) + cosmicDust.scale += 0.45f; + } + + SoundEngine.PlaySound(SoundID.Item74 with { Pitch = -0.36f }, Projectile.Center); + DelayUntilNextPunch = WarloksMoonFist.PunchCooldownTime - 10; + Projectile.velocity = Projectile.SafeDirectionTo(target.Center, -Vector2.UnitY).RotatedBy(0.16f) * Projectile.velocity.Length() * -0.45f; + Projectile.netUpdate = true; + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D texture = ModContent.Request(Texture).Value; + Rectangle frame = texture.Frame(1, Main.projFrames[Type], 0, Projectile.frame); + Vector2 origin = frame.Size() * 0.5f; + Vector2 drawPosition = Projectile.Center - Main.screenPosition; + SpriteEffects direction = Projectile.spriteDirection == 1 ? SpriteEffects.None : SpriteEffects.FlipHorizontally; + Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, origin, Projectile.scale, direction, 0); + return false; + } + } +} diff --git a/Projectiles/Summon/MoonFist.png b/Projectiles/Summon/MoonFist.png new file mode 100644 index 0000000000000000000000000000000000000000..5e74b5957e87f37cf336c60f23153e597257535f GIT binary patch literal 15539 zcmeIZcT`i|*EMU%-;O@-@4N4J#~pXvG43Dtj`95iDCC@d_Fikvx#pTDR9{#97!wZ@ z1VP6%HB^w`yE6nGVn1>i{FJSr0|Vb^T#)KYP+{AdUl4Q-(o|72@=Te>nZLBKOUxOW zA26N}F_|mHHOzktJ9G6e`r7N%$Wvq<8%^*A(KksQu57I39nehZ`wrqaHXr_`M$K&G+u0w^xXDqgkzpS{AHUgy zKKvWX_QuZO+}uaBPetkQ-d@uN{gLxu@nzq+&S`)37u?uuA?!eqPi#|(01F*7c`y-7 zeBXXnYTxrxpUc=xc*P>0^jhv&==HaxL(qev+YmHp=HD$>SWOR^>hNAdaaz7{$20mk zN-_7lRaW`Y&^?%_fqAUY{Zt=hF2~VE2JGiTfrN`?Q8EXMA8L134|EkqiiWMW@IHgp zyK-I*%+U3=1D6>W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OX#z)T*1swp9Onat z>u3ZS4Hv)l$0eshAcB{wq{-)E@xI3e4-5=3ufYCdZOCY$&UIpt!qd@Xlf{x<)A_GWc11n$i@qhsl2^FmYB z0qjll8|)uL+@1;!n@t@d3!_BisX-9DgRM=R?}!V`xEk8D;zv#io|D!Y-Z6lMsz>ei z#5b@p0dRtWmpOoYL{E>PDI%R}rc=`nqRgHrm&!XnP_g^kjsS?2zfl3EdVqLPp>mdk zKm`jp(KrhrAa%(97sLKrBs9P19_VMeu$=XCPMvBK2S@%VxXc{d1XCSBfz$Vih#T4W z+rb@Ew;MSM-C5oSaRo|KgL3Yh@Q@!X@+?Eo+67acsr;g4IaPEu`H}5iGgFV7v7W7f zMt!)WAYMkFkFlS|k(Sn-q^a-giLGt_9zFd#EphKtDT0KKSNg9q1E$7`f0{|#U}+9b z@n3|i^hh$f~i|+GY1Q(NxdGBun^H3(*FPHrK+J4s8>64Z# z80r338%OkI`44BAoQ>k5Iu0-I3c&GMj<_%W+SA&o2F#pR{$1qv+v7UeW xZy=jcflCL&0iL~yN@V}W!G9|N;-k9(S_z{;bL4MC@D?(psj90|sC4J){{T*f0{;L2 literal 0 HcmV?d00001 diff --git a/Projectiles/Summon/MoonFistTeleportVisual.cs b/Projectiles/Summon/MoonFistTeleportVisual.cs new file mode 100644 index 0000000000..ed4e267d83 --- /dev/null +++ b/Projectiles/Summon/MoonFistTeleportVisual.cs @@ -0,0 +1,69 @@ +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using Terraria; +using Terraria.GameContent; +using Terraria.ModLoader; + +namespace CalamityMod.Projectiles.Summon +{ + public class MoonFistTeleportVisual : ModProjectile + { + public override void SetStaticDefaults() => DisplayName.SetDefault("Light"); + + public override void SetDefaults() + { + Projectile.width = Projectile.height = 2; + Projectile.tileCollide = false; + Projectile.ignoreWater = true; + Projectile.hide = true; + Projectile.timeLeft = 45; + Projectile.MaxUpdates = 2; + Projectile.penetrate = -1; + } + + public override void AI() + { + Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Projectile.timeLeft); + Projectile.scale = Utils.GetLerpValue(45f, 5f, Projectile.timeLeft); + } + + public override bool PreDraw(ref Color lightColor) + { + Texture2D telegraphTexture = TextureAssets.Projectile[Projectile.type].Value; + Color telegraphColor = Color.White * Projectile.Opacity * 0.2f; + telegraphColor.A = 0; + + for (int i = 0; i < 35; i++) + { + Vector2 drawPosition = Projectile.Center + (MathHelper.TwoPi * i / 5f + Main.GlobalTimeWrappedHourly * 3f).ToRotationVector2() * 2f; + drawPosition -= Main.screenPosition; + + Vector2 scale = new Vector2(0.58f, 1f) * Projectile.scale; + scale *= MathHelper.Lerp(0.015f, 1f, i / 35f); + + Main.spriteBatch.Draw(telegraphTexture, drawPosition, null, telegraphColor, 0f, telegraphTexture.Size() * 0.5f, scale, 0, 0f); + } + return false; + } + + public override void Kill(int timeLeft) + { + for (int i = 0; i < 20; i++) + { + Dust magic = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(30f, 30f), 267); + magic.color = Color.SkyBlue; + magic.scale = 1.1f; + magic.fadeIn = 0.6f; + magic.velocity = Main.rand.NextVector2Circular(2f, 2f); + magic.velocity = Vector2.Lerp(magic.velocity, -Vector2.UnitY * magic.velocity.Length(), Main.rand.NextFloat(0.65f, 1f)); + magic.noGravity = true; + } + } + + public override void DrawBehind(int index, List behindNPCsAndTiles, List behindNPCs, List behindProjectiles, List overPlayers, List overWiresUI) + { + behindNPCsAndTiles.Add(index); + } + } +} diff --git a/Projectiles/Summon/MoonFistTeleportVisual.png b/Projectiles/Summon/MoonFistTeleportVisual.png new file mode 100644 index 0000000000000000000000000000000000000000..f51029ba2170a62d1cec2b0d0502768b3ea64a79 GIT binary patch literal 4689 zcmZ8lc|6qH`=2pmi!r%kvJK*nvZQ1X*_tA0DB1U{GqwoXnIT&xBoWy{mN52xnXIL( zS%(-DnZnrj`i<(|+wc3w`JC5zea`m0pZ9sr^FC46wKX6|c#Z%70Ep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$R}8BCprV|HI@rBbxz6b?lVx>^Um zF80pvgvc^?gW=8n%2Dg-W|$wr2dy`y0Q|A_>oob>*ZEqEgd{(Uq#8SpyN@4vT>F%n?`l}dRkl%u%EB5q{-AgO5nr8+O;&sT%; zUG_jG`pv0EyGv3D48ySJF#InvZJus0yEa<-Jffiim2~Yp)UgyI>M6M-O?w6cXkOO7 KRD97Y Date: Tue, 13 Sep 2022 23:12:02 -0700 Subject: [PATCH 03/20] Added Nanodroids --- NPCs/CalamityGlobalNPC.cs | 15 +++- NPCs/DraedonLabThings/Nanodroid.cs | 74 +++++++++++++++++ NPCs/DraedonLabThings/Nanodroid.png | Bin 0 -> 1009 bytes .../NanodroidDisfunctional.cs | 76 ++++++++++++++++++ .../NanodroidDisfunctional.png | Bin 0 -> 764 bytes .../NanodroidDisfunctional_Glow.png | Bin 0 -> 284 bytes NPCs/DraedonLabThings/NanodroidPlagueGreen.cs | 76 ++++++++++++++++++ .../DraedonLabThings/NanodroidPlagueGreen.png | Bin 0 -> 928 bytes .../NanodroidPlagueGreen_Glow.png | Bin 0 -> 240 bytes NPCs/DraedonLabThings/NanodroidPlagueRed.cs | 76 ++++++++++++++++++ NPCs/DraedonLabThings/NanodroidPlagueRed.png | Bin 0 -> 917 bytes .../NanodroidPlagueRed_Glow.png | Bin 0 -> 289 bytes NPCs/DraedonLabThings/Nanodroid_Glow.png | Bin 0 -> 338 bytes 13 files changed, 316 insertions(+), 1 deletion(-) create mode 100644 NPCs/DraedonLabThings/Nanodroid.cs create mode 100644 NPCs/DraedonLabThings/Nanodroid.png create mode 100644 NPCs/DraedonLabThings/NanodroidDisfunctional.cs create mode 100644 NPCs/DraedonLabThings/NanodroidDisfunctional.png create mode 100644 NPCs/DraedonLabThings/NanodroidDisfunctional_Glow.png create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueGreen.cs create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueGreen.png create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueGreen_Glow.png create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueRed.cs create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueRed.png create mode 100644 NPCs/DraedonLabThings/NanodroidPlagueRed_Glow.png create mode 100644 NPCs/DraedonLabThings/Nanodroid_Glow.png diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index b8b544325e..62133dcc24 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4800,6 +4800,7 @@ namespace CalamityMod.NPCs nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.HellLabCenter / 16f) < 180f; nearLab |= CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.IceLabCenter / 16f) < 180f; + bool nearPlagueLab = CalamityUtils.ManhattanDistance(checkPosition, CalamityWorld.JungleLabCenter / 16f) < 180f; bool isLabWall = aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); isLabWall |= aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType() || aboveSpawnTile.WallType == WallType(); @@ -4808,7 +4809,19 @@ namespace CalamityMod.NPCs WeightedRandom pool = new WeightedRandom(); pool.Add(NPCID.None, 0f); - pool.Add(NPCType(), 0.2f); + pool.Add(NPCType(), 0.1f); + if (nearPlagueLab) + { + pool.Add(NPCType(), 0.05f); + pool.Add(NPCType(), 0.05f); + pool.Add(NPCType(), 0.01f); + } + else + { + pool.Add(NPCType(), 0.1f); + pool.Add(NPCType(), 0.1f); + } + int typeToSpawn = pool.Get(); if (typeToSpawn != NPCID.None) diff --git a/NPCs/DraedonLabThings/Nanodroid.cs b/NPCs/DraedonLabThings/Nanodroid.cs new file mode 100644 index 0000000000..40b81ecf8e --- /dev/null +++ b/NPCs/DraedonLabThings/Nanodroid.cs @@ -0,0 +1,74 @@ +using CalamityMod.BiomeManagers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.DraedonLabThings +{ + public class Nanodroid : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanodroid"); + Main.npcFrameCount[NPC.type] = 8; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.CloneDefaults(NPCID.LightningBug); + NPC.width = 16; + NPC.height = 12; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") + }); + } + + public override void AI() + { + Lighting.AddLight(NPC.Center, 0.2f, 0.2f, 0.4f); + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 0.15f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/Nanodroid_Glow").Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/Nanodroid.png b/NPCs/DraedonLabThings/Nanodroid.png new file mode 100644 index 0000000000000000000000000000000000000000..c7b96ffeb185e1f6766a3022d0038545cb416c94 GIT binary patch literal 1009 zcmVPx&t4TybR9J=Gm`iL;K^(?^Q|I>RyO&mPR4eV}HYJq4B8uzLcoY$dhz%0)SRj#N zFOk@3SlD2LjYP!8Bc%0~5O4KTlIsmtieR1d!6U!$EfOgTQl~=Az5YZ<93G_3>p4PDr!1}ZY08E=R1Axf$cL2<* zo(Vwxt@8kEIBRJg^c#V7sWz$C3N^Aj-0k~62YCg40GeKX(q_B3qDX7_==u`?N~%i* zKyiVoRd5$%1V;m4SJXHFNr!d;(6)RN0AKH474mt_41%sj%^E&bLP|{oz@M8a06I2r zRqp^KwPZz+UVtV27qW*82jG26!~v)-oen^K zHv(*HH5%jFyLGe zZr*=S2>{?Ls|29qr<@wgC&9KiJ_O*+nG=Q(gjdPgeBYR=twL^2mH_ziGg0HhxNy3V z&kREd+`6!AO*sH}@3aCvxZu(SwIj`)NGc+4)1o8G5t@J9?DdbqZ8yyz_~S&16-#!E z6aX_erW!)vF0iMC0SGjl*AO)?TPgs)9X+D8H?Ip;Q4oOS1A8@eg<}c<=zOc66Xs8( zSh|p(>lXm|Bm8C%SPK@09e}!>2Z7kSFg6%+03u%=8bYA1B-Foo(%1Ht6z3G|O-u#KwZp&};ty?PqQgV_3NDa#UVF%=x=D6UM zse1W^oPf;U0s-3$0;{Sz=l~qvcLUJ;f&+j0g+RbIoFh%GYeOQ?E4=)IYHtidOfINU z>mENY*m*KH%Ba$Fqs|pehV z-e8Ukef0~WDoX$qO|i@%=(As#y&VVOQmxMr0ERbX43KwLds}(uSbjm>BV{KTax7w0q0E7wzkK;uexYi*RPCZro*@M80=Hj? zdydqFpvy1JUj#r#`cQqO#(VO|r`N#0)P?`?9?9!Y)k_x!{!Z1c3zgxZ04NL@a&0kn fK}FoW^S_VZc!-&nt4jn700000NkvXXu0mjfR=UdA literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs new file mode 100644 index 0000000000..bbc16fc0fc --- /dev/null +++ b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs @@ -0,0 +1,76 @@ +using CalamityMod.BiomeManagers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.DraedonLabThings +{ + public class NanodroidDisfunctional : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanodroid"); + Main.npcFrameCount[NPC.type] = 8; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.CloneDefaults(NPCID.LightningBug); + NPC.width = 16; + NPC.height = 12; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") + }); + } + public override void AI() + { + if (NPC.localAI[2] > 3f) + { + Lighting.AddLight(NPC.Center, 0.25f, 0.1f, 0f); + } + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 0.15f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/NanodroidDisfunctional_Glow").Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.png b/NPCs/DraedonLabThings/NanodroidDisfunctional.png new file mode 100644 index 0000000000000000000000000000000000000000..425918f9b5be97b7c5768676919d251e43a7c9e7 GIT binary patch literal 764 zcmVPx%wn;=mR9J=Wm&;33Q2@q&C$;f0GmX=Xqfm|7P)#Eu*2YC5kpw{my>@{v+Xc0? zh5tbKAG9utT-7GfAR4`%xQ7&<$A7jqqxTsy5H(>9`}Cd@tyB{ z;!3<0fcpzM$rkixjtPK#ep9LM3l{}If4Bs|9y~(Go}>g2BQpS8Xln!D$ND+|7kf?u z@Nnc60HX&A$_G3%sJv8h*euQ{4c4EXu>0#`@bc}rFv}8PczhhN*TBNFsVM+X)zu1s zcr2!efpAu&nwkJ;Kc1EV4~icEd+w9dSphJa&1zLHyQLh?>n>)MVPP$P5+(-m8F>q^$nYVNIiB1V%IoRj*zA(7FR{-3edLi{N zxH_@$%QuqK7cwmkMj>1yv@me>g-9p_*l(qs*Mburt*r_p3mdr{pwk!JZlrjPvETVz zu54b=b}RdN!Osf{13xeLc>#7~Uif>y;FcGHpa~60+7BevL9R^{><2=4*a<9_|JYu;R8kGh!%#1 zmF}jxc#aDM{^@P z^L+6cYO5lQ8Vpu4EXy~M?P*G6VzV>nV`Nw*f8n)rib0fI0ON$YLW!!DM>jfb;!Xgm z((if3x~k#gze5QO7Jqp^zs{&{%$1UjC<)78&qol`;+0A3bg&Hw-a literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs new file mode 100644 index 0000000000..f7f0522086 --- /dev/null +++ b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs @@ -0,0 +1,76 @@ +using CalamityMod.BiomeManagers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.DraedonLabThings +{ + public class NanodroidPlagueGreen : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanodroid"); + Main.npcFrameCount[NPC.type] = 8; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.CloneDefaults(NPCID.LightningBug); + NPC.width = 16; + NPC.height = 12; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") + }); + } + public override void AI() + { + if (NPC.localAI[2] > 3f) + { + Lighting.AddLight(NPC.Center, 0.03f, 0.3f, 0.05f); + } + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 0.15f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/NanodroidPlagueGreen_Glow").Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.png b/NPCs/DraedonLabThings/NanodroidPlagueGreen.png new file mode 100644 index 0000000000000000000000000000000000000000..62353a847eccf835cca5686736f8f9812cfa36e9 GIT binary patch literal 928 zcmV;R17G}!P)Px&T1iAfR9J=Wm`h9(K^Vt>Bjs77wU$?FMbR2ml#2ofV^9$e1QU!0;{#2+c=uxB zNsWmYoTUI{WTpWS zNf{OZk1sC=U^+#vxl%64qb zG^5~;>%yVkxfU2)l^yXe#H$N8@Ae6RgEa+~83pIBxBqgFWUmXK{C?FGMik6qAy}RT zz`=8A7W}9Otxq}xKv$PkW}XEVsTq>CI~OwrfFna@%JNEO?pVs?v7ln*`k(-ajPz^g z8!F{ab#JBDjDom+Au>2@0c@+=55U9bCSsWv$S=fW!MI-#TS@`|bPY{v&*l!ew2ng` z0000a~60+7BevL9R^{>nJe!8i7z%f`Qq7=IIbNkX12NEvgOmxt~-Bv#!H!BKR^0r3IDL% z#UOD}&nJ7`?gv+nitX_hS2&U`p7i;^LT-UW)%V}u)iC3i*~Rek-Odm9COf@gYDsWs j>N&4xk@SD=R4Yc2?K*a>^>*bz2QhfM`njxgN@xNAEG$^s literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs new file mode 100644 index 0000000000..bab0fbf0ff --- /dev/null +++ b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs @@ -0,0 +1,76 @@ +using CalamityMod.BiomeManagers; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.DraedonLabThings +{ + public class NanodroidPlagueRed : ModNPC + { + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Nanodroid"); + Main.npcFrameCount[NPC.type] = 8; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.CloneDefaults(NPCID.LightningBug); + NPC.width = 16; + NPC.height = 12; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") + }); + } + public override void AI() + { + if (NPC.localAI[2] > 3f) + { + Lighting.AddLight(NPC.Center, 0.3f, 0.03f, 0f); + } + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + NPC.frameCounter += 0.15f; + NPC.frameCounter %= Main.npcFrameCount[NPC.type]; + int frame = (int)NPC.frameCounter; + NPC.frame.Y = frame * frameHeight; + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/NanodroidPlagueRed_Glow").Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.png b/NPCs/DraedonLabThings/NanodroidPlagueRed.png new file mode 100644 index 0000000000000000000000000000000000000000..3fe30d653e4d32bae72608a28bfe5015d7fb81e5 GIT binary patch literal 917 zcmV;G18V$Px&Pf0{UR9J=Wmq}=oK@`V-W75fcoIa= zgA}hWM-N^^+(7iE;Mo-wH(W@y8jEd6m((Qc=iz-rozx(ulN7Y?^36Bjo0YKq{Fs{w>f@XErnuAI$zpB;MI+aU;u#1Yz_cl ztU&>sO!n({@k8jxv*fVq>#gH zn=B#NeW=!DV;=yS*GYa~`PGyA#()hwe0JG5BqROJR`04)04p~IEFmc5!Xm%qx^uCx zf#}Gmv;w&8#>2;sXLb+_sS9;}>AIN1h`8{?8UO0v-pT>%e=e*G+3p&*C7H=S z7Zz7bM4oA?a$v9?Jn(rHz-PB^*yn<_>Yozp$3Dy6c%tJ0@aH5FLsdV;v1DA(7MmSa z0I8mLMt|#?umV`Vw$=`UqIx0GJ>YU-KL9r_oW@LX-1`WA7))){(hV zwHss2mJnzzO!^@a7|(q-?nVbwT?*jgfZXD9y`|!Ur&4lZz9y&u+PWq7BSFd137`0- zN4+lmi+W+WT+pV+m0mj+)`bPDCMkfHCDoP?{H-qROZF*%`{|6~XO9bodZAtdj8j>q z0H%gR0Ca@pna)|}!VtZ1*G)vR=6XXfq%&DPW=t>qhkBuWccenS(AJ$*FsPZsdAS>< reUdZB^um~45G$8n&{i_-Jo@$v$$P#7$K(+u00000NkvXXu0mjfz0j_6 literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed_Glow.png b/NPCs/DraedonLabThings/NanodroidPlagueRed_Glow.png new file mode 100644 index 0000000000000000000000000000000000000000..7a5b6df398d3c98b303df3e146b0e3672c9080c0 GIT binary patch literal 289 zcmeAS@N?(olHy`uVBq!ia0vp^0zjO=!3HEnE`C}7q!^2X+?^QKos)S9a~60+7BevL9R^{>`(O|8LK%+Q8{Gnb(b1f`{#a z5BtnRSqYs{%#jBBe;!IUu>Jd1*Uf;LE8{s+(!mUqJ}Cw!5ov>2;%>YQje*P`mK;ex zcTPhnsQUY&CyWvc=5lwiF1~1y#lR7e!*FmLI?x9Up00i_>zopr0Np5E@Bjb+ literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/Nanodroid_Glow.png b/NPCs/DraedonLabThings/Nanodroid_Glow.png new file mode 100644 index 0000000000000000000000000000000000000000..8367fc171588d87267bf1df9d43a3cfb42ae8f45 GIT binary patch literal 338 zcmeAS@N?(olHy`uVBq!ia0vp^0zjO=!3HEnE`C}7q!^2X+?^QKos)S9a~60+7BevL9R^{>`(O|8LK%+Q8{GnO9Md3?z~gP4s!#m>n{uZEGJhzj(!dj@w{*z?-HGV<^=8%UTYnCLe!v~gd!?Y83;vxEd&q5%g_!&Z|8HBAh$wof-Y zWW_Zw&d_cvwqm%-{o<`kPJ%@{`^{cBlXV literal 0 HcmV?d00001 From d0f36c771b68123079907340d9ed6b5299a9a219 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Wed, 14 Sep 2022 19:45:22 -0700 Subject: [PATCH 04/20] bestiary and increased framerate the normal Nanodroid is now the only one with a bestiary entry, with the others counting towards it --- NPCs/DraedonLabThings/Nanodroid.cs | 3 ++- .../NanodroidDisfunctional.cs | 27 ++++++++++--------- NPCs/DraedonLabThings/NanodroidPlagueGreen.cs | 27 ++++++++++--------- NPCs/DraedonLabThings/NanodroidPlagueRed.cs | 27 ++++++++++--------- 4 files changed, 44 insertions(+), 40 deletions(-) diff --git a/NPCs/DraedonLabThings/Nanodroid.cs b/NPCs/DraedonLabThings/Nanodroid.cs index 40b81ecf8e..7e89709ab6 100644 --- a/NPCs/DraedonLabThings/Nanodroid.cs +++ b/NPCs/DraedonLabThings/Nanodroid.cs @@ -48,7 +48,8 @@ namespace CalamityMod.NPCs.DraedonLabThings public override void FindFrame(int frameHeight) { - NPC.frameCounter += 0.15f; + NPC.spriteDirection = NPC.direction; + NPC.frameCounter += 0.3f; NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs index bbc16fc0fc..31647a8691 100644 --- a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs +++ b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs @@ -1,9 +1,7 @@ -using CalamityMod.BiomeManagers; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -13,6 +11,7 @@ namespace CalamityMod.NPCs.DraedonLabThings { public override void SetStaticDefaults() { + this.HideFromBestiary(); DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; @@ -25,17 +24,8 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") - }); - } public override void AI() { if (NPC.localAI[2] > 3f) @@ -50,7 +40,8 @@ namespace CalamityMod.NPCs.DraedonLabThings public override void FindFrame(int frameHeight) { - NPC.frameCounter += 0.15f; + NPC.spriteDirection = NPC.direction; + NPC.frameCounter += 0.3f; NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; @@ -62,6 +53,16 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } + public override void OnKill() + { + if (NPC.GetWereThereAnyInteractions()) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Kills.RegisterKill(nPC); + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs index f7f0522086..ca14d60d90 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs @@ -1,9 +1,7 @@ -using CalamityMod.BiomeManagers; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -13,6 +11,7 @@ namespace CalamityMod.NPCs.DraedonLabThings { public override void SetStaticDefaults() { + this.HideFromBestiary(); DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; @@ -25,17 +24,8 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") - }); - } public override void AI() { if (NPC.localAI[2] > 3f) @@ -50,7 +40,8 @@ namespace CalamityMod.NPCs.DraedonLabThings public override void FindFrame(int frameHeight) { - NPC.frameCounter += 0.15f; + NPC.spriteDirection = NPC.direction; + NPC.frameCounter += 0.3f; NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; @@ -62,6 +53,16 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } + public override void OnKill() + { + if (NPC.GetWereThereAnyInteractions()) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Kills.RegisterKill(nPC); + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs index bab0fbf0ff..57872dc566 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs @@ -1,9 +1,7 @@ -using CalamityMod.BiomeManagers; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; -using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -13,6 +11,7 @@ namespace CalamityMod.NPCs.DraedonLabThings { public override void SetStaticDefaults() { + this.HideFromBestiary(); DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; @@ -25,17 +24,8 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } - public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) - { - bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") - }); - } public override void AI() { if (NPC.localAI[2] > 3f) @@ -50,7 +40,8 @@ namespace CalamityMod.NPCs.DraedonLabThings public override void FindFrame(int frameHeight) { - NPC.frameCounter += 0.15f; + NPC.spriteDirection = NPC.direction; + NPC.frameCounter += 0.3f; NPC.frameCounter %= Main.npcFrameCount[NPC.type]; int frame = (int)NPC.frameCounter; NPC.frame.Y = frame * frameHeight; @@ -62,6 +53,16 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } + public override void OnKill() + { + if (NPC.GetWereThereAnyInteractions()) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Kills.RegisterKill(nPC); + } + } + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; From dbbdbb7111ede8da03c683c46f7552f2a3465e45 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Thu, 15 Sep 2022 01:34:30 -0700 Subject: [PATCH 05/20] Added Androomba --- NPCs/CalamityGlobalNPC.cs | 8 +- NPCs/DraedonLabThings/Androomba.cs | 252 +++++++++++++++++++++++ NPCs/DraedonLabThings/Androomba.png | Bin 0 -> 5578 bytes NPCs/DraedonLabThings/Androomba_Glow.png | Bin 0 -> 2925 bytes 4 files changed, 257 insertions(+), 3 deletions(-) create mode 100644 NPCs/DraedonLabThings/Androomba.cs create mode 100644 NPCs/DraedonLabThings/Androomba.png create mode 100644 NPCs/DraedonLabThings/Androomba_Glow.png diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 62133dcc24..3becfc68af 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4810,11 +4810,13 @@ namespace CalamityMod.NPCs WeightedRandom pool = new WeightedRandom(); pool.Add(NPCID.None, 0f); pool.Add(NPCType(), 0.1f); + pool.Add(NPCType(), 0.05f); + // Normal droids are replaced with plague droids in the Jungle Lab. if (nearPlagueLab) { - pool.Add(NPCType(), 0.05f); - pool.Add(NPCType(), 0.05f); - pool.Add(NPCType(), 0.01f); + pool.Add(NPCType(), 0.075f); + pool.Add(NPCType(), 0.075f); + pool.Add(NPCType(), 0.04f); } else { diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs new file mode 100644 index 0000000000..74cc87f20b --- /dev/null +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -0,0 +1,252 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Critters; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.DraedonLabThings +{ + public class Androomba : ModNPC + { + public SoundStyle HurrySound = new("CalamityMod/Sounds/Custom/WulfrumDroidHurry", 2) { PitchVariance = 0.3f }; + public override void SetStaticDefaults() + { + this.HideFromBestiary(); + DisplayName.SetDefault("Androomba"); + Main.npcFrameCount[NPC.type] = 22; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.damage = 0; + NPC.width = 40; + NPC.height = 16; + NPC.lifeMax = 80; + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = false; + NPC.chaseable = false; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + DrawOffsetY = -17; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Slowly moving back and forth, these contraptions endlessly operate with the fruitless goal of cleaning the long abandoned labs.") + }); + } + + public override void AI() + { + // Gravity + NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y + 0.4f, -15f, 15f); + NPC.spriteDirection = (int)NPC.ai[2]; + switch (NPC.ai[0]) + { + // Idle + case 0: + { + if (NPC.ai[1] == 0) + { + NPC.ai[2] = Main.rand.NextBool(2) ? -1 : 1; + } + NPC.ai[1]++; + NPC.velocity.X = NPC.ai[2] * 2; + //if (NPC.collideX) + if (!Collision.CanHit(NPC.Center - Vector2.UnitX * NPC.ai[2] * 8f, 2, 2, NPC.Center + Vector2.UnitX * NPC.ai[2] * 32f, 8, 8)) + { + NPC.ai[2] *= -1; + } + // If she sees someone, start running + for (int i = 0; i < Main.maxPlayers; i++) + { + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[i].position, Main.player[i].width, Main.player[i].height) && NPC.ai[1] > 300) + { + ChangeAI(1); + } + } + } + break; + // Surprise and explode animations + case 1: + case 3: + { + NPC.velocity = Vector2.Zero; + if (NPC.ai[1] == 0) + { + if (NPC.ai[0] == 1) + { + SoundEngine.PlaySound(HurrySound, NPC.Center); + } + if (NPC.ai[0] == 3) + { + SoundEngine.PlaySound(NPC.DeathSound, NPC.Center); + } + } + NPC.ai[1]++; + } + break; + // Run!!! + case 2: + { + NPC.ai[1]++; + NPC.velocity.X = NPC.ai[2] * 4; + if (NPC.collideX) + { + ChangeAI(3); + } + else if (NPC.ai[1] > 480) // If the roomba is somehow still alive after 8 seconds and there are no players, calm down + { + for (int i = 0; i < Main.maxPlayers; i++) + { + if (!Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[i].position, Main.player[i].width, Main.player[i].height)) + { + ChangeAI(0); + } + } + } + } + break; + // Fatal eror (corpse) + case 4: + { + NPC.velocity = Vector2.Zero; + NPC.ai[1]++; + if (NPC.ai[1] > 1200) + { + NPC.active = false; + } + NPC.damage = 10; // Stay aware from fire, kids + } + break; + } + } + + public void ChangeAI(int phase) + { + NPC.ai[0] = phase; + NPC.ai[1] = 0; + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + /* + -Frame 0: Idle + -Frames 1-4: Moving + -Frames 5-6: Surprised animation + -Frames 7-12: Escaping loop + -Frames 13-17: Exploding animation + -Frames 18-21: Debris loop + */ + NPC.frameCounter += 1.0; + if (NPC.frameCounter > 6.0) + { + NPC.frameCounter = 0.0; + NPC.frame.Y += frameHeight; + } + + // Idle + if (NPC.ai[0] == 0 || NPC.IsABestiaryIconDummy) + { + if (NPC.frame.Y > frameHeight * 4) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = 1; + } + } + // Suprise! + else if (NPC.ai[0] == 1) + { + if (NPC.frame.Y < frameHeight * 5) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * 5; + } + if (NPC.frame.Y > frameHeight * 6) + { + ChangeAI(2); + } + } + // Run + else if (NPC.ai[0] == 2) + { + if (NPC.frame.Y < frameHeight * 7 || NPC.frame.Y > frameHeight * 12) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * 7; + } + } + // Explode + else if (NPC.ai[0] == 3) + { + if (NPC.frame.Y < frameHeight * 13) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * 13; + } + if (NPC.frame.Y > frameHeight * 17) + { + ChangeAI(4); + } + } + // Fire + else + { + if (NPC.frame.Y < frameHeight * 18 || NPC.frame.Y > frameHeight * 21) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * 18; + } + } + if (NPC.frame.Y >= frameHeight * 15 && NPC.active) + { + Lighting.AddLight(NPC.Center, 0.8f, 0.03f, 0.1f); + } + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override void OnCaughtBy(Player player, Item item, bool failed) + { + // You can't catch what's dead + if (NPC.ai[0] >= 3) + { + failed = true; + } + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/Androomba_Glow").Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + drawPosition.Y += DrawOffsetY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/DraedonLabThings/Androomba.png b/NPCs/DraedonLabThings/Androomba.png new file mode 100644 index 0000000000000000000000000000000000000000..6fde70d5f4e2713b43aa5c909edd0182c4d214a6 GIT binary patch literal 5578 zcmY*dd0diN_b;t!Y#*$tT&F~vGNo~$axEhj*UWtZODz{%as*2eE!zgmOvq4iDO_=Z zT+l?prZO{EL`6}gnl!`(OOeEoANIcQZ)To9o_inoJm;S0-0%5*?>X4BE_T~Ct8HGl zZrwJhJ>;BXG+VcBL*I`-C}t#mFTP?}A9v2qW*wzRV`|;H-8Z3-Qyy3IW_hmnU=s=L zpZOc_O&!1LWUN)}VCqgj^wZ;$9xAMjL22H*kNA-x6&q3`yAGV&O-`$QRYe!vc2>K- zD-&#=B|K6a_HZ}Z0Q`qD?5W!yYJ<1Wyt(?T)+Y7H&N0It%%`3NQ9|zu^Ha;G0^?7z zWNp(g;W2#uB|%TfSxhqJ#h6jOgMLh5q=&sD}dk{8bE{axrUN4 z;`$$5Jo-Iw1xepjp#6p8%NHkZt%m%SaU*&r1(f80UX_pi*!hkSlmDB%3Ug!xm}ob% z+X+WyEPH)1*Mah{3Vwq22TR5c4q5nW1Gb61Q&yaz{cI}#0TAwQD>l{I$BgIFmG!KN>B!y?1r&bZZstOB zCTz-69i96CX);aq%1pn**BB>ak@9dKpffpI~wqZcQY`Wu%%Y!}b@B${` z5e{VpJ?2n0ifsazaIT13`y>GJ=VWB>YNgiktZ z8q_)X(R0r8za^m540nV43-!-QOBF4a2qr~C^M{l00W}9ls3pfKs9|&{@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Ef3u5v z^lbXgABtv3_V*^qe-As)SBmk75JCm*KUCBe4?@+4;_aReqV|3Pwg3{@N(KfjrunTpC^FoimsU*{ zS$RaG62u=elhWswT3hBrCyWgP4CHwV3B9YGq|g*^kvw9;BD?RbGI_i~u3sb;6Y% zUKpW?`}e6TV^KmB094z`W6$HBm<3fUL=6$YAP;~*V$^`4tUuYuXhFt z#xA*ChhcN2klO+7fy|xl^b2&fxV8z7xt_qFfPCq|T!8{9-B3lI$>dHONsH7X0c8)P;HTMJf?O|vPKYI9H+UQtHRjRBZxuDU$jpQi{-1! zQnVDVD827a9ZhtZ0FqYV8X|VCX;@E+%xlK7%9g|m`qZ+)!@6L@F+nuZF0k_wJ<`@xIid2=TrX=H;HO{ literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/Androomba_Glow.png b/NPCs/DraedonLabThings/Androomba_Glow.png new file mode 100644 index 0000000000000000000000000000000000000000..c87224aa37c937d6548ec187bc3ea38c64bbbff7 GIT binary patch literal 2925 zcmeHJi&N9b7LMiN1(Z4pf*`~J>hKJsfW#C{VTefxAS6GC66K*q!doOTJmnfLSOP+M zB)kNKL`bTD5(p4^UW`;|g^-XE5U{8`(uQ6h5lsj*T%FsickW-%?l(JUcV~9b+3$RN zW^;VJk$bg`v_T-yUNp)btFkZs2o;U(2XJ-jt*N@Mx=-pqszlX(ikS-2x5#oeAl9&Y zbH`4(O=@$&ANk*jMo7TTEaU~aZkT78{SPRNu17{~n*HgRV89bcDAAFAy2)!k3Hojk$amdT<Z#x(+av534yhHYBl!W9>9x8rim`WYw+wtiu`4{(0IU!lvv(L zC2gtOEM8~$#Cj?BGF6U~tZS6~qg*o%zMBIa9v>-x1NCCm5xa>cb{HNX`LULa#p4>-79Fg_U!9DQ7%*?uSdt}X#*XGn^Tp1zH_$eAds>P2?1Ar) z$;+11kj{>bkfDdor_L1H+<}zz^h*0$!UqOfRqVs*8B<#K9v7~!;m#BV*Vb57_86e` zw>Hye1#8DI@Ah{bH+WiXfC(ETrw+1AQQi*KzDrQQ3lJY-<`<3)v48Ix%~mr+gFoa> z&zdIxeEs(A!YCqd?7ZFSo7$XAq0wYuFu|pRyHm zO3j<^cL}X-f_q4RIOF6O|BvOM`$BC0Ak*aY)%N~(z_)Ok2|ZEBXh$kT=j#?18iHuE zCtl^6L^Cflg93Z}R*W5zv8Swa8Q03^@4Mg)FjK1+E?UTr7mN7(=(4Jb-ec^9kX_#~633t&9EnTRK<{ z<%&xRCCQrLneI8Dz?C3y=g-B=o~q>3v105LJQ*}!a_w$W&?>R`5F&l-xt+;|C#6n) zyv*Y%Z@!#+E@0NIvEg-Y?WpE>o&iEOd_?@fxb(jS5^z@elfO6xM$wbteKU0OIN(4> z{f?~GNS}W0bjsUM?K>$yhn}dS)VC1R*x2eEI+v{2)}9xCoHw3l5U3$U1D_^ z9{tUJ{ABCn}XQWOx=D@Tq zA>k_7;WpLQLsOW>CviZmr@Gd`ie*1d!X#9JQICK0Y(|6#LEZ?x!p+$B zZi_oR#2J!HFL3`)adfKP8ul&rJt>-F*|ujAJP2K6kyh&7Xme>w*?fDySd~l>57!-P zc<~B^BF|v2G?IEI_(vTmat-SeQkSA8>N6%QHMxFS8yNNsKr1Q_7@IlUa8?h=KU7DC z5587ruPxp`5#s9-ec<`315t4knwif%DD6EGdXM;o-tbKW_r}QMnmXHxp?_XeEQ?$9 zy%HkD_DzFvK&cINvj|!FgQcW+K4z&S468R@+7Ea@PK*e7*xo}zkzkdlQg+0X+&X#a lw^0+fhUXT|mB-|3YjDZ;Q;(aG{-<}oKWK!vdy`u*`F9AQlFR@A literal 0 HcmV?d00001 From 5a440e16b941f3511d435b1fdf52ff448f157507 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Thu, 15 Sep 2022 13:23:00 -0700 Subject: [PATCH 06/20] added friendly Androomba --- NPCs/DraedonLabThings/Androomba.cs | 1 - NPCs/TownNPCs/AndroombaFriendly.cs | 248 ++++++++++++++++++ NPCs/TownNPCs/AndroombaFriendly.png | Bin 0 -> 1267 bytes NPCs/TownNPCs/AndroombaFriendly_Astral.png | Bin 0 -> 417 bytes .../TownNPCs/AndroombaFriendly_Corruption.png | Bin 0 -> 420 bytes NPCs/TownNPCs/AndroombaFriendly_Crimson.png | Bin 0 -> 414 bytes NPCs/TownNPCs/AndroombaFriendly_Hallow.png | Bin 0 -> 417 bytes NPCs/TownNPCs/AndroombaFriendly_Mushroom.png | Bin 0 -> 431 bytes NPCs/TownNPCs/AndroombaFriendly_Pure.png | Bin 0 -> 424 bytes 9 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 NPCs/TownNPCs/AndroombaFriendly.cs create mode 100644 NPCs/TownNPCs/AndroombaFriendly.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Astral.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Corruption.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Crimson.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Hallow.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Mushroom.png create mode 100644 NPCs/TownNPCs/AndroombaFriendly_Pure.png diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index 74cc87f20b..5f35e69086 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -16,7 +16,6 @@ namespace CalamityMod.NPCs.DraedonLabThings public SoundStyle HurrySound = new("CalamityMod/Sounds/Custom/WulfrumDroidHurry", 2) { PitchVariance = 0.3f }; public override void SetStaticDefaults() { - this.HideFromBestiary(); DisplayName.SetDefault("Androomba"); Main.npcFrameCount[NPC.type] = 22; NPCID.Sets.CountsAsCritter[NPC.type] = true; diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs new file mode 100644 index 0000000000..f97b91692c --- /dev/null +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -0,0 +1,248 @@ +using CalamityMod.BiomeManagers; +using CalamityMod.Items.Ammo; +using CalamityMod.Items.Critters; +using CalamityMod.World; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.GameContent.Bestiary; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.NPCs.TownNPCs +{ + public class AndroombaFriendly : ModNPC + { + public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); + public override void SetStaticDefaults() + { + DisplayName.SetDefault("Androomba"); + Main.npcFrameCount[NPC.type] = 9; + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } + + public override void SetDefaults() + { + NPC.aiStyle = -1; + AIType = -1; + NPC.damage = 0; + NPC.width = 40; + NPC.height = 16; + NPC.lifeMax = 80; + NPC.knockBackResist = 0f; + NPC.noGravity = true; + NPC.noTileCollide = false; + NPC.chaseable = false; + NPC.HitSound = SoundID.NPCHit4; + NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); + SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + } + + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) + { + bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { + + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("placeholdertext") + }); + } + + public override void AI() + { + // Gravity + NPC.velocity.Y = MathHelper.Clamp(NPC.velocity.Y + 0.4f, -15f, 15f); + NPC.spriteDirection = (int)NPC.ai[2]; + switch (NPC.ai[0]) + { + case 0: + { + if (Main.netMode != NetmodeID.Server) + { + bool holdingsol = ((Main.LocalPlayer.HeldItem.type >= ItemID.GreenSolution && Main.LocalPlayer.HeldItem.type <= ItemID.RedSolution) || Main.LocalPlayer.HeldItem.type == ModContent.ItemType()); + if (NPC.Hitbox.Contains(Main.MouseWorld.ToPoint()) && holdingsol && Main.LocalPlayer.Distance(NPC.Center) < 450) + { + Main.LocalPlayer.cursorItemIconEnabled = true; + Main.LocalPlayer.cursorItemIconID = Main.LocalPlayer.HeldItem.type; + Main.LocalPlayer.cursorItemIconText = ""; + NPC.ShowNameOnHover = false; + + if (Main.mouseRight && Main.mouseRightRelease && Main.LocalPlayer.Distance(NPC.Center) < 300) + { + NPC.netUpdate = true; + Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); + SoundEngine.PlaySound(SoundID.Item87); + + int soltype = 0; + if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) + { + soltype = 5; + } + else + { + switch (Main.LocalPlayer.HeldItem.type) + { + case ItemID.GreenSolution: + soltype = 0; + break; + case ItemID.PurpleSolution: + soltype = 1; + break; + case ItemID.BlueSolution: + soltype = 2; + break; + case ItemID.DarkBlueSolution: + soltype = 3; + break; + case ItemID.RedSolution: + soltype = 4; + break; + } + } + NPC.ai[3] = soltype; + ChangeAI(1); + } + } + + else + NPC.ShowNameOnHover = true; + } + } + break; + // Main + case 1: + { + if (NPC.ai[1] == 0) + { + NPC.ai[2] = NPC.direction; + } + NPC.ai[1]++; + NPC.velocity.X = NPC.ai[2] * 2; + if (!Collision.CanHit(NPC.Center - Vector2.UnitX * NPC.ai[2] * 8f, 2, 2, NPC.Center + Vector2.UnitX * NPC.ai[2] * 32f, 8, 8)) + { + NPC.ai[2] *= -1; + ChangeAI(2); + } + Convert((int)NPC.ai[3]); + } + break; + // Turn + case 2: + { + NPC.velocity.X = 0; + Convert((int)NPC.ai[3]); + } + break; + } + } + + public void Convert(int conversionType) + { + int x = (int)(NPC.Center.X / 16f); + int y = (int)(NPC.Center.Y / 16f); + if (conversionType <= 4) + { + WorldGen.Convert(x, y, conversionType, 2); + } + else + { + AstralBiome.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); + } + } + + public void ChangeAI(int phase) + { + NPC.ai[0] = phase; + NPC.ai[1] = 0; + } + + public override bool? CanBeHitByItem(Player player, Item item) => null; + + public override bool? CanBeHitByProjectile(Projectile projectile) => null; + + public override void FindFrame(int frameHeight) + { + /* + -Frame 0: Asleep + -Frames 1-4: Moving + -Frames 5-9: Turning + */ + NPC.frameCounter += 1.0; + if (NPC.frameCounter > 6.0) + { + NPC.frameCounter = 0.0; + NPC.frame.Y += frameHeight; + } + + // Idle + if (NPC.ai[0] == 1 || NPC.IsABestiaryIconDummy) + { + if (NPC.frame.Y > frameHeight * 4) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight; + } + } + // Turnaround + else if (NPC.ai[0] == 2) + { + if (NPC.frame.Y < frameHeight * 5 || NPC.frame.Y > frameHeight * 8) + { + NPC.frameCounter = 0.0; + NPC.frame.Y = frameHeight * 5; + } + if (NPC.frame.Y > frameHeight * 8) + { + ChangeAI(1); + } + } + // Sleep + else + { + NPC.frame.Y = 0; + } + } + + public override void HitEffect(int hitDirection, double damage) + { + for (int i = 0; i < 6; i++) + Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); + } + + public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) + { + Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; + string pathextenstion = "Pure"; + switch (NPC.ai[3]) + { + case 0: + pathextenstion = "Pure"; + break; + case 1: + pathextenstion = "Corruption"; + break; + case 2: + pathextenstion = "Hallow"; + break; + case 3: + pathextenstion = "Mushroom"; + break; + case 4: + pathextenstion = "Crimson"; + break; + case 5: + pathextenstion = "Astral"; + break; + } + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/TownNPCs/AndroombaFriendly_" + pathextenstion).Value; + Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; + drawPosition.Y += DrawOffsetY; + SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; + spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + spriteBatch.Draw(glowmask, drawPosition, NPC.frame, NPC.GetAlpha(Color.White), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); + return false; + } + } +} diff --git a/NPCs/TownNPCs/AndroombaFriendly.png b/NPCs/TownNPCs/AndroombaFriendly.png new file mode 100644 index 0000000000000000000000000000000000000000..6ce44bc16364683792eda7c2ce8e7ca93143b236 GIT binary patch literal 1267 zcmVPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D1c*sQK~#8N?VMd} z(@-47Gq-uMcB>oRCW>}4?1hR53d%qfVfYOcFTL|)_%XcmQuG_hKonspD2O;OCS&V- zT{m#uR@jT6$-n0xlGDbdO-_`*#JJQ+eNmAy~ z+&ro6H0j4rA4qMyWi`n0`*-iq!Q-dTNR#H`g-fKD&sRy`FD#PYyLyiF$=lDQjB$>q zUU0`jkBeTr$_Ymif`7oX$wPJ$J^R* zZfDD*CDI@&Cnm+7pQzu~QmsaM`|K%F=J}UaJvYDSO4NobG%e))%k;iebT|fqoj?7es2%5a7OUVC;eLv|u7We}$}#`|006qd9jjm!TuOMy zxa2fe!6~NAaU@xaNxk4mvV>+1k}Opq$r9?|>p8=~D!3kLb3DhG;Wz*Q006q7FRuxf zjGSm`Jvxk(U@=K0Sxm2qmi~^bPOxO+CR*A$o>{@;CR%VjDWWD?`a7;V!IFuaXld)X z+m3U)8nzaTiJN3Gy{^sD*Kz(tcKyQW5SR$n8!vg85y^F0M(cK5Cen;3Y$nw0wfv~p z@EP+QS2ZJ&XFk>90BO`~_>8uWr(W=&nNQSf_zWEHm2R)$GjKd@%qzI6IjB6>WTLK` zV6=5Su;&b$gC@OtBI^A=j5&_yWeytj6l}(*Ixa)bM|cL1{0;Hnl^EI%osUVA*XpJ#PEzr^|}^Lb6>oEMQY)~-+USHBF z2TXzvX|WlO_gwIx)HN**pW|6`cnZ#$A7_B7kh4V@Z5{8r9p@{()0GNo7`XO)v{>v+FVhlkFO$%*51@U6K|Tk+4XwYj-vE&QxodwaXq zk^TXzvE6jH;gL~#&szN#y-yWmV`ch(%d4&RisrWCL3jNzs#9A=PH**hT$iy5r?=WV d4${T4{sH>-Oig7vL%#q3002ovPDHLkV1h4YUY`H} literal 0 HcmV?d00001 diff --git a/NPCs/TownNPCs/AndroombaFriendly_Astral.png b/NPCs/TownNPCs/AndroombaFriendly_Astral.png new file mode 100644 index 0000000000000000000000000000000000000000..77b257df5bd2973cba0c910f14527528f45afd09 GIT binary patch literal 417 zcmeAS@N?(olHy`uVBq!ia0vp^dO-Y&gAGXDJy1RsNHG=%xjQkeJ16rJ$YDu$^mSxl z*x1kgCy^D%=PdAuEM{QfI}E~%$MaXD05zC-x;TbZ#J#=a>vcFlq~YR~xjO{h^PE}K zcd5U&fE z2&n%<_|4rv;zS)z25q`_2`H)&2^8EA@=b4FIBUSBDQmWV+0~}(B?eM?KXtd~`ge&<+~=Q|KGw;m&tly z!x<8S&xK{b{+=mXTHE_7XYc;6^K`e0HE>I`#jBrxWc1K~_c5S344$rjF6*2UngD(e Bw=n8x;TbZ#J#=a>vcFlq~YR~)E&&>4?NWM zTnhr5ybBj8hdjzdTfurL1$@^>_D*y4>y8=B+Z_xXJccdzhf_ zt_vW;85(>oqt~vzzdZEHSJPFSzy7;cz3oaAgIvh;cq~T)7_l4SmEZ-Mp zU)syjq@)<_@+#-kJ76=DL#u4XdDo{c>ANGUdI0OtE8Ksqw}6U zy=r;p^s?v6+cTrq+uy(Z>*3>UtK~i)pMJ}WY59Hsp8etXQIE3J=Usa()%T|S5m5h! z@SD4T#ECkb4BB+<5>Qkl5-7MKO( zEai3I;tUjgaOlvkkXfFZA+D>JZs}XSJ^iH?1H&7~ZikW~~-}vk@n0t%kbm7H+N~_{;uid&l%Xdvq|G$NyE|c}ZhBG7t wp9{-={XJ8(w6^zE&ffiB=jm=0Yv7h>i&u=l^vZC%E6529p00i_>zopr07@{keE87I-aUG&Yh(3J|NQ}k|bF0ETbPe=Y$@UrP&%P$>Y0U!EWEQr@XQ$HCY|WjotHgCyn(s(r+I<|Ww+d*9Vex~uoDl^Ljd1HXCs-iYGKH+YJ54b4v6+Ex80Dq3iI_tkA* zc-Jo3_AaX(sEFaf!jjcn_gYs@di^v@mqB{QviQ=Ft6{VEZ4Cj*db;|#taD0e0s#4O BssI20 literal 0 HcmV?d00001 diff --git a/NPCs/TownNPCs/AndroombaFriendly_Mushroom.png b/NPCs/TownNPCs/AndroombaFriendly_Mushroom.png new file mode 100644 index 0000000000000000000000000000000000000000..8fb03ced68db742b8fbaf73d0a2bb4bc553d1787 GIT binary patch literal 431 zcmeAS@N?(olHy`uVBq!ia0vp^dO-Y&gAGXDJy1RsNHG=%xjQkeJ16rJ$YDu$^mSxl z*x1kgCy^D%=PdAuEM{QfI}E~%$MaXD05!OHx;TbZ#J#=k=yljZqV3_8(>qEY=2lIt zVyT{Z?^vt1zp&@Y_mA2Wm!-^_@WUqHR07k}*T?oe0vZPbYo6A~9)D>nzglkZzd-%Z zzu$$}|M-3Txy9aRkLO32)Wt>ZDES|>JGN%yrAz0()r+$;Ff=q>{u3wS`{ZlQ&iVP% zgTK!6wE6k}&bsfPuYY&HT)VdH_mum4oOC3*pSylGpS1qH@5x#Hs{=Oytx{NN#;>}1 z^E1(+nWwt7BC}^s>n**$B!v+uCA~UK?d=AT6!)3#tahlBEE7a(S=yn@^b=E2qx|nhFFBf%Ep~)jga4 zb<2vczrv=!E-cr(mVE8*;kTP^{XPA?=wHd-oi=J~e}1blmG9bLU;kIbF1-7$UfrhR z|N77W+&{|5z@YH>eC$$}@RKXz6m@SzZOZ!Zw06pxuO$+y+(6@-l0FA)vRWOdIBn&Q z6_ZR)?a7HMR{_i1h}dY9**-UPy+CwAOo+8iYMj|x>q%uCKutMoB4!r3YF!U1y8cx! zY8Non*aK?%-)#PKZdG_kxzSSV1;uxNs_c%v!_5v~mwT+U`qLOkZY%Tr% zW9v2*J@M7KFQubAbMIc|13HqS!TDuac6IqDmFuUkMlqNf`0jradZ90?`|(nsB!j1` KpUXO@geCyK3a^L& literal 0 HcmV?d00001 From c9d33d29d2bb4405275884a4b5243c29368a882f Mon Sep 17 00:00:00 2001 From: GinYuH Date: Thu, 15 Sep 2022 16:05:58 -0700 Subject: [PATCH 07/20] roomba item, and various fixes --- Items/Critters/CleaningRoomba.cs | 35 ++++++++ Items/Critters/CleaningRoomba.png | Bin 0 -> 383 bytes NPCs/DraedonLabThings/Androomba.cs | 14 +--- NPCs/TownNPCs/AndroombaFriendly.cs | 124 ++++++++++++++++------------- 4 files changed, 105 insertions(+), 68 deletions(-) create mode 100644 Items/Critters/CleaningRoomba.cs create mode 100644 Items/Critters/CleaningRoomba.png diff --git a/Items/Critters/CleaningRoomba.cs b/Items/Critters/CleaningRoomba.cs new file mode 100644 index 0000000000..75dccf2f6f --- /dev/null +++ b/Items/Critters/CleaningRoomba.cs @@ -0,0 +1,35 @@ +using CalamityMod.NPCs.TownNPCs; +using CalamityMod.Rarities; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class CleaningRoomba : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 5; + DisplayName.SetDefault("Cleaning Roomba"); + Tooltip.SetDefault("Right click the roomba with a solution to insert it\n"+"While a solution is inserted, the roomba will activate and start spreading the contents of the solution"); + } + + public override void SetDefaults() + { + Item.useStyle = ItemUseStyleID.Swing; + Item.autoReuse = true; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.maxStack = 9999; + Item.consumable = true; + Item.noUseGraphic = true; + Item.value = Item.buyPrice(0, 0, 30, 0); + Item.width = 36; + Item.height = 16; + Item.makeNPC = (short)ModContent.NPCType(); + Item.rare = ModContent.RarityType(); + } + } +} diff --git a/Items/Critters/CleaningRoomba.png b/Items/Critters/CleaningRoomba.png new file mode 100644 index 0000000000000000000000000000000000000000..82ab4e0dbce55c733bbea6718acf1124d87b3045 GIT binary patch literal 383 zcmV-_0f7FAP)Px$IY~r8R7i=<)lDmeVHC#k-$*vh4CSTBOUcMf5{i^a$;KDpBk%$2>@Do=EPV(i zQX-PXEY#GDg&GvY&Sot1G|e+Z7HXbrb>F9RpL6vA002ovPDHLkV1huEuNVLT literal 0 HcmV?d00001 diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index 5f35e69086..28e98393b5 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - NPC.catchItem = (short)ModContent.ItemType(); + NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; DrawOffsetY = -17; } @@ -84,7 +84,7 @@ namespace CalamityMod.NPCs.DraedonLabThings case 1: case 3: { - NPC.velocity = Vector2.Zero; + NPC.velocity.X = 0; if (NPC.ai[1] == 0) { if (NPC.ai[0] == 1) @@ -93,6 +93,7 @@ namespace CalamityMod.NPCs.DraedonLabThings } if (NPC.ai[0] == 3) { + NPC.catchItem = 0; SoundEngine.PlaySound(NPC.DeathSound, NPC.Center); } } @@ -227,15 +228,6 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } - public override void OnCaughtBy(Player player, Item item, bool failed) - { - // You can't catch what's dead - if (NPC.ai[0] >= 3) - { - failed = true; - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index f97b91692c..5850d1c7d0 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -28,7 +28,7 @@ namespace CalamityMod.NPCs.TownNPCs NPC.aiStyle = -1; AIType = -1; NPC.damage = 0; - NPC.width = 40; + NPC.width = 36; NPC.height = 16; NPC.lifeMax = 80; NPC.knockBackResist = 0f; @@ -37,7 +37,7 @@ namespace CalamityMod.NPCs.TownNPCs NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - NPC.catchItem = (short)ModContent.ItemType(); + NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } @@ -59,73 +59,24 @@ namespace CalamityMod.NPCs.TownNPCs { case 0: { - if (Main.netMode != NetmodeID.Server) + if (NPC.ai[1] == 0) { - bool holdingsol = ((Main.LocalPlayer.HeldItem.type >= ItemID.GreenSolution && Main.LocalPlayer.HeldItem.type <= ItemID.RedSolution) || Main.LocalPlayer.HeldItem.type == ModContent.ItemType()); - if (NPC.Hitbox.Contains(Main.MouseWorld.ToPoint()) && holdingsol && Main.LocalPlayer.Distance(NPC.Center) < 450) - { - Main.LocalPlayer.cursorItemIconEnabled = true; - Main.LocalPlayer.cursorItemIconID = Main.LocalPlayer.HeldItem.type; - Main.LocalPlayer.cursorItemIconText = ""; - NPC.ShowNameOnHover = false; - - if (Main.mouseRight && Main.mouseRightRelease && Main.LocalPlayer.Distance(NPC.Center) < 300) - { - NPC.netUpdate = true; - Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); - SoundEngine.PlaySound(SoundID.Item87); - - int soltype = 0; - if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) - { - soltype = 5; - } - else - { - switch (Main.LocalPlayer.HeldItem.type) - { - case ItemID.GreenSolution: - soltype = 0; - break; - case ItemID.PurpleSolution: - soltype = 1; - break; - case ItemID.BlueSolution: - soltype = 2; - break; - case ItemID.DarkBlueSolution: - soltype = 3; - break; - case ItemID.RedSolution: - soltype = 4; - break; - } - } - NPC.ai[3] = soltype; - ChangeAI(1); - } - } - - else - NPC.ShowNameOnHover = true; + NPC.ai[2] = (Main.LocalPlayer.position.X <= NPC.position.X) ? 1 : -1; } + GrabSolution(true); } break; // Main case 1: { - if (NPC.ai[1] == 0) - { - NPC.ai[2] = NPC.direction; - } NPC.ai[1]++; NPC.velocity.X = NPC.ai[2] * 2; if (!Collision.CanHit(NPC.Center - Vector2.UnitX * NPC.ai[2] * 8f, 2, 2, NPC.Center + Vector2.UnitX * NPC.ai[2] * 32f, 8, 8)) { - NPC.ai[2] *= -1; ChangeAI(2); } Convert((int)NPC.ai[3]); + GrabSolution(false); } break; // Turn @@ -133,11 +84,69 @@ namespace CalamityMod.NPCs.TownNPCs { NPC.velocity.X = 0; Convert((int)NPC.ai[3]); + GrabSolution(false); } break; } } + public void GrabSolution(bool reset = false) + { + if (Main.netMode != NetmodeID.Server) + { + bool holdingsol = ((Main.LocalPlayer.HeldItem.type >= ItemID.GreenSolution && Main.LocalPlayer.HeldItem.type <= ItemID.RedSolution) || Main.LocalPlayer.HeldItem.type == ModContent.ItemType()); + if (NPC.Hitbox.Contains(Main.MouseWorld.ToPoint()) && holdingsol && Main.LocalPlayer.Distance(NPC.Center) < 450) + { + Main.LocalPlayer.cursorItemIconEnabled = true; + Main.LocalPlayer.cursorItemIconID = Main.LocalPlayer.HeldItem.type; + Main.LocalPlayer.cursorItemIconText = ""; + NPC.ShowNameOnHover = false; + + if (Main.mouseRight && Main.mouseRightRelease && Main.LocalPlayer.Distance(NPC.Center) < 300) + { + NPC.netUpdate = true; + Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); + SoundEngine.PlaySound(SoundID.Item87); + + int soltype = 0; + if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) + { + soltype = 5; + } + else + { + switch (Main.LocalPlayer.HeldItem.type) + { + case ItemID.GreenSolution: + soltype = 0; + break; + case ItemID.PurpleSolution: + soltype = 1; + break; + case ItemID.BlueSolution: + soltype = 2; + break; + case ItemID.DarkBlueSolution: + soltype = 3; + break; + case ItemID.RedSolution: + soltype = 4; + break; + } + } + NPC.ai[3] = soltype; + if (reset) + { + ChangeAI(1); + } + } + } + + else + NPC.ShowNameOnHover = true; + } + } + public void Convert(int conversionType) { int x = (int)(NPC.Center.X / 16f); @@ -148,7 +157,7 @@ namespace CalamityMod.NPCs.TownNPCs } else { - AstralBiome.ConvertToAstral(x - 1, x + 1, y - 1, y + 1); + AstralBiome.ConvertToAstral(x - 2, x + 2, y - 2, y + 2); } } @@ -188,13 +197,14 @@ namespace CalamityMod.NPCs.TownNPCs // Turnaround else if (NPC.ai[0] == 2) { - if (NPC.frame.Y < frameHeight * 5 || NPC.frame.Y > frameHeight * 8) + if (NPC.frame.Y < frameHeight * 5) { NPC.frameCounter = 0.0; NPC.frame.Y = frameHeight * 5; } if (NPC.frame.Y > frameHeight * 8) { + NPC.ai[2] *= -1; ChangeAI(1); } } From b4e5ed79b4a34cd7e2a63247bcf9302e7b18c424 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Thu, 15 Sep 2022 21:48:38 -0700 Subject: [PATCH 08/20] misc fixes --- .../{CleaningRoomba.cs => AndroombaItem.cs} | 6 +-- .../{CleaningRoomba.png => AndroombaItem.png} | Bin NPCs/DraedonLabThings/Androomba.cs | 4 +- NPCs/DraedonLabThings/Nanodroid.cs | 2 +- NPCs/TownNPCs/AndroombaFriendly.cs | 48 ++++++++++++++---- 5 files changed, 45 insertions(+), 15 deletions(-) rename Items/Critters/{CleaningRoomba.cs => AndroombaItem.cs} (86%) rename Items/Critters/{CleaningRoomba.png => AndroombaItem.png} (100%) diff --git a/Items/Critters/CleaningRoomba.cs b/Items/Critters/AndroombaItem.cs similarity index 86% rename from Items/Critters/CleaningRoomba.cs rename to Items/Critters/AndroombaItem.cs index 75dccf2f6f..aa8c35b389 100644 --- a/Items/Critters/CleaningRoomba.cs +++ b/Items/Critters/AndroombaItem.cs @@ -6,13 +6,13 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Critters { - public class CleaningRoomba : ModItem + public class AndroombaItem : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 5; - DisplayName.SetDefault("Cleaning Roomba"); - Tooltip.SetDefault("Right click the roomba with a solution to insert it\n"+"While a solution is inserted, the roomba will activate and start spreading the contents of the solution"); + DisplayName.SetDefault("Androomba"); + Tooltip.SetDefault("Right click the roomba with a solution to insert it\n"+"While a solution is inserted, the roomba will start spreading its contents"); } public override void SetDefaults() diff --git a/Items/Critters/CleaningRoomba.png b/Items/Critters/AndroombaItem.png similarity index 100% rename from Items/Critters/CleaningRoomba.png rename to Items/Critters/AndroombaItem.png diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index 28e98393b5..8a79fc9eca 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -35,7 +35,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - NPC.catchItem = (short)ModContent.ItemType(); + NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; DrawOffsetY = -17; } @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.DraedonLabThings bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Slowly moving back and forth, these contraptions endlessly operate with the fruitless goal of cleaning the long abandoned labs.") + new FlavorTextBestiaryInfoElement("Slowly moving back and forth, these contraptions operate endlessly with the fruitless goal of cleaning the long, now abandoned labs.") }); } diff --git a/NPCs/DraedonLabThings/Nanodroid.cs b/NPCs/DraedonLabThings/Nanodroid.cs index 7e89709ab6..ec37040409 100644 --- a/NPCs/DraedonLabThings/Nanodroid.cs +++ b/NPCs/DraedonLabThings/Nanodroid.cs @@ -33,7 +33,7 @@ namespace CalamityMod.NPCs.DraedonLabThings bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much the smaller things contribute.") + new FlavorTextBestiaryInfoElement("Not every creation has to be large and flashy to be a success, sometimes it's good to take a step back and appreciate how much that smaller things such as these devices contribute.") }); } diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index 5850d1c7d0..b37df585c3 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -15,10 +15,9 @@ namespace CalamityMod.NPCs.TownNPCs { public class AndroombaFriendly : ModNPC { - public static Rectangle MouseScreenArea => Utils.CenteredRectangle(Main.MouseScreen, Vector2.One * 2f); public override void SetStaticDefaults() { - DisplayName.SetDefault("Androomba"); + DisplayName.SetDefault("Androomba Pal"); Main.npcFrameCount[NPC.type] = 9; NPCID.Sets.CountsAsCritter[NPC.type] = true; } @@ -31,13 +30,14 @@ namespace CalamityMod.NPCs.TownNPCs NPC.width = 36; NPC.height = 16; NPC.lifeMax = 80; + NPC.friendly = true; NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = false; NPC.chaseable = false; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - NPC.catchItem = (short)ModContent.ItemType(); + NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } @@ -46,7 +46,7 @@ namespace CalamityMod.NPCs.TownNPCs bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("placeholdertext") + new FlavorTextBestiaryInfoElement("Easily reversed engineered, these robots can be made to spread whatever you put into them, giving them a new purpose.") }); } @@ -105,8 +105,6 @@ namespace CalamityMod.NPCs.TownNPCs if (Main.mouseRight && Main.mouseRightRelease && Main.LocalPlayer.Distance(NPC.Center) < 300) { NPC.netUpdate = true; - Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); - SoundEngine.PlaySound(SoundID.Item87); int soltype = 0; if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) @@ -134,10 +132,15 @@ namespace CalamityMod.NPCs.TownNPCs break; } } - NPC.ai[3] = soltype; - if (reset) + if (NPC.ai[3] != soltype || NPC.ai[0] == 0) { - ChangeAI(1); + Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); + SoundEngine.PlaySound(SoundID.Item87); + NPC.ai[3] = soltype; + if (reset) + { + ChangeAI(1); + } } } } @@ -153,6 +156,32 @@ namespace CalamityMod.NPCs.TownNPCs int y = (int)(NPC.Center.Y / 16f); if (conversionType <= 4) { + ConvertType type = ConvertType.Pure; + switch (conversionType) + { + case 0: + type = ConvertType.Pure; + break; + case 1: + type = ConvertType.Corrupt; + break; + case 2: + type = ConvertType.Hallow; + break; + case 4: + type = ConvertType.Crimson; + break; + } + for (int i = 0; i < 3; i++) + { + for (int j = 0; j < 3; j++) + { + AstralBiome.ConvertFromAstral(x + i, y + j, type); + AstralBiome.ConvertFromAstral(x - i, y - j, type); + AstralBiome.ConvertFromAstral(x + i, y - j, type); + AstralBiome.ConvertFromAstral(x - i, y + j, type); + } + } WorldGen.Convert(x, y, conversionType, 2); } else @@ -204,6 +233,7 @@ namespace CalamityMod.NPCs.TownNPCs } if (NPC.frame.Y > frameHeight * 8) { + NPC.frame.Y = frameHeight; NPC.ai[2] *= -1; ChangeAI(1); } From 159bb017045b09f4bbfb6ccb2df0274cbca0e9a9 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Thu, 15 Sep 2022 22:39:56 -0700 Subject: [PATCH 09/20] bestiary grammar, friend no longer despawns --- NPCs/DraedonLabThings/Androomba.cs | 2 +- NPCs/TownNPCs/AndroombaFriendly.cs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index 8a79fc9eca..f056593e74 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -45,7 +45,7 @@ namespace CalamityMod.NPCs.DraedonLabThings bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Slowly moving back and forth, these contraptions operate endlessly with the fruitless goal of cleaning the long, now abandoned labs.") + new FlavorTextBestiaryInfoElement("Slowly moving back and forth, these contraptions operate endlessly with the fruitless goal of cleaning the now long abandoned labs.") }); } diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index b37df585c3..f787d0e8c2 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -31,6 +31,7 @@ namespace CalamityMod.NPCs.TownNPCs NPC.height = 16; NPC.lifeMax = 80; NPC.friendly = true; + NPC.townNPC = true; NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = false; @@ -41,6 +42,11 @@ namespace CalamityMod.NPCs.TownNPCs SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } + public override bool CanChat() + { + return false; + } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { From a780bd30de496f646d865fdb8368bde88df238a3 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Fri, 16 Sep 2022 01:31:39 -0700 Subject: [PATCH 10/20] item now works --- Items/Critters/AndroombaItem.cs | 26 +++++++++++++++++++++++--- NPCs/TownNPCs/AndroombaFriendly.cs | 1 - 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Items/Critters/AndroombaItem.cs b/Items/Critters/AndroombaItem.cs index aa8c35b389..e45f024f59 100644 --- a/Items/Critters/AndroombaItem.cs +++ b/Items/Critters/AndroombaItem.cs @@ -1,6 +1,7 @@ using CalamityMod.NPCs.TownNPCs; using CalamityMod.Rarities; using Terraria; +using Terraria.DataStructures; using Terraria.ID; using Terraria.ModLoader; @@ -20,16 +21,35 @@ namespace CalamityMod.Items.Critters Item.useStyle = ItemUseStyleID.Swing; Item.autoReuse = true; Item.useTurn = true; - Item.useAnimation = 15; - Item.useTime = 10; + Item.useAnimation = 25; + Item.useTime = 25; Item.maxStack = 9999; Item.consumable = true; Item.noUseGraphic = true; Item.value = Item.buyPrice(0, 0, 30, 0); Item.width = 36; Item.height = 16; - Item.makeNPC = (short)ModContent.NPCType(); + //Item.makeNPC = (short)ModContent.NPCType(); This doesn't work apparently Item.rare = ModContent.RarityType(); } + + public override bool? UseItem(Player player) + { + if (Main.LocalPlayer.Distance(Main.MouseWorld) < 300) + { + if (Main.netMode != NetmodeID.MultiplayerClient) + { + NPC.NewNPC(new EntitySource_BossSpawn(player), (int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, ModContent.NPCType(), 1); + } + else + NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); + + return true; + } + else + { + return false; + } + } } } diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index f787d0e8c2..013265701f 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -19,7 +19,6 @@ namespace CalamityMod.NPCs.TownNPCs { DisplayName.SetDefault("Androomba Pal"); Main.npcFrameCount[NPC.type] = 9; - NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() From 525f0ef8b041c45a07a964e7a3f5b66d442ac168 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sat, 17 Sep 2022 16:12:31 -0700 Subject: [PATCH 11/20] minor things before branch switch --- NPCs/DraedonLabThings/Androomba.cs | 4 +++- NPCs/TownNPCs/AndroombaFriendly.cs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index f056593e74..ddf1b54dd9 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -73,7 +73,8 @@ namespace CalamityMod.NPCs.DraedonLabThings // If she sees someone, start running for (int i = 0; i < Main.maxPlayers; i++) { - if (Collision.CanHit(NPC.position, NPC.width, NPC.height, Main.player[i].position, Main.player[i].width, Main.player[i].height) && NPC.ai[1] > 300) + Player player = Main.player[i]; + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height) && NPC.ai[1] > 300) { ChangeAI(1); } @@ -140,6 +141,7 @@ namespace CalamityMod.NPCs.DraedonLabThings { NPC.ai[0] = phase; NPC.ai[1] = 0; + NPC.netUpdate = true; } public override bool? CanBeHitByItem(Player player, Item item) => null; diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index 013265701f..d9ed599c1e 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -4,6 +4,8 @@ using CalamityMod.Items.Critters; using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using System.Collections.Generic; +using System.IO; using Terraria; using Terraria.Audio; using Terraria.GameContent; @@ -39,6 +41,7 @@ namespace CalamityMod.NPCs.TownNPCs NPC.DeathSound = SoundID.NPCDeath44; NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; + NPC.dontTakeDamage = true; } public override bool CanChat() @@ -199,6 +202,7 @@ namespace CalamityMod.NPCs.TownNPCs { NPC.ai[0] = phase; NPC.ai[1] = 0; + NPC.netUpdate = true; } public override bool? CanBeHitByItem(Player player, Item item) => null; From 58c9851cc2b8713881c992c00eda0f1f51da2892 Mon Sep 17 00:00:00 2001 From: Tymon Simonides Date: Sun, 18 Sep 2022 01:35:04 +0200 Subject: [PATCH 12/20] Quick check so that you don't get the repeated conversion effect (also happens in vanilla, but it's way more noticable with Astral) --- World/AstralBiome.cs | 653 ++++++++++++++++++++++--------------------- 1 file changed, 339 insertions(+), 314 deletions(-) diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index b2774e32f9..d92f450b84 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -528,340 +528,364 @@ namespace CalamityMod.World if (Main.tile[x, y] != null) { - if (WallID.Sets.Conversion.Grass[wallType]) + if (wallType != WallID.None && wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType() && wallType != ModContent.WallType() && + wallType != ModContent.WallType()) { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.HardenedSand[wallType]) - { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.Sandstone[wallType]) - { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (WallID.Sets.Conversion.Stone[wallType]) - { - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else - { - switch (wallType) + if (WallID.Sets.Conversion.Grass[wallType]) { - case WallID.DirtUnsafe: - case WallID.DirtUnsafe1: - case WallID.DirtUnsafe2: - case WallID.DirtUnsafe3: - case WallID.DirtUnsafe4: - case WallID.Cave6Unsafe: - case WallID.Dirt: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.SnowWallUnsafe: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.DesertFossil: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.IceUnsafe: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case WallID.LivingWood: - Main.tile[x, y].WallType = (ushort)ModContent.WallType(); - WorldGen.SquareWallFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.HardenedSand[wallType]) + { + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.Sandstone[wallType]) + { + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (WallID.Sets.Conversion.Stone[wallType]) + { + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else + { + switch (wallType) + { + case WallID.DirtUnsafe: + case WallID.DirtUnsafe1: + case WallID.DirtUnsafe2: + case WallID.DirtUnsafe3: + case WallID.DirtUnsafe4: + case WallID.Cave6Unsafe: + case WallID.Dirt: + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.SnowWallUnsafe: + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.DesertFossil: + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.IceUnsafe: + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case WallID.LivingWood: + Main.tile[x, y].WallType = (ushort)ModContent.WallType(); + WorldGen.SquareWallFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + } } } - if (TileID.Sets.Conversion.Grass[type] && !TileID.Sets.GrassSpecial[type]) + + if (type >= TileID.Dirt && type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType() && type != ModContent.TileType() && + type != ModContent.TileType()) { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Stone[type] || Main.tileMoss[type]) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Sand[type]) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.HardenedSand[type]) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Sandstone[type]) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else if (TileID.Sets.Conversion.Ice[type]) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - else - { - Tile tile = Main.tile[x, y]; - switch (type) + if (TileID.Sets.Conversion.Grass[type] && !TileID.Sets.GrassSpecial[type]) { - case TileID.Dirt: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.SnowBlock: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.Silt: - case TileID.Slush: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.DesertFossil: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.ClayBlock: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.Vines: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.LivingWood: - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - break; - case TileID.Copper: - case TileID.Iron: - case TileID.Silver: - case TileID.Gold: - case TileID.Tin: - case TileID.Lead: - case TileID.Tungsten: - case TileID.Platinum: - if (convertOre) - { - Main.tile[x, y].TileType = (ushort)ModContent.TileType(); - WorldGen.SquareTileFrame(x, y, true); - NetMessage.SendTileSquare(-1, x, y, 1); - } - break; - case TileID.LeafBlock: - case TileID.Sunflower: - WorldGen.KillTile(x, y); - if (Main.netMode == NetmodeID.MultiplayerClient) - { - NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y); - } - break; - case TileID.LargePiles: - if (tile.TileFrameX <= 1170) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 0, 1170, 0, 18); - } - if (tile.TileFrameX >= 1728) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1728, 1872, 0, 18); - } - if (tile.TileFrameX >= 1404 && tile.TileFrameX <= 1710) - { - RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1404, 1710, 0, 18); - } - break; - case TileID.LargePiles2: - if (tile.TileFrameX >= 1566 && tile.TileFrameY < 36) - { - RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 1566, 1872, 0, 18); - } - if (tile.TileFrameX >= 756 && tile.TileFrameX <= 900) - { - RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 756, 900, 0, 18); - } - break; - case TileID.SmallPiles: - if (tile.TileFrameY == 18) - { - ushort newType; - if (tile.TileFrameX >= 1476 && tile.TileFrameX <= 1674) - { - newType = (ushort)ModContent.TileType(); - } - else if (tile.TileFrameX <= 558 || (tile.TileFrameX >= 1368 && tile.TileFrameX <= 1458)) - { - newType = (ushort)ModContent.TileType(); - } - else if (tile.TileFrameX >= 900 && tile.TileFrameX <= 1098) - { - newType = (ushort)ModContent.TileType(); - } - else - { - break; - } - int leftMost = x; - if (tile.TileFrameX % 36 != 0) //this means it's the right tile of the two - { - leftMost--; - } - if (Main.tile[leftMost, y] != null) - { - Main.tile[leftMost, y].TileType = newType; - WorldGen.SquareTileFrame(leftMost, y, true); - NetMessage.SendTileSquare(-1, leftMost, y, 1); - } - if (Main.tile[leftMost + 1, y] != null) - { - Main.tile[leftMost + 1, y].TileType = newType; - WorldGen.SquareTileFrame(leftMost + 1, y, true); - NetMessage.SendTileSquare(-1, leftMost + 1, y, 1); - } - while (Main.tile[leftMost, y].TileFrameX >= 216) - { - if (Main.tile[leftMost, y] != null) - Main.tile[leftMost, y].TileFrameX -= 216; - if (Main.tile[leftMost + 1, y] != null) - Main.tile[leftMost + 1, y].TileFrameX -= 216; - } - } - else if (tile.TileFrameY == 0) - { - ushort newType3; - if (tile.TileFrameX >= 972 && tile.TileFrameX <= 1062) - { - newType3 = (ushort)ModContent.TileType(); - } - else if (tile.TileFrameX <= 486) - { - newType3 = (ushort)ModContent.TileType(); - } - else if (tile.TileFrameX >= 648 && tile.TileFrameX <= 846) - { - newType3 = (ushort)ModContent.TileType(); - } - else - { - break; - } - Main.tile[x, y].TileType = newType3; - while (Main.tile[x, y].TileFrameX >= 108) //REFRAME IT - { - Main.tile[x, y].TileFrameX -= 108; - } + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Stone[type] || Main.tileMoss[type]) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Sand[type]) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.HardenedSand[type]) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Sandstone[type]) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else if (TileID.Sets.Conversion.Ice[type]) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + else + { + Tile tile = Main.tile[x, y]; + switch (type) + { + case TileID.Dirt: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); WorldGen.SquareTileFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); - } - break; - case TileID.Stalactite: - int topMost = tile.TileFrameY <= 54 ? (tile.TileFrameY % 36 == 0 ? y : y - 1) : y; - bool twoTall = tile.TileFrameY <= 54; - bool hanging = tile.TileFrameY <= 18 || tile.TileFrameY == 72; - ushort newType2; - if (tile.TileFrameX >= 378 && tile.TileFrameX <= 414) //DESERT - { - newType2 = (ushort)ModContent.TileType(); - } - else if ((tile.TileFrameX >= 54 && tile.TileFrameX <= 90) || (tile.TileFrameX >= 216 && tile.TileFrameX <= 360)) - { - newType2 = (ushort)ModContent.TileType(); - } - else if (tile.TileFrameX <= 36) - { - newType2 = (ushort)ModContent.TileType(); - } - else - { break; - } + case TileID.SnowBlock: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.Silt: + case TileID.Slush: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.DesertFossil: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.ClayBlock: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.Vines: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.LivingWood: + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + break; + case TileID.Copper: + case TileID.Iron: + case TileID.Silver: + case TileID.Gold: + case TileID.Tin: + case TileID.Lead: + case TileID.Tungsten: + case TileID.Platinum: + if (convertOre) + { + Main.tile[x, y].TileType = (ushort)ModContent.TileType(); + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + break; + case TileID.LeafBlock: + case TileID.Sunflower: + WorldGen.KillTile(x, y); + if (Main.netMode == NetmodeID.MultiplayerClient) + { + NetMessage.SendData(MessageID.TileManipulation, -1, -1, null, 0, x, y); + } + break; + case TileID.LargePiles: + if (tile.TileFrameX <= 1170) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 0, 1170, 0, 18); + } + if (tile.TileFrameX >= 1728) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1728, 1872, 0, 18); + } + if (tile.TileFrameX >= 1404 && tile.TileFrameX <= 1710) + { + RecursiveReplaceToAstral(TileID.LargePiles, (ushort)ModContent.TileType(), x, y, 324, 1404, 1710, 0, 18); + } + break; + case TileID.LargePiles2: + if (tile.TileFrameX >= 1566 && tile.TileFrameY < 36) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 1566, 1872, 0, 18); + } + if (tile.TileFrameX >= 756 && tile.TileFrameX <= 900) + { + RecursiveReplaceToAstral(TileID.LargePiles2, (ushort)ModContent.TileType(), x, y, 324, 756, 900, 0, 18); + } + break; + case TileID.SmallPiles: + if (tile.TileFrameY == 18) + { + ushort newType; + if (tile.TileFrameX >= 1476 && tile.TileFrameX <= 1674) + { + newType = (ushort)ModContent.TileType(); + } + else if (tile.TileFrameX <= 558 || (tile.TileFrameX >= 1368 && tile.TileFrameX <= 1458)) + { + newType = (ushort)ModContent.TileType(); + } + else if (tile.TileFrameX >= 900 && tile.TileFrameX <= 1098) + { + newType = (ushort)ModContent.TileType(); + } + else + { + break; + } + int leftMost = x; + if (tile.TileFrameX % 36 != 0) //this means it's the right tile of the two + { + leftMost--; + } + if (Main.tile[leftMost, y] != null) + { + Main.tile[leftMost, y].TileType = newType; + WorldGen.SquareTileFrame(leftMost, y, true); + NetMessage.SendTileSquare(-1, leftMost, y, 1); + } + if (Main.tile[leftMost + 1, y] != null) + { + Main.tile[leftMost + 1, y].TileType = newType; + WorldGen.SquareTileFrame(leftMost + 1, y, true); + NetMessage.SendTileSquare(-1, leftMost + 1, y, 1); + } + while (Main.tile[leftMost, y].TileFrameX >= 216) + { + if (Main.tile[leftMost, y] != null) + Main.tile[leftMost, y].TileFrameX -= 216; + if (Main.tile[leftMost + 1, y] != null) + Main.tile[leftMost + 1, y].TileFrameX -= 216; + } + } + else if (tile.TileFrameY == 0) + { + ushort newType3; + if (tile.TileFrameX >= 972 && tile.TileFrameX <= 1062) + { + newType3 = (ushort)ModContent.TileType(); + } + else if (tile.TileFrameX <= 486) + { + newType3 = (ushort)ModContent.TileType(); + } + else if (tile.TileFrameX >= 648 && tile.TileFrameX <= 846) + { + newType3 = (ushort)ModContent.TileType(); + } + else + { + break; + } + Main.tile[x, y].TileType = newType3; + while (Main.tile[x, y].TileFrameX >= 108) //REFRAME IT + { + Main.tile[x, y].TileFrameX -= 108; + } + WorldGen.SquareTileFrame(x, y, true); + NetMessage.SendTileSquare(-1, x, y, 1); + } + break; + case TileID.Stalactite: + int topMost = tile.TileFrameY <= 54 ? (tile.TileFrameY % 36 == 0 ? y : y - 1) : y; + bool twoTall = tile.TileFrameY <= 54; + bool hanging = tile.TileFrameY <= 18 || tile.TileFrameY == 72; + ushort newType2; + if (tile.TileFrameX >= 378 && tile.TileFrameX <= 414) //DESERT + { + newType2 = (ushort)ModContent.TileType(); + } + else if ((tile.TileFrameX >= 54 && tile.TileFrameX <= 90) || (tile.TileFrameX >= 216 && tile.TileFrameX <= 360)) + { + newType2 = (ushort)ModContent.TileType(); + } + else if (tile.TileFrameX <= 36) + { + newType2 = (ushort)ModContent.TileType(); + } + else + { + break; + } - //Set types - if (Main.tile[x, topMost] != null) - { - Main.tile[x, topMost].TileType = newType2; - } - if (twoTall) - { - if (Main.tile[x, topMost + 1] != null) - Main.tile[x, topMost + 1].TileType = newType2; - } - - //Fix frames - while (Main.tile[x, topMost].TileFrameX >= 54) - { + //Set types if (Main.tile[x, topMost] != null) - Main.tile[x, topMost].TileFrameX -= 54; + { + Main.tile[x, topMost].TileType = newType2; + } if (twoTall) { if (Main.tile[x, topMost + 1] != null) - Main.tile[x, topMost + 1].TileFrameX -= 54; + Main.tile[x, topMost + 1].TileType = newType2; } - } - if (Main.tile[x, topMost] != null) - { - WorldGen.SquareTileFrame(x, topMost, true); - NetMessage.SendTileSquare(-1, x, topMost, 1); - } - - if (Main.tile[x, topMost + 1] != null) - { - WorldGen.SquareTileFrame(x, topMost + 1, true); - NetMessage.SendTileSquare(-1, x, topMost + 1, 1); - } - - if (hanging) - { - ConvertToAstral(x, topMost - 1); - break; - } - else - { - if (twoTall) + //Fix frames + while (Main.tile[x, topMost].TileFrameX >= 54) { - ConvertToAstral(x, topMost + 2); + if (Main.tile[x, topMost] != null) + Main.tile[x, topMost].TileFrameX -= 54; + if (twoTall) + { + if (Main.tile[x, topMost + 1] != null) + Main.tile[x, topMost + 1].TileFrameX -= 54; + } + } + + if (Main.tile[x, topMost] != null) + { + WorldGen.SquareTileFrame(x, topMost, true); + NetMessage.SendTileSquare(-1, x, topMost, 1); + } + + if (Main.tile[x, topMost + 1] != null) + { + WorldGen.SquareTileFrame(x, topMost + 1, true); + NetMessage.SendTileSquare(-1, x, topMost + 1, 1); + } + + if (hanging) + { + ConvertToAstral(x, topMost - 1); break; } - ConvertToAstral(x, topMost + 1); + else + { + if (twoTall) + { + ConvertToAstral(x, topMost + 2); + break; + } + ConvertToAstral(x, topMost + 1); + break; + } + case TileID.OasisPlants: + Main.tile[x, y].Get().HasTile = false; + NetMessage.SendTileSquare(-1, x, y, 1); break; - } - case TileID.OasisPlants: - Main.tile[x, y].Get().HasTile = false; - NetMessage.SendTileSquare(-1, x, y, 1); - break; + } } } } @@ -1075,6 +1099,7 @@ namespace CalamityMod.World { ReplaceAstralStalactite(TileID.Stalactite, TileID.IceBlock, x, y); } + if (TileID.Sets.Conversion.Grass[type] || type == TileID.Dirt) { WorldGen.SquareTileFrame(x, y); From 6ab0799689b26d0d719f4013ec129d2f352dfdaa Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Sat, 24 Sep 2022 12:30:25 -0400 Subject: [PATCH 13/20] Fixed Androombas not being released properly --- Items/Critters/AndroombaItem.cs | 21 +-------------------- NPCs/DraedonLabThings/Androomba.cs | 1 + NPCs/TownNPCs/AndroombaFriendly.cs | 14 ++++++-------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/Items/Critters/AndroombaItem.cs b/Items/Critters/AndroombaItem.cs index e45f024f59..565323d392 100644 --- a/Items/Critters/AndroombaItem.cs +++ b/Items/Critters/AndroombaItem.cs @@ -29,27 +29,8 @@ namespace CalamityMod.Items.Critters Item.value = Item.buyPrice(0, 0, 30, 0); Item.width = 36; Item.height = 16; - //Item.makeNPC = (short)ModContent.NPCType(); This doesn't work apparently + Item.makeNPC = (short)ModContent.NPCType(); Item.rare = ModContent.RarityType(); } - - public override bool? UseItem(Player player) - { - if (Main.LocalPlayer.Distance(Main.MouseWorld) < 300) - { - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.NewNPC(new EntitySource_BossSpawn(player), (int)Main.MouseWorld.X, (int)Main.MouseWorld.Y, ModContent.NPCType(), 1); - } - else - NetMessage.SendData(MessageID.SpawnBoss, -1, -1, null, player.whoAmI, ModContent.NPCType()); - - return true; - } - else - { - return false; - } - } } } diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index ddf1b54dd9..f1c8620763 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -19,6 +19,7 @@ namespace CalamityMod.NPCs.DraedonLabThings DisplayName.SetDefault("Androomba"); Main.npcFrameCount[NPC.type] = 22; NPCID.Sets.CountsAsCritter[NPC.type] = true; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index d9ed599c1e..2e433810a3 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -21,6 +21,7 @@ namespace CalamityMod.NPCs.TownNPCs { DisplayName.SetDefault("Androomba Pal"); Main.npcFrameCount[NPC.type] = 9; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() @@ -44,17 +45,14 @@ namespace CalamityMod.NPCs.TownNPCs NPC.dontTakeDamage = true; } - public override bool CanChat() - { - return false; - } + public override bool CanChat() => false; public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Easily reversed engineered, these robots can be made to spread whatever you put into them, giving them a new purpose.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Easily reversed engineered, these robots can be made to spread whatever you put into them, giving them a new purpose.") }); } @@ -213,8 +211,8 @@ namespace CalamityMod.NPCs.TownNPCs { /* -Frame 0: Asleep - -Frames 1-4: Moving - -Frames 5-9: Turning + -Frames 1-4: Moving + -Frames 5-9: Turning */ NPC.frameCounter += 1.0; if (NPC.frameCounter > 6.0) From f049fc7117bd0ec719588f0bb89b5caae3314811 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Sat, 24 Sep 2022 14:03:18 -0400 Subject: [PATCH 14/20] Added netcode for the roombas it's not perfect but they function I guess --- CalPlayer/CalamityPlayerMiscEffects.cs | 108 +++++++++++++++++++++-- CalamityNetcode.cs | 15 ++++ NPCs/TownNPCs/AndroombaFriendly.cs | 113 +++++++++---------------- 3 files changed, 160 insertions(+), 76 deletions(-) diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 1d2445d74e..9c9d5d0e92 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -16,6 +16,7 @@ using CalamityMod.EntitySources; using CalamityMod.Events; using CalamityMod.Items; using CalamityMod.Items.Accessories; +using CalamityMod.Items.Ammo; using CalamityMod.Items.Armor.Brimflame; using CalamityMod.Items.Armor.DesertProwler; using CalamityMod.Items.Armor.Silva; @@ -39,6 +40,7 @@ using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Other; using CalamityMod.NPCs.PlagueEnemies; using CalamityMod.NPCs.SupremeCalamitas; +using CalamityMod.NPCs.TownNPCs; using CalamityMod.Projectiles.Magic; using CalamityMod.Projectiles.Melee; using CalamityMod.Projectiles.Rogue; @@ -165,6 +167,9 @@ namespace CalamityMod.CalPlayer // Check if schematics are present on the mouse, for the sake of registering their recipes. CheckIfMouseItemIsSchematic(); + // Handle Androomba's Right Click function + AndroombaRightClick(); + // Update all particle sets for items. // This must be done here instead of in the item logic because these sets are not properly instanced // in the global classes. Attempting to update them there will cause multiple updates to one set for multiple items. @@ -520,7 +525,7 @@ namespace CalamityMod.CalPlayer // Allows the blazing aura to display if the accessory is vanity, but it deals no damage if (!blazingCursorDamage) - return; + return; // miscCounter is used to limit Calamity's hit rate. int framesPerHit = 60 / Calamity.HitsPerSecond; @@ -2450,7 +2455,7 @@ namespace CalamityMod.CalPlayer Player.statDefense += 20; Player.longInvince = true; Player.crimsonRegen = true; - healingPotBonus += 0.5f; + healingPotBonus += 0.5f; } // 50% movement speed bonus so that you don't feel like a snail in the early game. @@ -2855,10 +2860,10 @@ namespace CalamityMod.CalPlayer } if (bloodyWormTooth) - { + { Player.GetDamage() += 0.07f; - Player.GetAttackSpeed() += 0.07f; - } + Player.GetAttackSpeed() += 0.07f; + } if (filthyGlove) { @@ -3947,6 +3952,99 @@ namespace CalamityMod.CalPlayer } #endregion + #region Androomba Right Click + public void AndroombaRightClick() + { + if (Main.myPlayer != Player.whoAmI) + return; + + for (int i = 0; i < Main.maxNPCs; i++) + { + NPC npc = Main.npc[i]; + if (npc is null || !npc.active) + return; + + bool holdingsol = ((Player.HeldItem.type >= ItemID.GreenSolution && Player.HeldItem.type <= ItemID.RedSolution) || Player.HeldItem.type == ModContent.ItemType()); + if (npc.Hitbox.Contains(Main.MouseWorld.ToPoint()) && holdingsol && Player.Distance(npc.Center) < 450) + { + Player.cursorItemIconEnabled = true; + Player.cursorItemIconID = Player.HeldItem.type; + Player.cursorItemIconText = ""; + npc.ShowNameOnHover = false; + + if (Main.mouseRight && Main.mouseRightRelease && Player.Distance(npc.Center) < 300) + { + npc.netUpdate = true; + + int soltype = 0; + if (Player.HeldItem.type == ModContent.ItemType()) + { + soltype = 5; + } + else + { + switch (Player.HeldItem.type) + { + case ItemID.GreenSolution: + soltype = 0; + break; + case ItemID.PurpleSolution: + soltype = 1; + break; + case ItemID.BlueSolution: + soltype = 2; + break; + case ItemID.DarkBlueSolution: + soltype = 3; + break; + case ItemID.RedSolution: + soltype = 4; + break; + } + } + if (npc.ai[3] != soltype || npc.ai[0] == 0) + { + Player.ConsumeItem(Player.HeldItem.type); + SoundEngine.PlaySound(SoundID.Item87); + if (Main.netMode == NetmodeID.SinglePlayer) + { + AndroombaFriendly.SwapSolution(npc.whoAmI, soltype); + } + else + { + var netMessage = Mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncAndroombaSolution); + netMessage.Write(npc.whoAmI); + netMessage.Write(soltype); + netMessage.Send(); + } + if (npc.ai[0] == 0f) + { + if (Main.netMode == NetmodeID.SinglePlayer) + { + AndroombaFriendly.ChangeAI(npc.whoAmI, 1); + } + else + { + var netMessage = Mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncAndroombaAI); + netMessage.Write(npc.whoAmI); + netMessage.Write(1); + netMessage.Send(); + } + } + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, i); + } + } + } + + else + npc.ShowNameOnHover = true; + } + } + #endregion + #region Potion Handling private void HandlePotions() { diff --git a/CalamityNetcode.cs b/CalamityNetcode.cs index 21d9595985..c0ec0cd579 100644 --- a/CalamityNetcode.cs +++ b/CalamityNetcode.cs @@ -3,6 +3,7 @@ using CalamityMod.Items; using CalamityMod.NPCs; using CalamityMod.NPCs.NormalNPCs; using CalamityMod.NPCs.Providence; +using CalamityMod.NPCs.TownNPCs; using CalamityMod.TileEntities; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -85,6 +86,18 @@ namespace CalamityMod if (Main.netMode != NetmodeID.MultiplayerClient) SuperDummy.DeleteDummies(); break; + case CalamityModMessageType.SyncAndroombaSolution: + int index = reader.ReadInt32(); + int solType = reader.ReadInt32(); + if (Main.netMode != NetmodeID.MultiplayerClient) + AndroombaFriendly.SwapSolution(index, solType); + break; + case CalamityModMessageType.SyncAndroombaAI: + int idx = reader.ReadInt32(); + int phase = reader.ReadInt32(); + if (Main.netMode != NetmodeID.MultiplayerClient) + AndroombaFriendly.ChangeAI(idx, phase); + break; case CalamityModMessageType.ServersideSpawnOldDuke: byte playerIndex2 = reader.ReadByte(); CalamityUtils.SpawnOldDuke(playerIndex2); @@ -313,6 +326,8 @@ namespace CalamityMod SyncCalamityNPCAIArray, SpawnSuperDummy, DeleteAllSuperDummies, + SyncAndroombaSolution, + SyncAndroombaAI, ServersideSpawnOldDuke, ArmoredDiggerCountdownSync, // TODO -- remove this mechanic entirely ProvidenceDyeConditionSync, // TODO -- this packetstorms if you hit Provi with spam weapons. It should ONLY send a packet if the status changes. diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index 2e433810a3..a153e3de1a 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -1,5 +1,4 @@ using CalamityMod.BiomeManagers; -using CalamityMod.Items.Ammo; using CalamityMod.Items.Critters; using CalamityMod.World; using Microsoft.Xna.Framework; @@ -50,7 +49,6 @@ namespace CalamityMod.NPCs.TownNPCs public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - // Will move to localization whenever that is cleaned up. new FlavorTextBestiaryInfoElement("Easily reversed engineered, these robots can be made to spread whatever you put into them, giving them a new purpose.") }); @@ -69,7 +67,6 @@ namespace CalamityMod.NPCs.TownNPCs { NPC.ai[2] = (Main.LocalPlayer.position.X <= NPC.position.X) ? 1 : -1; } - GrabSolution(true); } break; // Main @@ -79,10 +76,9 @@ namespace CalamityMod.NPCs.TownNPCs NPC.velocity.X = NPC.ai[2] * 2; if (!Collision.CanHit(NPC.Center - Vector2.UnitX * NPC.ai[2] * 8f, 2, 2, NPC.Center + Vector2.UnitX * NPC.ai[2] * 32f, 8, 8)) { - ChangeAI(2); + ChangeAIHook(2); } Convert((int)NPC.ai[3]); - GrabSolution(false); } break; // Turn @@ -90,72 +86,11 @@ namespace CalamityMod.NPCs.TownNPCs { NPC.velocity.X = 0; Convert((int)NPC.ai[3]); - GrabSolution(false); } break; } } - public void GrabSolution(bool reset = false) - { - if (Main.netMode != NetmodeID.Server) - { - bool holdingsol = ((Main.LocalPlayer.HeldItem.type >= ItemID.GreenSolution && Main.LocalPlayer.HeldItem.type <= ItemID.RedSolution) || Main.LocalPlayer.HeldItem.type == ModContent.ItemType()); - if (NPC.Hitbox.Contains(Main.MouseWorld.ToPoint()) && holdingsol && Main.LocalPlayer.Distance(NPC.Center) < 450) - { - Main.LocalPlayer.cursorItemIconEnabled = true; - Main.LocalPlayer.cursorItemIconID = Main.LocalPlayer.HeldItem.type; - Main.LocalPlayer.cursorItemIconText = ""; - NPC.ShowNameOnHover = false; - - if (Main.mouseRight && Main.mouseRightRelease && Main.LocalPlayer.Distance(NPC.Center) < 300) - { - NPC.netUpdate = true; - - int soltype = 0; - if (Main.LocalPlayer.HeldItem.type == ModContent.ItemType()) - { - soltype = 5; - } - else - { - switch (Main.LocalPlayer.HeldItem.type) - { - case ItemID.GreenSolution: - soltype = 0; - break; - case ItemID.PurpleSolution: - soltype = 1; - break; - case ItemID.BlueSolution: - soltype = 2; - break; - case ItemID.DarkBlueSolution: - soltype = 3; - break; - case ItemID.RedSolution: - soltype = 4; - break; - } - } - if (NPC.ai[3] != soltype || NPC.ai[0] == 0) - { - Main.LocalPlayer.ConsumeItem(Main.LocalPlayer.HeldItem.type); - SoundEngine.PlaySound(SoundID.Item87); - NPC.ai[3] = soltype; - if (reset) - { - ChangeAI(1); - } - } - } - } - - else - NPC.ShowNameOnHover = true; - } - } - public void Convert(int conversionType) { int x = (int)(NPC.Center.X / 16f); @@ -196,11 +131,47 @@ namespace CalamityMod.NPCs.TownNPCs } } - public void ChangeAI(int phase) + public void ChangeAIHook(int phase) { - NPC.ai[0] = phase; - NPC.ai[1] = 0; - NPC.netUpdate = true; + if (Main.netMode == NetmodeID.SinglePlayer) + { + ChangeAI(NPC.whoAmI, phase); + } + else + { + var netMessage = Mod.GetPacket(); + netMessage.Write((byte)CalamityModMessageType.SyncAndroombaAI); + netMessage.Write(NPC.whoAmI); + netMessage.Write(phase); + netMessage.Send(); + } + } + + public static void ChangeAI(int index, int phase) + { + NPC npc = Main.npc[index]; + + if (npc is null || !npc.active) + return; + + npc.ai[0] = phase; + npc.ai[1] = 0; + npc.netUpdate = true; + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, index); + } + + public static void SwapSolution(int index, int solutionType) + { + NPC npc = Main.npc[index]; + + if (npc is null || !npc.active) + return; + + npc.ai[3] = solutionType; + npc.netUpdate = true; + if (Main.netMode == NetmodeID.Server) + NetMessage.SendData(MessageID.SyncNPC, -1, -1, null, index); } public override bool? CanBeHitByItem(Player player, Item item) => null; @@ -242,7 +213,7 @@ namespace CalamityMod.NPCs.TownNPCs { NPC.frame.Y = frameHeight; NPC.ai[2] *= -1; - ChangeAI(1); + ChangeAIHook(1); } } // Sleep From dec4b92a7920e194eaf058da80a3d1a44f7fc6d4 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Sat, 24 Sep 2022 16:48:09 -0400 Subject: [PATCH 15/20] Critter Bestiary tracker fixes --- .../NanodroidDisfunctional.cs | 24 +++++++++++-------- NPCs/DraedonLabThings/NanodroidPlagueGreen.cs | 24 +++++++++++-------- NPCs/DraedonLabThings/NanodroidPlagueRed.cs | 24 +++++++++++-------- NPCs/DraedonLabThings/RepairUnitCritter.cs | 13 ++++++++++ NPCs/NormalNPCs/Piggy.cs | 16 +++++++++++++ NPCs/TownNPCs/AndroombaFriendly.cs | 13 ++++++++++ 6 files changed, 84 insertions(+), 30 deletions(-) diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs index 31647a8691..7154e1c2a7 100644 --- a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs +++ b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs @@ -32,6 +32,20 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.25f, 0.1f, 0f); } + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Sights.RegisterWasNearby(nPC); + break; + } + } } public override bool? CanBeHitByItem(Player player, Item item) => null; @@ -53,16 +67,6 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } - public override void OnKill() - { - if (NPC.GetWereThereAnyInteractions()) - { - NPC nPC = new NPC(); - nPC.SetDefaults(ModContent.NPCType()); - Main.BestiaryTracker.Kills.RegisterKill(nPC); - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs index ca14d60d90..64dfd219d4 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs @@ -32,6 +32,20 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.03f, 0.3f, 0.05f); } + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Sights.RegisterWasNearby(nPC); + break; + } + } } public override bool? CanBeHitByItem(Player player, Item item) => null; @@ -53,16 +67,6 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } - public override void OnKill() - { - if (NPC.GetWereThereAnyInteractions()) - { - NPC nPC = new NPC(); - nPC.SetDefaults(ModContent.NPCType()); - Main.BestiaryTracker.Kills.RegisterKill(nPC); - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs index 57872dc566..817cfa8e7f 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs @@ -32,6 +32,20 @@ namespace CalamityMod.NPCs.DraedonLabThings { Lighting.AddLight(NPC.Center, 0.3f, 0.03f, 0f); } + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Sights.RegisterWasNearby(nPC); + break; + } + } } public override bool? CanBeHitByItem(Player player, Item item) => null; @@ -53,16 +67,6 @@ namespace CalamityMod.NPCs.DraedonLabThings Dust.NewDustDirect(NPC.position, NPC.width, NPC.height, 226); } - public override void OnKill() - { - if (NPC.GetWereThereAnyInteractions()) - { - NPC nPC = new NPC(); - nPC.SetDefaults(ModContent.NPCType()); - Main.BestiaryTracker.Kills.RegisterKill(nPC); - } - } - public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index efc179de13..b0d26612c4 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -124,6 +124,19 @@ namespace CalamityMod.NPCs.DraedonLabThings break; } Time++; + + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + break; + } + } } public void WalkAroundOnGround() diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index ed38f0d9a4..5880f44067 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -46,6 +46,22 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.Calamity().VulnerableToSickness = true; } + public override void AI() + { + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + break; + } + } + } + public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index a153e3de1a..a555767ec2 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -89,6 +89,19 @@ namespace CalamityMod.NPCs.TownNPCs } break; } + + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + break; + } + } } public void Convert(int conversionType) From 77c64504961995f5f2fc2256bbdb1f58595129f7 Mon Sep 17 00:00:00 2001 From: ben-tk <45545085+ben-tk@users.noreply.github.com> Date: Sat, 24 Sep 2022 17:15:46 -0400 Subject: [PATCH 16/20] Bestiary tweaks --- NPCs/DraedonLabThings/Androomba.cs | 14 ++++++++++++++ NPCs/DraedonLabThings/RepairUnitCritter.cs | 2 +- NPCs/NormalNPCs/Piggy.cs | 4 +++- NPCs/TownNPCs/AndroombaFriendly.cs | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/NPCs/DraedonLabThings/Androomba.cs b/NPCs/DraedonLabThings/Androomba.cs index f1c8620763..4d2901c071 100644 --- a/NPCs/DraedonLabThings/Androomba.cs +++ b/NPCs/DraedonLabThings/Androomba.cs @@ -20,6 +20,7 @@ namespace CalamityMod.NPCs.DraedonLabThings Main.npcFrameCount[NPC.type] = 22; NPCID.Sets.CountsAsCritter[NPC.type] = true; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.NormalGoldCritterBestiaryPriority.Add(Type); } public override void SetDefaults() @@ -136,6 +137,19 @@ namespace CalamityMod.NPCs.DraedonLabThings } break; } + + for (int i = 0; i < Main.maxPlayers; i++) + { + Player player = Main.player[i]; + if (player is null || !player.active) + continue; + + if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) + { + Main.BestiaryTracker.Kills.RegisterKill(NPC); + break; + } + } } public void ChangeAI(int phase) diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index b0d26612c4..a22735ebf7 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -133,7 +133,7 @@ namespace CalamityMod.NPCs.DraedonLabThings if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { - Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + Main.BestiaryTracker.Kills.RegisterKill(NPC); break; } } diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 5880f44067..95357c79b4 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -56,7 +56,9 @@ namespace CalamityMod.NPCs.NormalNPCs if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { - Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + NPC nPC = new NPC(); + nPC.SetDefaults(ModContent.NPCType()); + Main.BestiaryTracker.Kills.RegisterKill(nPC); break; } } diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index a555767ec2..c4ba7a272f 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -98,7 +98,7 @@ namespace CalamityMod.NPCs.TownNPCs if (NPC.Hitbox.Intersects(player.HitboxForBestiaryNearbyCheck)) { - Main.BestiaryTracker.Sights.RegisterWasNearby(NPC); + Main.BestiaryTracker.Chats.RegisterChatStartWith(NPC); break; } } From 1072082a456a379ca8c71a936a160e4aee856571 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sat, 24 Sep 2022 21:38:36 -0700 Subject: [PATCH 17/20] Nanodroid items, other minor fixes --- Items/Critters/NanodroidDisfunctionalItem.cs | 34 ++++++++++++++++++ Items/Critters/NanodroidDisfunctionalItem.png | Bin 0 -> 222 bytes Items/Critters/NanodroidItem.cs | 34 ++++++++++++++++++ Items/Critters/NanodroidItem.png | Bin 0 -> 238 bytes Items/Critters/NanodroidPlagueGreenItem.cs | 34 ++++++++++++++++++ Items/Critters/NanodroidPlagueGreenItem.png | Bin 0 -> 238 bytes Items/Critters/NanodroidPlagueRedItem.cs | 34 ++++++++++++++++++ Items/Critters/NanodroidPlagueRedItem.png | Bin 0 -> 238 bytes NPCs/DraedonLabThings/Androomba.cs | 3 +- NPCs/DraedonLabThings/Nanodroid.cs | 3 ++ .../NanodroidDisfunctional.cs | 5 ++- NPCs/DraedonLabThings/NanodroidPlagueGreen.cs | 5 ++- NPCs/DraedonLabThings/NanodroidPlagueRed.cs | 5 ++- NPCs/TownNPCs/AndroombaFriendly.cs | 3 +- 14 files changed, 154 insertions(+), 6 deletions(-) create mode 100644 Items/Critters/NanodroidDisfunctionalItem.cs create mode 100644 Items/Critters/NanodroidDisfunctionalItem.png create mode 100644 Items/Critters/NanodroidItem.cs create mode 100644 Items/Critters/NanodroidItem.png create mode 100644 Items/Critters/NanodroidPlagueGreenItem.cs create mode 100644 Items/Critters/NanodroidPlagueGreenItem.png create mode 100644 Items/Critters/NanodroidPlagueRedItem.cs create mode 100644 Items/Critters/NanodroidPlagueRedItem.png diff --git a/Items/Critters/NanodroidDisfunctionalItem.cs b/Items/Critters/NanodroidDisfunctionalItem.cs new file mode 100644 index 0000000000..a979b66ee5 --- /dev/null +++ b/Items/Critters/NanodroidDisfunctionalItem.cs @@ -0,0 +1,34 @@ +using CalamityMod.NPCs.DraedonLabThings; +using CalamityMod.Rarities; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class NanodroidDisfunctionalItem : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 5; + DisplayName.SetDefault("Disfunctional Nanodroid"); + } + + public override void SetDefaults() + { + Item.useStyle = ItemUseStyleID.Swing; + Item.autoReuse = true; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.maxStack = 999; + Item.consumable = true; + Item.noUseGraphic = true; + Item.value = Item.buyPrice(0, 0, 30); + Item.width = 16; + Item.height = 10; + Item.makeNPC = (short)ModContent.NPCType(); + Item.rare = ModContent.RarityType(); + } + } +} diff --git a/Items/Critters/NanodroidDisfunctionalItem.png b/Items/Critters/NanodroidDisfunctionalItem.png new file mode 100644 index 0000000000000000000000000000000000000000..45b30b567fa1aa810d8ec76fe2daae338a0b4ac9 GIT binary patch literal 222 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!3-q367<#qDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheq5(c3u0YyOMdiPPyuXglgp`ONXD6UY&~y8@K#IL2$S?Rm7%)hAGrIwW zI14-?iy0XB4ude`@%$AjKtX#?7sn8Z@YJ)8Tn8L@oG#Ajy!ZdaViB&~ds=^5HCOsH zoh*B?&We2o(); + Item.rare = ModContent.RarityType(); + } + } +} diff --git a/Items/Critters/NanodroidItem.png b/Items/Critters/NanodroidItem.png new file mode 100644 index 0000000000000000000000000000000000000000..a5e85a83bd967b4101290ba257d74329cc3d8ee5 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!3-q367<#qDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheasfUeu0UGTRDJ4aZ98{I6=l`j^z?{S6S0VV`QQJ6Qr|e@Kq|RPg8YL2 z!vMpkGdkyiqMQXDk;M!Qe1}1p@p%4<6riB9r;B5VM0o01N4^6F9L$bBOh^9zFX+_@ z^_nSstJ&~UOG`jnfq8WHdyWICZD;rt9ZvDQ&+z~D<@-~vwXf!^+E>?D!*HRC>FEuZ Rly;zT44$rjF6*2UngBJdP$~cb literal 0 HcmV?d00001 diff --git a/Items/Critters/NanodroidPlagueGreenItem.cs b/Items/Critters/NanodroidPlagueGreenItem.cs new file mode 100644 index 0000000000..0f8c7343c2 --- /dev/null +++ b/Items/Critters/NanodroidPlagueGreenItem.cs @@ -0,0 +1,34 @@ +using CalamityMod.NPCs.DraedonLabThings; +using CalamityMod.Rarities; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; + +namespace CalamityMod.Items.Critters +{ + public class NanodroidPlagueGreenItem : ModItem + { + public override void SetStaticDefaults() + { + SacrificeTotal = 5; + DisplayName.SetDefault("Green Plague Nanodroid"); + } + + public override void SetDefaults() + { + Item.useStyle = ItemUseStyleID.Swing; + Item.autoReuse = true; + Item.useTurn = true; + Item.useAnimation = 15; + Item.useTime = 10; + Item.maxStack = 999; + Item.consumable = true; + Item.noUseGraphic = true; + Item.value = Item.buyPrice(0, 0, 30); + Item.width = 16; + Item.height = 10; + Item.makeNPC = (short)ModContent.NPCType(); + Item.rare = ModContent.RarityType(); + } + } +} diff --git a/Items/Critters/NanodroidPlagueGreenItem.png b/Items/Critters/NanodroidPlagueGreenItem.png new file mode 100644 index 0000000000000000000000000000000000000000..ad42fbc33856e25ddd294f2b5755ad5f634c25b0 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!3-q367<#qDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheasfUeu96ZG2Bt=5mipVdJE|zFrZ&`Pd8lV)yU)C=0aWtjq00;)#Z?mI z7yKUv7&e{JIS&-&EbxddW?7e0@4c1qqE<097t_D!>8zQisyZX|F(); + Item.rare = ModContent.RarityType(); + } + } +} diff --git a/Items/Critters/NanodroidPlagueRedItem.png b/Items/Critters/NanodroidPlagueRedItem.png new file mode 100644 index 0000000000000000000000000000000000000000..d94ddff161e9974efd95fe4a04626b5dd9493246 GIT binary patch literal 238 zcmeAS@N?(olHy`uVBq!ia0vp^0zk~g!3-q367<#qDaPU;cPEB*=VV?2IV|apzK#qG z8~eHcB(eheasfUet}@a(YK9K8c6qtlxvMCvmQ9-MpAw%Tr25p!38>`#=I|aM#Z?mI z7yKUv7&e{JIS&-&EbxddW?7e0@4c1qqE<097t_D!>8zQisyZX|F 300) + if (Collision.CanHit(NPC.position, NPC.width, NPC.height, player.position, player.width, player.height)) { ChangeAI(1); } diff --git a/NPCs/DraedonLabThings/Nanodroid.cs b/NPCs/DraedonLabThings/Nanodroid.cs index ec37040409..33f330c15f 100644 --- a/NPCs/DraedonLabThings/Nanodroid.cs +++ b/NPCs/DraedonLabThings/Nanodroid.cs @@ -1,4 +1,5 @@ using CalamityMod.BiomeManagers; +using CalamityMod.Items.Critters; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -16,6 +17,7 @@ namespace CalamityMod.NPCs.DraedonLabThings DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() @@ -25,6 +27,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); SpawnModBiomes = new int[1] { ModContent.GetInstance().Type }; } diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs index 7154e1c2a7..eea2a618df 100644 --- a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs +++ b/NPCs/DraedonLabThings/NanodroidDisfunctional.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Critters; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; @@ -15,6 +16,7 @@ namespace CalamityMod.NPCs.DraedonLabThings DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() @@ -24,6 +26,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); } public override void AI() diff --git a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs index 64dfd219d4..29f75f5f61 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueGreen.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Critters; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; @@ -15,6 +16,7 @@ namespace CalamityMod.NPCs.DraedonLabThings DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() @@ -24,6 +26,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); } public override void AI() diff --git a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs index 817cfa8e7f..4c494fde59 100644 --- a/NPCs/DraedonLabThings/NanodroidPlagueRed.cs +++ b/NPCs/DraedonLabThings/NanodroidPlagueRed.cs @@ -1,4 +1,5 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Items.Critters; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.GameContent; @@ -15,6 +16,7 @@ namespace CalamityMod.NPCs.DraedonLabThings DisplayName.SetDefault("Nanodroid"); Main.npcFrameCount[NPC.type] = 8; NPCID.Sets.CountsAsCritter[NPC.type] = true; + Main.npcCatchable[NPC.type] = true; } public override void SetDefaults() @@ -24,6 +26,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; + NPC.catchItem = (short)ModContent.ItemType(); } public override void AI() diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index c4ba7a272f..c81c1766d5 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -65,7 +65,8 @@ namespace CalamityMod.NPCs.TownNPCs { if (NPC.ai[1] == 0) { - NPC.ai[2] = (Main.LocalPlayer.position.X <= NPC.position.X) ? 1 : -1; + Player closest = Main.player[Player.FindClosest(NPC.position, 9999, 9999)]; + NPC.ai[2] = (closest.position.X <= NPC.position.X) ? 1 : -1; } } break; From 2a27c29d5d14ec80a6d38c1f351901b8acad981d Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sat, 24 Sep 2022 22:03:00 -0700 Subject: [PATCH 18/20] decreased spawnrates --- NPCs/CalamityGlobalNPC.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 3becfc68af..034549136f 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4809,19 +4809,19 @@ namespace CalamityMod.NPCs WeightedRandom pool = new WeightedRandom(); pool.Add(NPCID.None, 0f); - pool.Add(NPCType(), 0.1f); - pool.Add(NPCType(), 0.05f); + pool.Add(NPCType(), 0.025f); + pool.Add(NPCType(), 0.001f); // Normal droids are replaced with plague droids in the Jungle Lab. if (nearPlagueLab) { - pool.Add(NPCType(), 0.075f); - pool.Add(NPCType(), 0.075f); - pool.Add(NPCType(), 0.04f); + pool.Add(NPCType(), 0.025f); + pool.Add(NPCType(), 0.025f); + pool.Add(NPCType(), 0.02f); } else { - pool.Add(NPCType(), 0.1f); - pool.Add(NPCType(), 0.1f); + pool.Add(NPCType(), 0.05f); + pool.Add(NPCType(), 0.05f); } From c6b2179232c7e6f1a0a7f31f1a33ecdb58ed4330 Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sat, 24 Sep 2022 22:27:13 -0700 Subject: [PATCH 19/20] Disfunctional -> Dysfunctional --- ...ctionalItem.cs => NanodroidDysfunctionalItem.cs} | 6 +++--- ...ionalItem.png => NanodroidDysfunctionalItem.png} | Bin NPCs/CalamityGlobalNPC.cs | 4 ++-- ...idDisfunctional.cs => NanodroidDysfunctional.cs} | 6 +++--- ...Disfunctional.png => NanodroidDysfunctional.png} | Bin ...nal_Glow.png => NanodroidDysfunctional_Glow.png} | Bin 6 files changed, 8 insertions(+), 8 deletions(-) rename Items/Critters/{NanodroidDisfunctionalItem.cs => NanodroidDysfunctionalItem.cs} (82%) rename Items/Critters/{NanodroidDisfunctionalItem.png => NanodroidDysfunctionalItem.png} (100%) rename NPCs/DraedonLabThings/{NanodroidDisfunctional.cs => NanodroidDysfunctional.cs} (95%) rename NPCs/DraedonLabThings/{NanodroidDisfunctional.png => NanodroidDysfunctional.png} (100%) rename NPCs/DraedonLabThings/{NanodroidDisfunctional_Glow.png => NanodroidDysfunctional_Glow.png} (100%) diff --git a/Items/Critters/NanodroidDisfunctionalItem.cs b/Items/Critters/NanodroidDysfunctionalItem.cs similarity index 82% rename from Items/Critters/NanodroidDisfunctionalItem.cs rename to Items/Critters/NanodroidDysfunctionalItem.cs index a979b66ee5..95fed65909 100644 --- a/Items/Critters/NanodroidDisfunctionalItem.cs +++ b/Items/Critters/NanodroidDysfunctionalItem.cs @@ -6,12 +6,12 @@ using Terraria.ModLoader; namespace CalamityMod.Items.Critters { - public class NanodroidDisfunctionalItem : ModItem + public class NanodroidDysfunctionalItem : ModItem { public override void SetStaticDefaults() { SacrificeTotal = 5; - DisplayName.SetDefault("Disfunctional Nanodroid"); + DisplayName.SetDefault("Dysfunctional Nanodroid"); } public override void SetDefaults() @@ -27,7 +27,7 @@ namespace CalamityMod.Items.Critters Item.value = Item.buyPrice(0, 0, 30); Item.width = 16; Item.height = 10; - Item.makeNPC = (short)ModContent.NPCType(); + Item.makeNPC = (short)ModContent.NPCType(); Item.rare = ModContent.RarityType(); } } diff --git a/Items/Critters/NanodroidDisfunctionalItem.png b/Items/Critters/NanodroidDysfunctionalItem.png similarity index 100% rename from Items/Critters/NanodroidDisfunctionalItem.png rename to Items/Critters/NanodroidDysfunctionalItem.png diff --git a/NPCs/CalamityGlobalNPC.cs b/NPCs/CalamityGlobalNPC.cs index 034549136f..41ae011d11 100644 --- a/NPCs/CalamityGlobalNPC.cs +++ b/NPCs/CalamityGlobalNPC.cs @@ -4816,12 +4816,12 @@ namespace CalamityMod.NPCs { pool.Add(NPCType(), 0.025f); pool.Add(NPCType(), 0.025f); - pool.Add(NPCType(), 0.02f); + pool.Add(NPCType(), 0.02f); } else { pool.Add(NPCType(), 0.05f); - pool.Add(NPCType(), 0.05f); + pool.Add(NPCType(), 0.05f); } diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs b/NPCs/DraedonLabThings/NanodroidDysfunctional.cs similarity index 95% rename from NPCs/DraedonLabThings/NanodroidDisfunctional.cs rename to NPCs/DraedonLabThings/NanodroidDysfunctional.cs index eea2a618df..dd53400a23 100644 --- a/NPCs/DraedonLabThings/NanodroidDisfunctional.cs +++ b/NPCs/DraedonLabThings/NanodroidDysfunctional.cs @@ -8,7 +8,7 @@ using Terraria.ModLoader; namespace CalamityMod.NPCs.DraedonLabThings { - public class NanodroidDisfunctional : ModNPC + public class NanodroidDysfunctional : ModNPC { public override void SetStaticDefaults() { @@ -26,7 +26,7 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.height = 12; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; - NPC.catchItem = (short)ModContent.ItemType(); + NPC.catchItem = (short)ModContent.ItemType(); } public override void AI() @@ -73,7 +73,7 @@ namespace CalamityMod.NPCs.DraedonLabThings public override bool PreDraw(SpriteBatch spriteBatch, Vector2 screenPos, Color drawColor) { Texture2D critterTexture = TextureAssets.Npc[NPC.type].Value; - Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/NanodroidDisfunctional_Glow").Value; + Texture2D glowmask = ModContent.Request("CalamityMod/NPCs/DraedonLabThings/NanodroidDysfunctional_Glow").Value; Vector2 drawPosition = NPC.Center - screenPos + Vector2.UnitY * NPC.gfxOffY; SpriteEffects direction = NPC.spriteDirection == 1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; spriteBatch.Draw(critterTexture, drawPosition, NPC.frame, NPC.GetAlpha(drawColor), NPC.rotation, NPC.frame.Size() * 0.5f, NPC.scale, direction, 0f); diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional.png b/NPCs/DraedonLabThings/NanodroidDysfunctional.png similarity index 100% rename from NPCs/DraedonLabThings/NanodroidDisfunctional.png rename to NPCs/DraedonLabThings/NanodroidDysfunctional.png diff --git a/NPCs/DraedonLabThings/NanodroidDisfunctional_Glow.png b/NPCs/DraedonLabThings/NanodroidDysfunctional_Glow.png similarity index 100% rename from NPCs/DraedonLabThings/NanodroidDisfunctional_Glow.png rename to NPCs/DraedonLabThings/NanodroidDysfunctional_Glow.png From 1f76789e5b97544b84f930fd12b519da577ebd1d Mon Sep 17 00:00:00 2001 From: GinYuH Date: Sun, 25 Sep 2022 19:31:25 -0700 Subject: [PATCH 20/20] astral to other conversion now uses a method --- NPCs/TownNPCs/AndroombaFriendly.cs | 11 +---------- World/AstralBiome.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/NPCs/TownNPCs/AndroombaFriendly.cs b/NPCs/TownNPCs/AndroombaFriendly.cs index c81c1766d5..68c0945c1c 100644 --- a/NPCs/TownNPCs/AndroombaFriendly.cs +++ b/NPCs/TownNPCs/AndroombaFriendly.cs @@ -127,16 +127,7 @@ namespace CalamityMod.NPCs.TownNPCs type = ConvertType.Crimson; break; } - for (int i = 0; i < 3; i++) - { - for (int j = 0; j < 3; j++) - { - AstralBiome.ConvertFromAstral(x + i, y + j, type); - AstralBiome.ConvertFromAstral(x - i, y - j, type); - AstralBiome.ConvertFromAstral(x + i, y - j, type); - AstralBiome.ConvertFromAstral(x - i, y + j, type); - } - } + AstralBiome.ConvertFromAstral(x - 2, x + 2, y - 2, y + 2, type); WorldGen.Convert(x, y, conversionType, 2); } else diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index d92f450b84..2c59c7d6b7 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -892,6 +892,17 @@ namespace CalamityMod.World } } + public static void ConvertFromAstral(int startX, int endX, int startY, int endY, ConvertType convert) + { + for (int x = startX; x <= endX; x++) + { + for (int y = startY; y <= endY; y++) + { + ConvertFromAstral(x, y, convert); + } + } + } + public static void ConvertFromAstral(int x, int y, ConvertType convert, bool tileframe = true) { Tile tile = Main.tile[x, y];