Mod calls (Fisherman NPC)

From Terraria Mods Wiki
Jump to navigation Jump to search

Fisherman NPC features a few Mod Calls that other mods can use.

General

Call String Return Type Info
"SellModdedItems" bool Returns true or false based on the "Sell Fisherman NPC Modded Items" config setting.
"SellBait" bool Returns true or false based on the "Sell Bait" config setting.
"SellFish" bool Returns true or false based on the "Sell Fish" config setting.
"SellFishingRods" bool Returns true or false based on the "Sell Fishing Rods" config setting.
"SellExtraItems" bool Returns true or false based on the "Sell Extra Items" config setting.
"shopMulti" float Returns the value of the "Shop Price Scaling" config setting divided by 100. Multiply your shop's price with the shopMulti value to have the price over the item scale with the config. Range is 0.5f to 2f.
"CatchNPCs" bool Returns true or false based on the "Catch Fisherman" config setting.

Get Condition

Call String Second Argument Return Type Description
"GetCondition" "SellModdedItems" Condition 'Sell Fisherman NPC Modded Items' config is enabled
"GetCondition" "SellBait" Condition 'Sell Bait' config is enabled
"GetCondition" "SellFish" Condition 'Sell Fish' config is enabled
"GetCondition" "SellFishingRods" Condition 'Sell Fishing Rods' config is enabled
"GetCondition" "SellExtraItems" Condition 'Sell Extra Items' config is enabled
"GetCondition" "TownNPCsCrossModSupport" Condition 'Fisherman Cross Mod Support' config is enabled
"GetCondition" "AnyUnderground" Condition In the Underground, Caverns, Underworld
"GetCondition" "AnyUndergroundOrHardmode" Condition In the Underground, Caverns, Underworld, or Hardmode
"GetCondition" "AnyUndergroundNotDesert" Condition In the Underground, Caverns, Underworld, and not in the Desert
"GetCondition" "InCavernsOrUnderworld" Condition In the Underground, Caverns, Underworld
"GetCondition" "DownedBocOrEoWCrimsonOrHardmode" Condition After defeating Brain of Cthulhu, in a Crimson World, or in Hardmode
"GetCondition" "DownedBocOrEoWCorruptionOrHardmode" Condition After defeating Eater of Worlds, in a Corruption World, or in Hardmode
"GetCondition" "InJungleOrHardmode" Condition In the Jungle or Hardmode
"GetCondition" "InUnderworldOrHardmode" Condition In the Underworld or Hardmode

Add To Shop

There are three types of calls you can make to add items to the shops. Call string is "AddToShop"

Usage: mod.Call("AddToShop", string priceMode, string shop, int item, List<Condition> condition, ...)

string priceMode refers to the price mode on the item. It can be "DefaultPrice", "CustomPrice", or "WithMulti". See their respective sections below for more information.

string shop refers to which shop you want to add the item to. See below for a list of names.

int item refers to the item you want to add to the shop. For vanilla items, use ItemID.Item and for modded items, use ModContent.ItemType<YourItemClass>()

List<Condition> condition refers to the availability of the item. The condition can be anything, but it must be a Condition record. Here are some examples of conditions you may want to use:

  • new List<Condition>() { } for always available.
  • new List<Condition>() { Condition.DownedEyeOfCthulhu} for available after defeating the Eye of Cthulhu.
  • new List<Condition>() { (Condition)fishermanNPC.Call("GetCondition", "AnyUnderground") } for available in any Underground, Caverns, or Underworld layer.
  • new List<Condition>() { Condition.PlayerCarriesItem(ItemID.IronPickaxe) } for available if the player has an Iron Pickaxe in their inventory. This a pre-defined Condition in tModLoader.
  • new List<Condition>() { Condition.MoonPhaseFull } for available if the current Moon phase is a Full Moon (not necessarily nighttime).
  • new List<Condition>() { Condition.DownedQueenBee, Condition.InJungle } for available if Queen Bee has been defeated and the Town NPC/player is in the Jungle.
  • new List<Condition>() { Condition.AnglerQuestsFinishedOver(3) } for available if the player has completed a certain number of Angler quests.

