From 56780e24867bdec598e39b0cce342a3cef6bdcae Mon Sep 17 00:00:00 2001 From: Ozzatron Date: Tue, 27 Aug 2024 14:38:13 -0400 Subject: [PATCH] Added mod calls for external stats and an external flight mult variable. --- CalPlayer/CalamityPlayer.cs | 7 ++ CalPlayer/CalamityPlayerMiscEffects.cs | 3 +- ModSupport/ModCalls.cs | 89 ++++++++++++++++++++++---- 3 files changed, 84 insertions(+), 15 deletions(-) diff --git a/CalPlayer/CalamityPlayer.cs b/CalPlayer/CalamityPlayer.cs index c0fae2128f..72581b7851 100644 --- a/CalPlayer/CalamityPlayer.cs +++ b/CalPlayer/CalamityPlayer.cs @@ -140,6 +140,7 @@ namespace CalamityMod.CalPlayer #endregion #region External variables -- Not used by Calamity, only via Mod.Call or reflection + public float externalFlightTimeMultBoost = 0f; public int externalAbyssLight = 0; public bool externalColdImmunity = false; public bool externalHeatImmunity = false; @@ -1586,8 +1587,12 @@ namespace CalamityMod.CalPlayer accStealthGenBoost = 0f; DashID = string.Empty; + + externalFlightTimeMultBoost = 0f; externalAbyssLight = 0; externalColdImmunity = externalHeatImmunity = false; + externalDefenseDamageImmunity = false; + alcoholPoisonLevel = 0; noLifeRegen = false; @@ -2380,8 +2385,10 @@ namespace CalamityMod.CalPlayer bloodflareMageCooldown = 0; tarraRangedCooldown = 0; hideOfDeusMeleeBoostTimer = 0; + externalFlightTimeMultBoost = 0f; externalAbyssLight = 0; externalColdImmunity = externalHeatImmunity = false; + externalDefenseDamageImmunity = false; dragonRageHits = 0; dragonRageCooldown = 0; spectralVeilImmunity = 0; diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index cfe6bfa37f..819936d9c0 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3011,7 +3011,8 @@ namespace CalamityMod.CalPlayer (prismaticGreaves ? 0.1 : 0D) + (plagueReaper ? 0.05 : 0D) + (ascendantInsignia ? 0.05 : 0D) + // Added to soaring insignia's flight to get 30% - (Player.empressBrooch ? 0.25 : 0D); + (Player.empressBrooch ? 0.25 : 0D) + + externalFlightTimeMultBoost; if (community) { diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 7857a0df85..3bc37856ff 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -670,6 +670,12 @@ namespace CalamityMod p.Calamity().externalAbyssLight += add; } + public static void AddFlightTimeMult(Player p, float add) + { + if (p != null) + p.Calamity().externalFlightTimeMultBoost += add; + } + public static void ToggleInfiniteFlight(Player p, bool enabled) { if (p != null) @@ -692,8 +698,9 @@ namespace CalamityMod p.Calamity().WearingPostMLSummonerSet = enabled; } - public static bool MakeColdImmune(Player p) => p is null ? false : (p.Calamity().externalColdImmunity = true); - public static bool MakeHeatImmune(Player p) => p is null ? false : (p.Calamity().externalHeatImmunity = true); + public static bool SetPlayerColdImmune(Player p, bool cold) => p is not null && (p.Calamity().externalColdImmunity = cold); + public static bool SetPlayerHeatImmune(Player p, bool heat) => p is not null && (p.Calamity().externalHeatImmunity = heat); + public static bool SetPlayerDefenseDamageImmune(Player p, bool dd) => p is not null && (p.Calamity().externalDefenseDamageImmunity = dd); #endregion #region NPC Damage Reduction @@ -1222,7 +1229,6 @@ namespace CalamityMod return null; } - case "GetLight": case "GetLightLevel": case "GetLightStrength": @@ -1252,6 +1258,21 @@ namespace CalamityMod AddAbyssLightStrength(castPlayer(args[1]), light); return null; + case "FlightMult": + case "FlightTimeMult": + case "AddFlightMult": + case "AddFlightTimeMult": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and flight mult change as a float."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify flight mult change as a float."); + if (!(args[2] is float flightMult)) + return new ArgumentException("ERROR: The second argument to \"AddFlightMult\" must be a float."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"AddFlightMult\" must be a Player or an int."); + AddFlightTimeMult(castPlayer(args[1]), flightMult); + return null; + case "InfiniteFlight": case "AddInfiniteFlight": case "EnableInfiniteFlight": @@ -1864,6 +1885,18 @@ namespace CalamityMod return new ArgumentException("ERROR: The first argument to \"SetFirePointBlank\" must be an Item or an int."); return SetFirePointBlank(castItem(args[1]), firePointBlank); + + case "GetPointBlankDuration": + case "GetProjectilePointBlank": + case "GetProjectilePointBlankDuration": + { + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify a Projectile."); + if (!isValidProjectileArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"GetPointBlankDuration\" must be a Projectile."); + return GetPointBlankDuration(castProjectile(args[1])); + } + case "SetPointBlankDuration": case "SetProjectilePointBlank": case "SetProjectilePointBlankDuration": @@ -1881,17 +1914,6 @@ namespace CalamityMod return null; } - case "GetPointBlankDuration": - case "GetProjectilePointBlank": - case "GetProjectilePointBlankDuration": - { - if (args.Length < 2) - return new ArgumentNullException("ERROR: Must specify a Projectile."); - if (!isValidProjectileArg(args[1])) - return new ArgumentException("ERROR: The first argument to \"GetPointBlankDuration\" must be a Projectile."); - return GetPointBlankDuration(castProjectile(args[1])); - } - case "NoDodges": case "DodgesDisabled": case "GetDodgesDisabled": @@ -1904,6 +1926,45 @@ namespace CalamityMod return new ArgumentNullException("ERROR: Must specify a bool."); return DisableAllDodges(disableDodges); + case "SetPlayerColdImmune": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and if the player should be immune to Death Mode cold effects as a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify if a player should be immune to Death Mode cold effects as a bool."); + if (!(args[2] is bool)) + return new ArgumentException("ERROR: The second argument to \"SetPlayerColdImmune\" must be a bool."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetPlayerColdImmune\" must be a Player or an int."); + bool coldImmune = (bool)args[2]; + SetPlayerColdImmune(castPlayer(args[1]), coldImmune); + return null; + + case "SetPlayerHeatImmune": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and if the player should be immune to Death Mode heat effects as a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify if a player should be immune to Death Mode heat effects as a bool."); + if (!(args[2] is bool)) + return new ArgumentException("ERROR: The second argument to \"SetPlayerHeatImmune\" must be a bool."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetPlayerHeatImmune\" must be a Player or an int."); + bool heatImmune = (bool)args[2]; + SetPlayerHeatImmune(castPlayer(args[1]), heatImmune); + return null; + + case "SetPlayerDefenseDamageImmune": + if (args.Length < 2) + return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and if the player should be immune to defense damage as a bool."); + if (args.Length < 3) + return new ArgumentNullException("ERROR: Must specify if a player should be immune to defense damage as a bool."); + if (!(args[2] is bool)) + return new ArgumentException("ERROR: The second argument to \"SetPlayerDefenseDamageImmune\" must be a bool."); + if (!isValidPlayerArg(args[1])) + return new ArgumentException("ERROR: The first argument to \"SetPlayerDefenseDamageImmune\" must be a Player or an int."); + bool defenseDamageImmune = (bool)args[2]; + SetPlayerDefenseDamageImmune(castPlayer(args[1]), defenseDamageImmune); + return null; + case "AcidRainActive": case "IsAcidRainActive": case "GetAcidRainActive":