Mod Calls

From Calamity Mod Wiki
Jump to navigation Jump to search

Mod Calls are special functions that can be used with tModLoader's .Call() function to get or set different values from other mods. This page lists the Mod Calls that are provided by the Calamity Mod along with what they are used for.

Note that Rogue damage and Rogue crit are affected by vanilla Throwing stats, and adding to Rogue stats through these calls will add on top of any throwing stats the player is given.

An asterisk (*) after a parameter type indicates that the function accepts multiple arguments of that type at once. Optional arguments will be specified, along with their default value if applicable.

Mod Calls

Player

Function Returns Parameters
GetInZone (bool) Whether the specified player is in a given Calamity biome or area. (Player) The player whose locale is being questioned.
(string) The zone or area name to check. Many aliases are accepted.
GetRogueVelocity (float) The specified player's rogue projectile speed modifier. 1f = no bonus, 2f = +100%. (Player) The player whose rogue velocity is being queried.
AddRogueVelocity (float) The specified player's new rogue projectile speed modifier. (Player) The player whose rogue damage is being modified.
(float) The amount of rogue velocity to add or subtract (if negative).
GetRage (float) The specified player's current rage. (Player) The player whose rage is being queried.
GetRageMax (float) The specified player's current max rage. (Player) The player whose max rage is being queried.
GetAdrenaline (float) The specified player's current adrenaline. (Player) The player whose adrenaline is being queried.
GetAdrenalineMax (float) The specified player's current max adrenaline. (Player) The player whose max adrenaline is being queried.
GetCurrentStealth (float) The specified player's current stealth. 0.1f = 10, 0.5f = 50. (Player) The player whose stealth is being queried.
GetMaxStealth (float) The specified player's maximum stealth. 0.1f = 10, 0.5f = 50. (Player) The player whose maximum stealth is being queried.
AddMaxStealth (float) The specified player's new maximum stealth. (Player) The player whose max stealth is being modified.
(float) The amount of stealth to add or subtract (if negative).
CanStealthStrike (bool) Whether or not the player can perform a stealth strike. (Player) The player who is being checked.
GetLightStrength (int) The specified player's light strength. (Player) The player whose light strength is being queried.
AddAbyssLightStrength (void) (Player) The player whose light strength is being modified.
(int) The light strength to add to the Abyss.
ToggleInfiniteFlight (void) (Player) The player who should be given infinite flight
(bool) Whether infinite flight should be enabled or disabled.
GetWearingPostMLSummonerArmor (bool) Whether or not the specified player is wearing Post-Moon Lord summoner armor. (Player) The player being checked.
SetWearingPostMLSummonerArmor (void) (Player) The player whose Post-Moon Lord summoner armor status is being modified.
(bool) Whether the player should be counted as having Post-Moon Lord summoner armor on.
GetWearingRogueArmor (bool) Whether or not the specified player is wearing rogue armor. (Player) The player being checked.
SetWearingRogueArmor (void) (Player) The player whose rogue armor status is being modified.
(bool) Whether the player should be counted as having rogue armor on.
GetRightClickListener (bool) Whether or not the player's right click is being detected by Calamity. (Player) The player being checked.
GetRightClick (bool) Whether or not Calamity's right click listener detects the player pressing right click. (Player) The player being checked.
SetRightClickListener (void) (Player) The player whose right click listener is being modified
(bool) Whether the listener should be enabled or disabled.
GetMouseWorldListener (bool) Whether or not the player's mouse position is being detected by Calamity. (Player) The player being checked.
GetMouseWorld (Vector2) The player's mouse's current in-world position as detected by Calamity. (Player) The player being checked.
SetMouseWorldListener (void) (Player) The player whose mouse world listener is being modified
(bool) Whether the listener should be enabled or disabled.

NPC

