From 9635a74b5d7de00eff86d05f251f3db0c5aca044 Mon Sep 17 00:00:00 2001 From: IbanPlay <56191483+IbanPlay@users.noreply.github.com> Date: Tue, 12 Jul 2022 01:40:00 +0200 Subject: [PATCH] Wulfrum hook uses aistyle 7 --- ILEditing/ILChangesLoading.cs | 2 -- ILEditing/MechanicILChanges.cs | 13 ------------- Items/Accessories/WulfrumAcrobaticsPack.cs | 4 ++-- Projectiles/Typeless/WulfrumHook.cs | 8 +++++--- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ILEditing/ILChangesLoading.cs b/ILEditing/ILChangesLoading.cs index d89853fce3..ad83ffd921 100644 --- a/ILEditing/ILChangesLoading.cs +++ b/ILEditing/ILChangesLoading.cs @@ -57,7 +57,6 @@ namespace CalamityMod.ILEditing IL.Terraria.GameContent.Liquid.LiquidRenderer.InternalDraw += DrawCustomLava2; IL.Terraria.Main.oldDrawWater += DrawCustomLava3; On.Terraria.GameContent.Drawing.TileDrawing.Draw += ClearTilePings; - On.Terraria.Player.RemoveAllGrapplingHooks += RemoveCustomGrapples; On.Terraria.Player.GrappleMovement += CustomGrappleMovementCheck; On.Terraria.Player.UpdatePettingAnimal += CustomGrapplePreDefaultMovement; On.Terraria.Player.PlayerFrame += CustomGrapplePostFrame; @@ -172,7 +171,6 @@ namespace CalamityMod.ILEditing On.Terraria.NPC.Collision_DecideFallThroughPlatforms -= EnableCalamityBossPlatformCollision; IL.Terraria.Wiring.HitWireSingle -= AddTwinklersToStatue; On.Terraria.GameContent.Drawing.TileDrawing.Draw -= ClearTilePings; - On.Terraria.Player.RemoveAllGrapplingHooks -= RemoveCustomGrapples; On.Terraria.Player.GrappleMovement -= CustomGrappleMovementCheck; On.Terraria.Player.UpdatePettingAnimal -= CustomGrapplePreDefaultMovement; On.Terraria.Player.PlayerFrame -= CustomGrapplePostFrame; diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index eec1d8c567..41ecb25148 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -956,19 +956,6 @@ namespace CalamityMod.ILEditing #region Custom Grappling hooks - /// - /// Custom grapples get removed when the vanilla function to remove all grapples get called, as the vanilla one relies solely on the ai stype = 7 - /// - private static void RemoveCustomGrapples(On.Terraria.Player.orig_RemoveAllGrapplingHooks orig, Player self) - { - orig(self); - for (int i = 0; i < Main.maxProjectiles; i++) - { - if (Main.projectile[i].active && Main.projectile[i].owner == self.whoAmI && Main.projectile[i].type == ModContent.ProjectileType()) - Main.projectile[i].Kill(); - } - } - /// /// Determines if the custom grapple movement should take place or not. Useful for hooks that only do movement tricks in some cases /// diff --git a/Items/Accessories/WulfrumAcrobaticsPack.cs b/Items/Accessories/WulfrumAcrobaticsPack.cs index 7f249bc54b..db3672c5ad 100644 --- a/Items/Accessories/WulfrumAcrobaticsPack.cs +++ b/Items/Accessories/WulfrumAcrobaticsPack.cs @@ -88,7 +88,7 @@ namespace CalamityMod.Items.Accessories public override void OnSpawn(Projectile projectile, IEntitySource source) { Player owner = Main.player[projectile.owner]; - if (projectile.aiStyle == 7 && owner.GetModPlayer().WulfrumPackEquipped) + if (projectile.aiStyle == 7 && projectile.type != ProjectileType() && owner.GetModPlayer().WulfrumPackEquipped) { projectile.active = false; } @@ -413,7 +413,7 @@ namespace CalamityMod.Items.Accessories for (int i = 0; i < Main.maxProjectiles; ++i) { Projectile p = Main.projectile[i]; - if (!p.active || p.owner != Player.whoAmI || p.aiStyle != 7) + if (!p.active || p.owner != Player.whoAmI || p.aiStyle != 7 || p.type == ProjectileType()) continue; p.Kill(); diff --git a/Projectiles/Typeless/WulfrumHook.cs b/Projectiles/Typeless/WulfrumHook.cs index 6500127ce0..f877d5fa27 100644 --- a/Projectiles/Typeless/WulfrumHook.cs +++ b/Projectiles/Typeless/WulfrumHook.cs @@ -55,13 +55,13 @@ namespace CalamityMod.Projectiles.Typeless Projectile.tileCollide = false; Projectile.extraUpdates = WulfrumPackPlayer.HookUpdates; Projectile.netImportant = true; - //Projectile.aiStyle = 7; Can i set its ai style to 7 wihle also making it not do anthing related to ai 7 whatsoever and use my own custom hook ai? - //That would bne great because fsr the onyl way to distinguish if a projectile is a hook or not is by checking its ai style. + Projectile.aiStyle = 7; //The projectile uses entirely custom AI, but for some reason terraria's only way to distinguish what is and isnt a hook is its ai style. } public override bool? CanDamage() => false; - public override void AI() + public override bool PreAI() => false; + public override void PostAI() { Lighting.AddLight(Projectile.Center, Color.DeepSkyBlue.ToVector3()); Vector2 BetweenOwner = Owner.Center - Projectile.Center; @@ -247,5 +247,7 @@ namespace CalamityMod.Projectiles.Typeless Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, lightColor, Projectile.rotation, texture.Size() / 2f, Projectile.scale, 0, 0); return false; } + + public override bool PreDrawExtras() => false; //Prevents vanilla chain drawing from taking place } }