The "AddToShop" calls will return false if unsuccessful. (Returning true doesn't necessarily mean it was successful though. Check the log files for any warnings if you do not see your item in the shops.)

You do not need to worry about setting SellModdedItems or TownNPCsCrossModSupport. That is handled automatically.
You do not need to worry about setting the shop scaling for prices, that is handled automatically as well.
You do not need to worry about checking if the shop is enabled, that is handled automatically as well.

Valid Shop Names

The following are the valid shops that you can specify with "AddToShop"

  • "Bait"
  • "Fish"
  • "Rods"
  • "Extra"

"DefaultPrice"

Usage: mod.Call("AddToShop", "DefaultPrice", string shop, int item, List<Condition> condition)

The price of the item will be the item's value.

"CustomPrice"

Usage: mod.Call("AddToShop", "CustomPrice", string shop, int item, List<Condition> condition, int customPrice)

The price of the item will whatever is set for the customPrice int. The value is in copper coins. 1 is one copper coin, 100 is one silver coin, 10000 is one gold coin, and 1000000 is one platinum coin. Alternatively, you can use Item.buyPrice() to set the value.

"WithMulti"

Usage: mod.Call("AddToShop", "WithDiv", string shop, int item, List<Condition> condition, float priceMulti)

The price of the item will be the item's value * priceMulti. Decimal numbers can be used to reduce the price as well. Example: 2f will double the price and 0.5f will halve the price.

Disable Internal Cross Mod Support

These calls will disable the internal cross mod support for the specified mod.

Call String Second Argument Return Type Description
"DisableInternalCrossModSupport" "CalamityMod" false Disables the internal support for Calamity Mod
"DisableInternalCrossModSupport" "ThoriumMod" false Disables the internal support for Thorium Mod

Log file warnings

If you have done something wrong, there will be warnings printed in the log file to help you figure out what you did wrong.

"Expected a function name for the first argument"

You called nothing?

"Function "function" is not defined by Fisherman NPC"

Your call string is wrong. Make sure you have spelled it correctly.

"Function "function" has been removed by FishermanNPC. Please use "AddToShop"

Calling "GetStatusShopCycle", "GetStatusShop1", or "GetStatusShop2" will show this warning in the logs. These calls have been removed no longer work. "GetStatusShopCycle" will always return -1. "GetStatusShop1" and "GetStatusShop2" will always return false.

"Expected # arguments for Mod.Call("function", "argNames"), got # arguments instead"

You entered the incorrect number of arguments for the call you made. Take a look at the calls above and make sure you have the correct number of arguments passed.

"Argument "arg" of Function "function" is not defined by Fisherman NPC"

The second argument for either the "GetCondition" or "AddToShop" call is incorrect.

"Cross mod SetShopItem(): Item type ID "#" exceeded the number of loaded items!"

The item you set in your "AddToShop" call is larger than the number of loaded items. Use ItemID.Item for vanilla items and ModContent.ItemType<YourItemClass>() for modded items to set the item type.

"Cross mod SetShopItem(): Shop string "string" is not a valid Shop type!"

The shop you set in your "AddToShop" is incorrect. Check the spelling and capitalization.

"Internal cross mod support for Mod has been disabled."

This is just a debug message letting you know that the internal support for that mod has been disabled.

Example Usage

public override void PostSetupContent()
{	
	if (ModLoader.TryGetMod("FishermanNPC", out Mod fishermanNPC))
	{
		fishermanNPC.Call("AddToShop", "DefaultPrice", "Fish", ModContent.ItemType<MyFishItem>(), new List<Condition>() { });
		fishermanNPC.Call("AddToShop", "CustomPrice", "Bait", ModContent.ItemType<MyBaitItem>(), new List<Condition>() { Condition.AnglerQuestsFinishedOver(3) }, 5000);
		fishermanNPC.Call("AddToShop", "WithMulti", "Bait", (int)ItemID.LadyBug, new List<Condition>() { Condition.DownedEyeOfCthulhu }, 5f);
	}
}

See the tModLoader Wiki for information on Mod Calls.

For a working example, take a look at Rijam's Mod: RijamsMod: RijamsMod.cs

Happiness

See this example for adding cross mod happiness through GlobalNPC: BossesAsNPCs: CrossModExamples.cs

For a working example, take a look at Rijam's Mod: RijamsMod: GlobalNPCs.cs