Function Returns Parameters
SetDamageReduction (float) The NPC's old damage reduction. 0.1f = 10%, 0.5f = 50%. (int) The ID of the NPC whose dr is being modified
(float) The new dr for the NPC.
GetDamageReduction (bool) The specified NPC's current damage reduction. (NPC) The NPC whose dr is being queried.
SetDamageReductionSpecific (void) (NPC) The NPC whose dr is being modified
(float) The new dr for the NPC.
GetDefenseDamageNPC (bool) Whether or not contact damage from the specified NPC inflicts defense damage (NPC) The NPC whose ability to inflict defense damage is being checked.
SetDefenseDamageNPC (void) (NPC) The NPC whose ability to inflict defense damage on contact is being modified.
(bool) Whether or not the NPC should inflict defense damage on contact.
GetDebuffVulnerability (bool?) The NPC's vulnerability to the specified debuff category. False means an NPC is resistant, and takes less damage. Null means an NPC takes normal damage. True means an NPC is vulnerable, and takes extra damage. (NPC) The NPC whose debuff vulnerability is being checked.
(string) The debuff category to check. Many aliases are accepted.
SetDebuffVulnerability (void) (NPC) The NPC whose debuff vulnerability is being modified.
(string) The debuff category's resistance status to modify. Many aliases are accepted.
GetCalamityAI (float[]) The NPC's Calamity AI variables. Calamity's AI array contains 4 elements (0-3). If the NPC is null or the Calamity AI is not found, an empty array is returned. (NPC) The NPC whose Calamity AI variables are being queried.
SetCalamityAI (void) (NPC) The NPC whose Calamity AI variables are being modified.
(int) The AI slot (array index) to modify
(float) The new value the AI slot should be set to.
DeclareMiniboss (null) (int) The id of the NPC to be set as a miniboss.
GetShouldClossBossHealthBar (bool) Whether or not the specified NPC is currently being forced to close its boss health bar. (NPC) The NPC whose health bar visibility is being checked.
SetShouldClossBossHealthBar (null) (NPC) The NPC whose health bar visibility is being modified.
(bool) Whether or not the boss health bar should display.
ExcludeBossFromHealthbar (null) (int) The id of the NPC to be excluded from having a Calamity boss health bar.
DeclareOneToManyRelationshipForHealthBar (null) (int) The id of the NPC to act as a key for the relationship.
(int*) The ids of the all the NPCs in the relationship, including the key NPC.
DeclareSpecialHPCalculationDecisionForHealthBar (null) (Func<NPC, bool>) The function to decide whether each NPC applies for this special health calculation. Returns whether the specified NPC should get special health calculations or not.
(Func<NPC, bool, long>) The function that does the special HP calculations. The boolean parameter specifies if the function accumulates max health (true) or just health (false). Returns the calculated health for the given NPC.
CreateNameExtensionHandlerForHealthBar (null) (LocalizedText) The name of the extension to create.
(int) The id of the main NPC for the extension.
(int*) The ids of the NPCs in the extension, which may or may not include the main NPC.
RegisterTownNPCShop (null) (int) The NPC's id.
(Predicate<Player>) The player check for if a shop notification should display.
(Action<Player, bool>) A function which sets the given player's shop notification status for an NPC based on the Action's bool.
SendNPCShopAlert (null) (int[]) An array of NPC ids which should be alerted.
(bool) The bool which the alert is tied to. In practice, a false bool will activate the alert, while a true one will not.

Item

Function Returns Parameters
GetChargeable (bool) Whether or not the item can be charged. (Item) The item whose chargeability is being queried.
SetChargeable (void) (Item) The item whose chargeability is being modified.
(bool) Whether or not the item should be chargeable.
GetCharge (float) The item's current charge. (Item) The item whose charge is being queried.
SetCharge (void) (Item) The item whose charge is being modified.
(float) The new charge value for the item.
GetMaxCharge (float) The item's max charge. (Item) The item whose max charge is being queried.
SetMaxCharge (void) (Item) The item whose max charge is being modified.
(float) The new max charge value for the item.
GetChargePerUse (float) How much charge the item consumes per use. (Item) The item whose use charge is being queried.
SetChargePerUse (void) (Item) The item whose use charge is being modified.
The new charge per use value for the item.
GetChargePerAltUse (float) How much charge the item consumes per alt use. (Item) The item whose alt use charge is being queried.
SetChargePerAltUse (void) (Item) The item whose alt use charge is being modified.
The new charge per alt use value for the item.
CanFirePointBlank (bool) Whether or not the specified item can fire point-blank shots. (Item) The item whose ability to fire point-blank shots is being queried.
SetFirePointBlank (void) (Item) The item whose ability to fire point-blank is being modified.
(bool) Whether or not the item should fire point-blank shots.
AddToVeneratedLocketBanlist (void) (int) The id of the item to exclude from the Venerated Locket's clone mechanic.
MakeItemExhumable (null) (int) The id of the item to be exhumed.
(int) The id of the resulting exhumed item.

