-
-
Notifications
You must be signed in to change notification settings - Fork 3
Cross Mod Content and API
The Options do copy even modded projectiles from other mods, which is great. This comes with a cost, however. Due to a mod creator's unique way of coding projectile AI, the options may not behave properly if their AI and behavior are advanced, and may duplicate generated projectiles created by another friendly projectile, or even projectiles owned by the enemy.
This is why there are many filters if the projectile should be duplicated. As a default behavior, this mod requires both vanilla and modded projectiles to go through the filter if they can be duplicated or not. However, there is a way to bypass the filters. Read more to find out how.
As a mod creator, one might want to have the Options work well with their own mod's projectile. Below are ways on how to achieve this.
It is highly unlikely that we will be able to support all existing mods. The more appropriate description for the task is it being impossible to complete.
If you one wants their mod's projectiles to be compatible with the Options, then they should take these items below in mind when implementing their projectile:
- (*) Make sure the projectile is active. (
projectile.active = true;
) - (*) Make sure the projectile is not a Yo-yo.
- Make sure the projectile is not hostile. (
projectile.hostile = false;
) - Make sure the projectile is friendly. (
projectile.friendly = true;
) - Make sure the projectile is not an NPC projectile. (
projectile.npcProj = false;
) - Make sure the projectile has damage.
- Make sure the projectile can deal critical damage. (Melee, Ranged, Thrown and Magic)
- Make sure the projectile is not a minion. (
projectile.minion = false;
) - Make sure the projectile is not a trap. (
projectile.trap = false;
) - (*) Make sure the projectile is owned by the same player who generated the projectile.
- Either one of these apply. If at least one of these are true, then the filters will pass (while still taking account the above items):
- Make sure the weapon is set to shoot that projectile. (
item.shoot = projectile.type
, whereitem
is a weapon) - Make sure that the ammo being used, if it does use ammo, is set to shoot that projectile. (
item.shoot = projectile.type
, whereitem
is an ammo)
- Make sure the weapon is set to shoot that projectile. (
This mod offers an API for other mod creators through Mod.Call. Mod Creators can bypass the filters to outright allow a projectile to be duplicated no matter the circumstance. Mod Creators can also ban the projectiles from being duplicated by the Options even if they pass the filters. Read on to find out more about this mod's API.
For information about how to use Mod.Call
, refer to the tModLoader guide.
Before one can interact with this mod's API, it is mandatory that they understand what an Option Rule List is. What is an Option Rule List?
An Option Rule List is a set of records where it stores weapon ID and projectile ID to determine bypasses for them, allowing them to ignore the standard filters as displayed in Option Compatibility section. However, items marked with (*) will always be checked as a filter for all rules. Strictly speaking, the Option Rules are for determining if a projectile can be duplicated by the Options without being anchored by the defined regular filters.
An Option Rule contained in the list may have two modes: Allow
and Ban
.
-
Allow
is a mode that will bypass the standard filters and allow the options duplicate projectiles. A projectile will still be allowed to be duplicated even though there is aBan
rule present. -
Ban
is a mode that will never undergo filters and the Options will automatically ignore projectiles in this rule.
There exists Option Rule Types which is the bone of this mod's API. They are the actual rules present in the mod. These are used by Option Rules to determine what kind of rule it should apply for Option Duplication of projectiles.
The Weapon rule type decides whether if the weapon is able to generate duplicated projectiles from the Options. This rule will apply when a player uses the weapon in the rule list.
For example, if one adds Wooden Bow as a banned weapon rule, then the Options will never duplicate projectiles that is fired from the Wooden Bow. However, if one adds Celebration as an allowed weapon rule, then the Options will duplicate all the projectiles Celebration produces.
-
How to add a weapon rule:
-
Invoke #1:
mod.Call("AddWeaponRule", mode, ItemID.IronBow);
- Use this for adding a vanilla weapon, or a modded weapon if the ID is available.
-
args[0]
:"AddWeaponRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Weapon item type inint
-
Invoke #2:
mod.Call("AddWeaponRule", mode, "ChensGradiusMod", "MyCustomWeapon");
- Use this for adding a modded weapon in the rule list if the ID is not available.
- Make sure to use internal names and not the display names.
-
args[0]
:"AddWeaponRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Your mod's Internal Name instring
-
args[3]
: Weapon Internal Name instring
-
Invoke #1:
-
Where to put: In a Mod's
Load()
override, or anywhere if weapon/projectile addition is dynamic and projectile integer types are known. -
Returns:
True
(Rule was added) orFalse
(Rule already existing)
The Projectile rule type decides whether if the projectile can be duplicated by the Options. This rule will apply when a player uses a weapon that generates the projectile that is in the rule list.
For example, if one adds a Wooden Arrow as a banned projectile rule, then the Options will never duplicate Wooden Arrows. If one adds Fallen Star as an allowed weapon rule, then the Options will always duplicate Fallen Stars as long as the player generated it through a weapon.
-
How to add a projectile rule:
-
Invoke #1:
mod.Call("AddProjectileRule", mode, ProjectileID.FireArrow);
- Use this for adding a vanilla projectile, or a modded projectile if the ID is available.
-
args[0]
:"AddProjectileRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Projectile type inint
-
Invoke #2:
mod.Call("AddProjectileRule", mode, "ChensGradiusMod", "MyCustomBullet");
- Use this for adding a modded projectile in the rule list if the ID is not available.
- Make sure to use internal names and not the display names.
-
args[0]
:"AddProjectileRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Your mod's Internal Name instring
-
args[3]
: Projectile Internal Name instring
-
Invoke #1:
-
Where to put: In a Mod's
Load()
override, or anywhere if weapon/projectile addition is dynamic and projectile integer types are known. -
Returns:
True
(Rule was added) orFalse
(Rule already existing)
The Weapon-Projectile Pair rule type decides is a combination of Weapon Rule type and Projectile Rule type. This rule type decides whether if a specific projectile that is fired by a specific weapon can be duplicated by the Options.
For example, if one adds a Wooden Bow and a Wooden Arrow as a banned weapon-projectile pair rule, then the Options will not duplicate Wooden Arrows that is fired by a Wooden Bow. Wooden Arrows fired by a Lead Bow will still be duplicated. Fire Arrows fired by a Wooden Bow will still also be duplicated.
If one adds a Blowgun and a Seed as an allowed weapon-projectile pair rule, then the Options will always duplicate Seed projectiles coming from a Blowgun. Blowpipe will undergo regular filters when firing Seeds.
-
How to add a weapon-projectile pair rule:
-
Invoke #1:
mod.Call("AddWeaponProjectilePairRule", mode, ItemID.StarCannon, ProjectileID.FallenStar);
- Use this for adding a vanilla weapon and projectile.
-
args[0]
:"AddWeaponProjectilePairRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Weapon item type inint
-
args[3]
: Projectile type inint
-
Invoke #2:
mod.Call("AddWeaponProjectilePairRule", mode, "ChensGradiusMod", "Weap", "Proj");
- Use this for adding a modded projectile in the rule list.
- Make sure to use internal names and not the display names.
-
args[0]
:"AddWeaponProjectilePairRule"
-
args[1]
:"Allow"
or"Ban"
-
args[2]
: Your mod's Internal Name instring
-
args[3]
: Weapon Internal Name instring
-
args[4]
: Projectile Internal Name instring
-
Invoke #1:
-
Where to put: In a Mod's
Load()
override, or anywhere if weapon/projectile addition is dynamic and projectile integer types are known. -
Returns:
True
(Rule was added) orFalse
(Rule already existing)
A unique type of rule that serves as support for mods with custom damage types. This function will add one's mod's custom damage type so that the Options may copy those projectiles as well. Please do note that the Custom Damage Rule still falls in the filters listed above in Options Compatibility section.
- How to add a custom damage rule:
-
Invoke #1:
mod.Call("AddCustomDamage", "CalamityMod", "CalamityGlobalProjectile", "rogue");
- Use this if your projectile's custom damage type is in GlobalProjectile.
-
args[0]
:"AddCustomDamage"
-
args[1]
: Your mod's Internal Name instring
-
args[2]
: Your global projectile's Internal Name instring
-
args[3]
: Your boolean variable name which determines the custom damage type instring
-
Invoke #2:
mod.Call("AddCustomDamage", "ChensGradiusMod", "laser");
- Use this if your projectile's custom damage type is in ModProjectile.
-
args[0]
:"AddCustomDamage"
-
args[1]
: Your mod's Internal Name instring
-
args[2]
: Your boolean variable name which determines the custom damage type instring
-
Where to put: In your Mod's
Load()
override. -
Returns:
True
(Custom Damage added for support) orFalse
(Custom Damage is already supported)
This is the end of the page. Back to the top.
Table of Contents