using CalamityMod.CalPlayer;
using CalamityMod.Events;
using CalamityMod.Items;
using CalamityMod.Projectiles;
using CalamityMod.UI;
using CalamityMod.UI.CalamitasEnchants;
using CalamityMod.World;
using System;
using System.Collections.Generic;
using System.Linq;
using Terraria;
namespace CalamityMod
{
public class ModCalls
{
#region Boss / Event Downed
///
/// Returns whether the Calamity boss or event corresponding to the given string has been defeated.
///
/// The boss or event name to check. Many aliases are accepted.
/// Whether the boss or event has been defeated.
public static bool GetBossDowned(string boss)
{
switch (boss.ToLower())
{
default:
return false;
// Because this value will always be true if Acid Rain at any point in the game is beaten.
case "acid rain":
case "acidrain":
case "acid rain 1":
case "acidrain 1":
case "acidrain1":
case "acid rain eoc":
case "acidrain eoc":
case "acidraineoc":
return CalamityWorld.downedEoCAcidRain;
case "desertscourge":
case "desert scourge":
return CalamityWorld.downedDesertScourge;
case "clam":
case "giantclam":
case "giant clam":
return CalamityWorld.downedCLAM;
case "crabulon":
return CalamityWorld.downedCrabulon;
case "hivemind":
case "hive mind":
case "thehivemind":
case "the hive mind":
return CalamityWorld.downedHiveMind;
case "perforator":
case "perforators":
case "theperforators":
case "the perforators":
case "perforatorhive":
case "perforator hive":
case "theperforatorhive":
case "the perforator hive":
return CalamityWorld.downedPerforator;
case "slimegod":
case "slime god":
case "theslimegod":
case "the slime god":
return CalamityWorld.downedSlimeGod;
case "hmclam":
case "clamhm":
case "hm clam":
case "clam hm":
case "hmgiantclam":
case "giantclamhm":
case "hm giant clam":
case "giant clam hm":
case "hardmodeclam":
case "hardmode clam":
case "hardmodegiantclam":
case "hardmode giant clam":
return CalamityWorld.downedCLAMHardMode;
case "cryogen":
return CalamityWorld.downedCryogen;
case "acid rain 2":
case "acidrain 2":
case "acidrain2":
case "acid rain scourge":
case "acid rain aquatic scourge":
case "acid rain aquaticscourge":
case "acidrain scourge":
case "acidrain aquatic scourge":
case "acidrain aquaticscourge":
case "acidrainscourge":
case "acidrainaquaticscourge":
return CalamityWorld.downedAquaticScourgeAcidRain;
case "aquaticscourge":
case "aquatic scourge":
return CalamityWorld.downedAquaticScourge;
case "brimstoneelemental":
case "brimstone elemental":
return CalamityWorld.downedBrimstoneElemental;
case "calamitas":
case "clone":
case "calamitasclone":
case "calamitas clone":
case "clonelamitas":
case "calamitasdoppelganger":
case "calamitas doppelganger":
return CalamityWorld.downedCalamitas;
case "gss":
case "greatsandshark":
case "great sand shark":
return CalamityWorld.downedGSS;
// Don't remove the old references to "Siren" here to avoid breaking other mods
case "sirenleviathan":
case "siren leviathan":
case "sirenandleviathan":
case "siren and leviathan":
case "the siren and the leviathan":
case "siren":
case "thesiren":
case "the siren":
case "anahita":
case "leviathan":
case "theleviathan":
case "the leviathan":
case "anahitaleviathan":
case "anahita leviathan":
case "anahitaandleviathan":
case "anahita and leviathan":
case "anahita and the leviathan":
return CalamityWorld.downedLeviathan;
case "aureus":
case "astrumaureus":
case "astrum aureus":
return CalamityWorld.downedAstrageldon;
case "pbg":
case "plaguebringer":
case "plaguebringergoliath":
case "plaguebringer goliath":
case "theplaguebringergoliath":
case "the plaguebringer goliath":
return CalamityWorld.downedPlaguebringer;
case "scavenger": // backwards compatibility
case "ravager":
return CalamityWorld.downedScavenger;
case "stargod": // backwards compatibility
case "star god": // backwards compatibility
case "astrumdeus":
case "astrum deus":
return CalamityWorld.downedStarGod;
case "guardians":
case "donuts":
case "profanedguardians":
case "profaned guardians":
case "theprofanedguardians":
case "the profaned guardians":
return CalamityWorld.downedGuardians;
case "dragonfolly":
case "the dragonfolly":
case "bumblebirb":
case "bumblefuck":
return CalamityWorld.downedBumble;
case "providence":
case "providencetheprofanedgoddess":
case "providence the profaned goddess":
case "providence, the profaned goddess":
return CalamityWorld.downedProvidence;
case "polterghast":
case "necroghast":
case "necroplasm":
return CalamityWorld.downedPolterghast;
// Old Duke is also Acid Rain tier 3, so he gets those names too
case "oldduke":
case "old duke":
case "theoldduke":
case "the old duke":
case "boomerduke":
case "boomer duke":
case "sulphurduke":
case "sulphur duke":
case "sulfurduke":
case "sulfur duke":
case "acid rain 3":
case "acidrain 3":
case "acidrain3":
case "acid rain duke":
case "acidrain duke":
case "acidrainduke":
return CalamityWorld.downedBoomerDuke;
case "sentinel1": // backwards compatibility
case "void":
case "ceaselessvoid":
case "ceaseless void":
return CalamityWorld.downedSentinel1;
case "sentinel2": // backwards compatibility
case "stormweaver":
case "storm weaver":
return CalamityWorld.downedSentinel2;
case "sentinel3": // backwards compatibility
case "cosmicwraith":
case "cosmic wraith":
case "signus":
case "signusenvoyofthedevourer":
case "signus envoy of the devourer":
case "signus, envoy of the devourer":
return CalamityWorld.downedSentinel3;
case "sentinelany": // backwards compatibility
case "anysentinel":
case "any sentinel":
case "onesentinel":
case "one sentinel":
case "sentinel":
return CalamityWorld.downedSentinel1 || CalamityWorld.downedSentinel2 || CalamityWorld.downedSentinel3;
case "sentinelall": // backwards compatibility
case "sentinels":
case "allsentinel":
case "allsentinels":
case "all sentinels":
return CalamityWorld.downedSentinel1 && CalamityWorld.downedSentinel2 && CalamityWorld.downedSentinel3;
case "dog":
case "devourerofgods":
case "devourer of gods":
case "thedevourerofgods":
case "the devourer of gods":
return CalamityWorld.downedDoG;
case "yharon":
case "jungledragonyharon":
case "jungle dragon yharon":
case "jungle dragon, yharon":
return CalamityWorld.downedYharon;
case "draedon":
case "exomechs":
case "exo mechs":
case "the exo mechs":
case "apollo":
case "artemis":
case "thanatos":
case "ares":
return CalamityWorld.downedExoMechs;
case "scal":
case "supremecalamitas":
case "supreme calamitas":
return CalamityWorld.downedSCal;
case "adulteidolonwyrm":
case "adult eidolon wyrm":
case "adultwyrm":
case "adult wyrm":
case "adulteidolon":
case "adult eidolon":
return CalamityWorld.downedAdultEidolonWyrm;
}
}
#endregion
#region Player in Zone / Area
///
/// Returns whether the specified player is in the Calamity biome or area corresponding to the given string.
///
/// The player whose locale is being questioned.
/// The zone or area name to check. Many aliases are accepted.
/// Whether the player is currently in the zone.
public static bool GetInZone(Player p, string zone)
{
CalamityPlayer mp = p.Calamity();
switch (zone.ToLower())
{
default:
return false;
case "calamity": // backwards compatibility
case "calamitybiome":
case "calamity biome":
case "crag":
case "crags":
case "profanedcrag": // remove these four when the actual profaned biome is added
case "profaned crag":
case "profanedcrags":
case "profaned crags":
case "brimstone":
case "brimstonecrag":
case "brimstone crag":
case "brimstonecrags":
case "brimstone crags":
return mp.ZoneCalamity;
case "astral":
case "astralbiome":
case "astral biome":
case "astralinfection":
case "astral infection":
return mp.ZoneAstral;
case "sunkensea":
case "sunken sea":
case "thesunkensea":
case "the sunken sea":
return mp.ZoneSunkenSea;
case "sulfur":
case "sulphur":
case "sulfursea":
case "sulfur sea":
case "sulphursea":
case "sulphur sea":
case "sulfuroussea":
case "sulfurous sea":
case "sulphuroussea":
case "sulphurous sea":
return mp.ZoneSulphur;
case "abyss":
case "theabyss":
case "the abyss":
case "anyabyss":
case "any abyss":
case "abyssany":
case "any abyss layer":
return mp.ZoneAbyss;
case "abyss1":
case "abyss 1":
case "abyss_1":
case "layer1":
case "layer 1":
case "layer_1":
case "abysslayer1":
case "abyss layer 1":
return mp.ZoneAbyssLayer1;
case "abyss2":
case "abyss 2":
case "abyss_2":
case "layer2":
case "layer 2":
case "layer_2":
case "abysslayer2":
case "abyss layer 2":
return mp.ZoneAbyssLayer2;
case "abyss3":
case "abyss 3":
case "abyss_3":
case "layer3":
case "layer 3":
case "layer_3":
case "abysslayer3":
case "abyss layer 3":
return mp.ZoneAbyssLayer3;
case "abyss4":
case "abyss 4":
case "abyss_4":
case "layer4":
case "layer 4":
case "layer_4":
case "abysslayer4":
case "abyss layer 4":
return mp.ZoneAbyssLayer4;
}
}
#endregion
#region Difficulty Modes
///
/// Returns whether the Calamity difficulty modifier corresponding to the given string is currently active.
///
/// The difficulty modifier to check for.
/// Whether the difficulty is currently active.
public static bool GetDifficultyActive(string difficulty)
{
switch (difficulty.ToLower())
{
default:
return false;
case "revengeance":
case "rev":
case "revengeancemode":
case "revengeance mode":
return CalamityWorld.revenge;
case "death":
case "deathmode":
case "death mode":
return CalamityWorld.death;
case "malice":
case "malicemode":
case "malice mode":
return CalamityWorld.malice;
case "br":
case "bossrush":
case "boss rush":
case "bossrushactive":
case "boss rush active":
return BossRushEvent.BossRushActive;
case "armageddon":
case "arma":
case "instakill":
case "instagib":
case "armageddonmode":
case "armageddon mode":
return CalamityWorld.armageddon;
case "ironheart":
case "iron heart":
return CalamityWorld.ironHeart;
}
}
///
/// Either enables or disables the Calamity difficulty modifier corresponding to the given string.
/// Unlike the in-game mode changing items, this has no ancillary effects such as failing if a boss is alive or instantly killing players.
///
/// The difficulty modifier to edit.
/// Whether to enable or disable the difficulty.
///
public static bool SetDifficultyActive(string difficulty, bool enabled)
{
switch (difficulty.ToLower())
{
default:
return false;
case "revengeance":
case "rev":
case "revengeancemode":
case "revengeance mode":
return CalamityWorld.revenge = enabled;
case "death":
case "deathmode":
case "death mode":
return CalamityWorld.death = enabled;
case "malice":
case "malicemode":
case "malice mode":
return CalamityWorld.malice = enabled;
case "br":
case "bossrush":
case "boss rush":
case "bossrushactive":
case "boss rush active":
return BossRushEvent.BossRushActive = enabled;
case "armageddon":
case "arma":
case "instakill":
case "instagib":
case "armageddonmode":
case "armageddon mode":
return CalamityWorld.armageddon = enabled;
case "ironheart":
case "iron heart":
case "steelsoul":
case "steel soul":
case "permadeath":
return CalamityWorld.ironHeart = enabled;
}
}
#endregion
#region Rogue Class
///
/// Gets a player's current rogue damage stat.
///
/// The player whose rogue damage is being queried.
/// Current rogue damage boost. 1f is no bonus, 2f is +100%.
public static float GetRogueDamage(Player p) => p?.Calamity()?.throwingDamage ?? 1f;
///
/// Adds a flat amount of rogue damage stat to a player. This amount can be negative.
///
/// The player whose rogue damage is being modified.
/// The amount of rogue damage to add or subtract (if negative).
/// The player's new rogue damage stat.
public static float AddRogueDamage(Player p, float add) => p is null ? 1f : (p.Calamity().throwingDamage += add);
///
/// Gets a player's current rogue critical strike chance.
///
/// The player whose rogue crit is being queried.
/// Current rogue critical strike chance. 0 is no additional crit, 8 is +8% crit chance.
public static int GetRogueCrit(Player p) => p?.Calamity()?.throwingCrit ?? 0;
///
/// Adds a flat amount of rogue crit to a player. This amount can be negative.
///
/// The player whose rogue crit is being modified.
/// The amount of rogue crit to add or subtract (if negative).
/// The player's new rogue crit stat.
public static int AddRogueCrit(Player p, int add) => p is null ? 0 : (p.Calamity().throwingCrit += add);
///
/// Gets a player's current rogue projectile velocity multiplier.
///
/// The player whose rogue velocity is being queried.
/// Current rogue projectile velocity multiplier. 1f is no bonus, 2f doubles projectile speed.
public static float GetRogueVelocity(Player p) => p?.Calamity()?.throwingVelocity ?? 1f;
///
/// Adds a flat amount of rogue velocity stat to a player. This amount can be negative.
///
/// The player whose rogue velocity is being modified.
/// The amount of rogue velocity to add or subtract (if negative).
/// The player's new rogue velocity stat.
public static float AddRogueVelocity(Player p, float add) => p is null ? 1f : (p.Calamity().throwingVelocity += add);
public static float GetCurrentStealth(Player p) => p?.Calamity()?.rogueStealth ?? 0f;
public static float GetMaxStealth(Player p) => p?.Calamity()?.rogueStealthMax ?? 0f;
public static float AddMaxStealth(Player p, float add) => p is null ? 0f : (p.Calamity().rogueStealthMax += add);
///
/// Gets whether the given projectile is classified as rogue.
///
/// The projectile which is being checked.
/// Whether the projectile is rogue.
public static bool IsRogue(Projectile p)
{
if (p is null || p.Calamity() is null)
return false;
CalamityGlobalProjectile cgp = p.Calamity();
return cgp.rogue | cgp.forceRogue;
}
///
/// Sets whether the given projectile is classified as rogue. If set to true, also forces the projectile to be rogue every single frame.
///
/// The projectile whose rogue classification is being toggled.
/// The value to apply.
/// Whether the projectile is now rogue.
public static bool SetRogue(Projectile p, bool isRogue)
{
if (p is null || p.Calamity() is null)
return false;
CalamityGlobalProjectile cgp = p.Calamity();
cgp.forceRogue = cgp.rogue = isRogue;
return cgp.rogue;
}
#endregion
#region Other Player Stats
public static int GetLightStrength(Player p) => p?.Calamity()?.GetTotalLightStrength() ?? 0;
public static void AddAbyssLightStrength(Player p, int add)
{
if (p != null)
p.Calamity().externalAbyssLight += add;
}
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);
#endregion
#region Set Damage Reduction
public static float SetDamageReduction(int npcID, float dr)
{
CalamityMod.DRValues.TryGetValue(npcID, out float oldDR);
CalamityMod.DRValues.Remove(npcID);
CalamityMod.DRValues.Add(npcID, dr);
return oldDR;
}
#endregion
#region Boss Health Bars
public static bool BossHealthBarVisible() => Main.LocalPlayer.Calamity().drawBossHPBar;
public static bool SetBossHealthBarVisible(bool visible) => Main.LocalPlayer.Calamity().drawBossHPBar = visible;
#endregion
#region Item Rarity
public static int GetCalamityRarity(Item item)
{
CalamityGlobalItem cgi = item.Calamity();
CalamityRarity calrare = cgi.customRarity;
if (calrare == CalamityRarity.NoEffect)
return item.rare;
return (int)calrare;
}
public static bool SetCalamityRarity(Item item, int rarityNum)
{
CalamityGlobalItem cgi = item.Calamity();
cgi.customRarity = (CalamityRarity)rarityNum;
return cgi.customRarity != CalamityRarity.NoEffect;
}
#endregion
#region Call
public static object Call(params object[] args)
{
bool isValidPlayerArg(object o) => o is int || o is Player;
bool isValidProjectileArg(object o) => o is int || o is Projectile;
Player castPlayer(object o)
{
if (o is int i)
return Main.player[i];
else if (o is Player p)
return p;
return null;
}
Projectile castProjectile(object o)
{
if (o is int i)
return Main.projectile[i];
else if (o is Projectile p)
return p;
return null;
}
// Certain IDs in vanilla's files are shorts instead of ints for some reason.
// Instead of expecting developers to have to manually cast these IDs, this function is used
// to handle IDs that are either ints OR shorts, without the worry of missing a cast and wondering why
// the Mod Call did nothing.
bool castID(object o, out int id)
{
id = -1;
if (!(o is int) && !(o is short))
return false;
if (o is short shortID)
id = shortID;
if (o is int intID)
id = intID;
return true;
}
if (args is null || args.Length <= 0)
return new ArgumentNullException("ERROR: No function name specified. First argument must be a function name.");
if (!(args[0] is string))
return new ArgumentException("ERROR: First argument must be a string function name.");
string methodName = args[0].ToString();
switch (methodName)
{
case "Downed":
case "GetDowned":
case "BossDowned":
case "GetBossDowned":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a boss or event name as a string.");
if (!(args[1] is string))
return new ArgumentException("ERROR: The argument to \"Downed\" must be a string.");
return GetBossDowned(args[1].ToString());
case "Zone":
case "GetZone":
case "InZone":
case "GetInZone":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and a zone name as a string.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify a zone name as a string.");
if (!(args[2] is string))
return new ArgumentException("ERROR: The second argument to \"InZone\" must be a string.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"InZone\" must be a Player or an int.");
return GetInZone(castPlayer(args[1]), args[2].ToString());
case "Difficulty":
case "GetDifficulty":
case "DifficultyActive":
case "GetDifficultyActive":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string.");
if (!(args[1] is string))
return new ArgumentException("ERROR: The argument to \"Difficulty\" must be a string.");
return GetDifficultyActive(args[1].ToString());
case "SetDifficulty":
case "SetDifficultyActive":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a difficulty mode name as a string and a bool.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify a bool.");
if (!(args[2] is bool enabled))
return new ArgumentException("ERROR: The second argument to \"SetDifficulty\" must be a bool.");
if (!(args[1] is string))
return new ArgumentException("ERROR: The first argument to \"SetDifficulty\" must be a string.");
return SetDifficultyActive(args[1].ToString(), enabled);
case "GetLight":
case "GetLightLevel":
case "GetLightStrength":
case "GetAbyssLight":
case "GetAbyssLightLevel":
case "GetAbyssLightStrength":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if(!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"GetLightStrength\" must be a Player or an int.");
return GetLightStrength(castPlayer(args[1]));
case "AddLight":
case "AddLightLevel":
case "AddLightStrength":
case "AddAbyssLight":
case "AddAbyssLightLevel":
case "AddAbyssLightStrength":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and light strength change as an int.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify light strength change as an int.");
if (!(args[2] is int light))
return new ArgumentException("ERROR: The second argument to \"AddLightStrength\" must be an int.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"AddLightStrength\" must be a Player or an int.");
AddAbyssLightStrength(castPlayer(args[1]), light);
return null;
case "ColdImmune":
case "ColdImmunity":
case "GiveColdImmunity":
case "MakeColdImmune":
case "DeathModeCold":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"DeathModeCold\" must be a Player or an int.");
return MakeColdImmune(castPlayer(args[1]));
case "HeatImmune":
case "HeatImmunity":
case "GiveHeatImmunity":
case "MakeHeatImmune":
case "DeathModeHeat":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"DeathModeHeat\" must be a Player or an int.");
return MakeHeatImmune(castPlayer(args[1]));
case "GetRogueDamage":
case "GetRogueDmg":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"GetRogueDamage\" must be a Player or an int.");
return GetRogueDamage(castPlayer(args[1]));
case "GetRogueCrit":
case "GetRogueCritChance":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"GetRogueCrit\" must be a Player or an int.");
return GetRogueCrit(castPlayer(args[1]));
case "GetRogueVelocity":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The argument to \"GetRogueVelocity\" must be a Player or an int.");
return GetRogueVelocity(castPlayer(args[1]));
case "AddRogueDamage":
case "AddRogueDmg":
case "ModifyRogueDamage":
case "ModifyRogueDmg":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue damage change as a float.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify rogue damage change as a float.");
if (!(args[2] is float damage))
return new ArgumentException("ERROR: The second argument to \"AddRogueDamage\" must be a float.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"AddRogueDamage\" must be a Player or an int.");
return AddRogueDamage(castPlayer(args[1]), damage);
case "AddRogueCrit":
case "AddRogueCritChance":
case "ModifyRogueCrit":
case "ModifyRogueCritChance":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue crit change as an int.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify rogue crit change as a float.");
if (!(args[2] is int crit))
return new ArgumentException("ERROR: The second argument to \"AddRogueCrit\" must be an int.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"AddRogueCrit\" must be a Player or an int.");
return AddRogueCrit(castPlayer(args[1]), crit);
case "AddRogueVelocity":
case "ModifyRogueVelocity":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue velocity change as a float.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify rogue velocity change as a float.");
if (!(args[2] is float velocity))
return new ArgumentException("ERROR: The second argument to \"AddRogueVelocity\" must be a float.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"AddRogueVelocity\" must be a Player or an int.");
return AddRogueVelocity(castPlayer(args[1]), velocity);
case "GetStealth":
case "GetCurrentStealth":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"GetStealth\" must be a Player or an int.");
return GetCurrentStealth(castPlayer(args[1]));
case "GetMaxStealth":
case "GetStealthCap":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Player object (or int index of a Player).");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"GetMaxStealth\" must be a Player or an int.");
return GetMaxStealth(castPlayer(args[1]));
case "AddMaxStealth":
case "ModifyMaxStealth":
case "ModifyStealthCap":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Player object (or int index of a Player) and rogue max stealth as a float.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify rogue max stealth as a float.");
if (!(args[2] is float maxStealth))
return new ArgumentException("ERROR: The second argument to \"AddMaxStealth\" must be a float.");
if (!isValidPlayerArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"AddMaxStealth\" must be a Player or an int.");
return AddMaxStealth(castPlayer(args[1]), maxStealth);
case "IsRogue":
case "IsProjRogue":
case "IsProjectileRogue":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify a Projectile object (or int index of a Projectile).");
if (!isValidProjectileArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"IsRogue\" must be a Projectile or an int.");
return IsRogue(castProjectile(args[1]));
case "SetRogue":
case "SetProjRogue":
case "SetProjectileRogue":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both a Projectile object (or int index of a Projectile) and a bool.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify rogue status as a bool.");
if (!(args[2] is bool isRogue))
return new ArgumentException("ERROR: The second argument to \"SetRogue\" must be a bool.");
if (!isValidProjectileArg(args[1]))
return new ArgumentException("ERROR: The first argument to \"SetRogue\" must be a Projectile or an int.");
return SetRogue(castProjectile(args[1]), isRogue);
case "DR":
case "DamageReduction":
case "SetDR":
case "SetDamageReduction":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both NPC ID as an int and damage reduction as a float or double.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify damage reduction as a float or double.");
if (!(args[2] is float) && !(args[2] is double))
return new ArgumentException("ERROR: The second argument to \"SetDamageReduction\" must be a float or a double.");
if (!castID(args[1], out int npcID))
return new ArgumentException("ERROR: The first argument to \"SetDamageReduction\" must be an int or short ID.");
float DR = (float)args[2];
return SetDamageReduction(npcID, DR);
case "BossHealthBarVisible":
case "BossHealthBarsVisible":
case "GetBossHealthBarVisible":
case "GetBossHealthBarsVisible":
return BossHealthBarVisible();
case "SetBossHealthBarVisible":
case "SetBossHealthBarsVisible":
if (args.Length < 2 || !(args[1] is bool bossBarEnabled))
return new ArgumentNullException("ERROR: Must specify a bool.");
return SetBossHealthBarVisible(bossBarEnabled);
case "GetRarity":
case "GetItemRarity":
case "GetCalamityRarity":
case "GetPostMLRarity":
case "GetPostMoonLordRarity":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify an Item.");
if (!(args[1] is Item))
return new ArgumentException("ERROR: The first argument to \"GetCalamityRarity\" must be an Item.");
Item itemToGet = (Item)args[1];
return GetCalamityRarity(itemToGet);
case "SetRarity":
case "SetItemRarity":
case "SetCalamityRarity":
case "SetPostMLRarity":
case "SetPostMoonLordRarity":
if (args.Length < 2)
return new ArgumentNullException("ERROR: Must specify both an Item and desired rarity as an int or short ID.");
if (args.Length < 3)
return new ArgumentNullException("ERROR: Must specify desired rarity as an int or short ID.");
if (!castID(args[2], out int rarity))
return new ArgumentException("ERROR: The second argument to \"SetCalamityRarity\" must be an int or short ID.");
if (!(args[1] is Item))
return new ArgumentException("ERROR: The first argument to \"SetCalamityRarity\" must be an Item.");
Item itemToSet = (Item)args[1];
return SetCalamityRarity(itemToSet, rarity);
case "GetDoGCountdown":
case "GetDoGFightCountdown":
case "GetDoGStage2Countdown":
return CalamityWorld.DoGSecondStageCountdown;
case "AcidRainActive":
case "IsAcidRainActive":
case "GetAcidRainActive":
return CalamityWorld.rainingAcid;
case "StartAcidRain":
AcidRainEvent.TryStartEvent(true);
CalamityNetcode.SyncWorld();
return true;
case "StopAcidRain":
if (CalamityWorld.rainingAcid)
{
CalamityWorld.acidRainPoints = 0;
CalamityWorld.triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
return true;
// This is intentionally separate from the above because it will stop other events when they are added.
case "AbominationnClearEvents":
bool eventActive = CalamityWorld.rainingAcid;
bool canClear = Convert.ToBoolean(args[1]); //This is to indicate whether abomm is able to clear the event due to a cooldown
if (eventActive && canClear) //adjust based on other events when added.
{
CalamityWorld.acidRainPoints = 0;
CalamityWorld.triedToSummonOldDuke = false;
AcidRainEvent.UpdateInvasion(false);
}
return eventActive;
case "ExcludeMinionsFromResurrection":
// This assumes all arguments after the calling command name are projectile types.
IEnumerable