Projectile

Function Returns Parameters
GetStealthProjectile (bool) Whether or not the specified projectile is a stealth strike (Projectile) The projectile whose stealth strike status is being checked.
SetStealthProjectile (void) (Projectile) The projectile whose stealth strike status is being modified.
(bool) Whether or not the projectile should count as a stealth strike.
GetDefenseDamageProjectile (bool) Whether or not the specified projectile inflicts defense damage (Projectile) The projectile whose ability to inflict defense damage is being checked.
SetDefenseDamageProjectile (void) (Projectile) The projectile whose ability to inflict defense damage is being modified.
(bool) Whether or not the projectile should inflict defense damage.
GetPointBlankDuration (float) How many frames left the projectile can deal point-blank damage. (Projectile) The projectile whose point-blank duration is being queried.
SetPointBlankDuration (void) (Projectile) The projectile whose point-blank duration is being modified.
(float) How many frames left that the weapon should deal point-blank damage.

Misc

Function Returns Parameters
GetBossDowned (bool) Whether the boss or event has been defeated. (string) The boss or event to check for. Many different aliases are accepted.
GetDifficultyActive (bool) Whether the Calamity difficulty modifier is currently active. (string) The difficulty modifier to check for. Many aliases are accepted.
SetDifficultyActive (bool) If it has succeeded or not. (string) The difficulty modifier to toggle on or off. Many aliases are accepted.
BossHealthBarVisible (bool) Whether Calamity's Boss Health Bar is visible. None.
SetBossHealthBarVisible (bool) Whether the visibility was changed. (bool) Whether the Boss Health Bar should be visible or invisible.
AcidRainActive (bool) Whether the Acid Rain is currently active or not. n/a
StartAcidRain (bool) True. n/a
StopAcidRain (bool) True. n/a
AbominationnClearEvents (bool) True if the Acid Rain has not been successfully cleared, else false. (bool) If the Abominationn can currently clear events.
CreateEnchantment (null) (LocalizedText) The name for the enchantment.
(LocalizedText) The description for the enchantment.
(int) The id for the enchantment.
(Predicate<Item>) A predicate used to determine if an item can be enchanted or not.
(string) The path to the texture for the enchantment. May also be null, if no texture should be drawn.
(Action<Item>) (optional) The hold effect for the enchantment.
(Action<Player>) (optional) The creation effect for the enchantment.
GetBossRushEntries (List<(int, int, Action<int>, int, bool, float, int[], int[])>) A list of tuples representing the boss rush entries. The values inside the tuples have the following meanings: NPC id, time change (1: day, -1: night, 0: no change), boss spawning function, overriding countdown, whether the boss needs a special sound effect on spawn, the dimness factor to use once the boss is spawned, ids of NPCs to not be deleted once the boss spawns, list of any other NPC ids that need to be killed for the event to progress. n/a
SetBossRushEntries (null) (List<(int, int, Action<int>, int, bool, float, int[], int[])>) A list of tuples representing the boss rush entries to add. Explanations of the values can be found in the above entry.
CreateCustomDeathEffectForBossRush (null) (int) The id of the NPC to have the custom effect.
(Action<NPC>) The custom death effect to be set for the given NPC.
LoadParticleInstances (null) (Mod) The id of the mod to load particles from.
RegisterModCooldowns (null) (Mod) The id of the mod to register cooldowns from.
AddDifficultyToUI (null) (DifficultyMode) The difficulty mode being added.
RegisterDebuff (null) (string) The path to the debuff's sprite.
(Predicate<NPC>) The check for if the NPC has the debuff.
GetBossHealthBoost (float) The current value of Calamity's boss health multiplier configuration option. n/a

Aliases

Some of the functions above mention accepting different aliases for the string parameters. One alias for each flag will be listed below in tables for each function, however alternatives that use different cases or spacing will still be accepted.

GetBossDowned

