From ea1f4d4fbc5debe4aee5a656f6c1aef2da7688bf Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 19 Jun 2022 00:34:10 -0500 Subject: [PATCH] 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..5b35dcb43b116c1de5366aa57e5cbf5ed89a9e24 GI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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_* zU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