Queriable Strings
acidrain
acidraineoc
desertscourge
giantclam
crabulon
hivemind
perforator
slimegod
hmclam
cryogen
acidrainscourge
aquaticscourge
cragmawmire
brimstoneelemental
calamitasclone
greatsandshark
anahitaleviathan
astrumaureus
plaguebringergoliath
ravager
astrumdeus
guardians
dragonfolly
providence
polterghast
mauler
nuclearterror
oldduke
ceaselessvoid
stormweaver
signus
anysentinel
allsentinel
devourerofgods
yharon
exomechs
exotwins
thanatos
ares
calamitas
primordialwyrm
bossrush

GetInZone

Queriable Strings
crags
astral
sunkensea
sulphursea
abyss
layer1
layer2
layer3
layer4

DifficultyActive

Queriable Strings
revengeance
death
bossrush

DebuffVulnerabilities

Queriable Strings
cold
electricity
heat
sickness
water

Notes

  • Providing incorrect or too few/many arguments to any of these functions will result in an ArgumentException being thrown.

History

These history sections are still a work-in-progress, and may not yet contain changes relevant to the current version of the Calamity Mod.
  • 2.0.3.007:
    • Introduced mod calls for adding debuffs to the NPC debuff display, allowing bosses to hide the boss health bar, and allowing Town NPCs to be affected by the New Shop Inventory Alert configuration option.
    • Removed mod calls for getting and setting armor set bonuses.
  • 2.0.3.006: Introduced mod calls for getting and setting projectiles as stealth strike projectiles.
  • 2.0.3.005: Added several aliases for the Abyss for mod calls.
  • 2.0.3.003: Introduced mod calls for wearing a rogue armor set, wearing a post-Moon Lord summoner armor set, adding custom difficulties to the difficulty UI indicator, and preventing a rogue weapon from spawning clone projectiles with Venerated Locket.
  • 2.0.3.002:
    • Introduced mod calls for enabling and disabling infinite flight.
    • Added additional mod call aliases for Artemis and Apollo, Primordial Wyrm, and Yharon, Dragon of Rebirth.
  • 2.0.3.001: Introduced mod calls for detecting defeats of each individual Exo Mech, checking if the player can perform a stealth strike, getting current and max Adrenaline and Rage, getting and setting if an item is chargeable, getting and setting how much charge per use an item uses, getting and setting an item's max charge, getting and setting an item's current charge, getting and setting Calamity's mouse position and right click listener values, checking if Calamity's mouse position and right click listening is enabled, getting and setting damage reduction for a specific NPC, getting and setting the ability for an NPC or projectile to inflict defense damage, getting and setting elemental debuff immunities on NPCs, and getting and setting Calamity's custom AI variables.
  • 2.0.1.002: Introduced CanFirePointBlank, SetAmalgamBuffList, SetFirePointBlank, and SetPersistentBuffList.
  • 1.5.1.001: Introduced a mod call that allows particles to be loaded.
  • 1.5.0.003: "empyrean" can now be used as a substitute for the "xerocSet" mod call.
  • 1.5.0.002: Introduced a mod call that allows for making exhumed versions of items.
  • 1.5.0.001: Introduced mod calls for modifying entries in the Boss Rush, detecting if the Hardmode Giant Clam has been defeated, detecting and setting Sulphurous and Titan Heart armor set bonuses, starting and ending Acid Rain, detecting The Devourer of Gods' phase 2 countdown, defining items as rogue weapons, and various edits to the Calamity Boss Health Bar.
  • 1.4.5.002: Fixed a mod call error where Desert Prowler armor was an alias for Snow Ruffian armor.
  • 1.4.3.002:
    • Introduced calls for detecting and setting Abyss light levels, and Death Mode heat and cold immunity.
    • The SetDifficultyActive and GetDifficultyActive Mod Calls now support Boss Rush.
  • 1.4.3.001: Introduced them for Umbraphile armor, defeating buffed Mothron, defeating Giant Clam, defeating Great Sand Shark, drawing the Boss Health Bar, turning an item or projectile into Rogue class, and adding or obtaining player rogue stealth.
  • 1.4.2.107: Introduced setting Calamity armor set bonuses, and getting and setting rogue damage, velocity, and critical strike chance.
  • 1.4.2.106: Introduced adding damage reduction to NPCs.
  • 1.4.2.105: Introduced allowing for other mods to detect Calamity armor set bonuses.
  • 1.2.0.001: Introduced GetBossDowned and GetInZone mod calls.