Invisible, Inc.

Invisible, Inc.

Function Library
 This topic has been pinned, so it's probably important
wodzu_93  [developer] 27 May, 2019 @ 8:13am
Documentation for Modders
+ Melee weapons can generate PWR when used.
PWRbonus (integer)[item trait] - PWR generated when used


+ Melee weapons can tag target when used.
tagsTarget = true [item trait]


+ Armor ignore for melee weapons.
ignoreArmor = true [item trait]


+ EMP damage type for ranged weapons
canEmp = true [item trait]
modeEmpdamage (positive integer)[item trait] - EMP duration
baseDamage = 0 - damage must be set to 0 to not kill a target. [item trait]


+ Noisy weapons
soundRange (positive integer)[item trait] - circular sound radius, in tiles


+ Ranged weapon KO damage increase based on distance threshold
proxyRange (integer)[item trait] - Range threshold.
Positive value applies bonus when range is at or higher than specified.
Negative value applies bonus when range is at or lower than specified.
proxyKObonus (positive integer)[item trait] - KO damage increase


+ Buster Chips can generate PWR when used.
icebreakPWR (positive integer)[item trait] - PWR generated on use.


+ Buster Chips can fortify devices to prevent recapture.
icebreakFortify = true (boolean)[item trait]


+ Added Age of Lever status condition requirement for installing augments and using Accelerator\Econ Chips.
LEVERinstallRequirement (string)[item trait] - values: "HARMLESS", "TRUSTED", "LEGIT"


+ Paralyzers can reduce vision range of the target.
impare_sight (positive integer)[item trait] - range to reduce vision by. Affects both main and peripheral.
Lower limit of 4 and 5 range for main and peripheral vision respectively.


+ Paralyzers can remove target's ability to hear.
impare_hearing = true [item trait]


+ Paralyzers can reduce max AP of a target.
impare_AP (positive integer)[item trait] - max AP reduction. Lower limit of 4.


+ Paralyzers can increase their effectiveness VS targets KOed with ranged weapons.
koTimeDart (positive integer)[item trait] - extra turns


+ Stims can add attack actions when used.
ap (positive integer)[item trait] - number of attacks added.


+ Items can degrade after X uses.
usesLeft (positive integer) [item trait] - number of uses available

createUpgradeParams = function( self, unit )
return { traits = { usesLeft = unit:getTraits().usesLeft } }
end

Above functionneeds to be added to itemdef to preserve uses across missions


+ Charges and Ammo support for grenades.


+ Charges support for deployable items (like laptops).


+ Items can consume variable amount of ammo.
ammoRequired (positive integer)[item trait] - specifies ammo required per use of the item.


+ Global daemon reverse chance (independent of programs)
globalReverseOdds (positive integer)[pc player trait] - additional reversal chance, where 100 is 100% chance
NOTE: default reversal odds are 10%


+ TRG_DAEMON_INSTALLED and TRG_DAEMON_REVERSE triggers now pass the spawned daemon as evData


+ Block programs from targeting a firewall on a object (Tooltip says 'JAMMED')
iceImmune = true [device trait]



+ Pre-turn-end trigger. Pushed before on-turn-end code for players and units executes.
evType == "TRG_PRE_END_TURN"
evData == <current player>


+ Post-turn-end trigger. Pushed after all on-turn-end code executes.
evType == "TRG_POST_END_TURN"
evData == <current player>


+ Pre-turn-start trigger. Pushed before on-turn-start code for players and units executes.
evType == "TRG_PRE_START_TURN"
evData == <current player>


+ Post-turn-start trigger. Pushed after all on-turn-start code executes.
evType == "TRG_POST_START_TURN"
evData == <current player>


+ Augment installed trigger. Pushed after all code after augment is installed has completed.
evType == "TRG_AUGMENT_INSTALLED"
evData == { unit, userUnit }
unit - augment installed
userUnit - agent installing the augment


+ "EV_WALL_DESTROYED" visual event. Use to remove wall graphics for a wall segment.
sim:dispatchEvent( "EV_WALL_DESTROYED", { cell = X, rCell = Y, dir = Z, rdir = W } )

cell (cell) - tile on one side of the wall
rCell (cell) - tile on the second side of the wall
dir (direction constant) - direction from "cell" towards the wall
rdir (direction constant) - direction for "rCell" towards the wall

Direction constants defined in simdefs.lua


+ "W93_REFRESH_CELLS" visual event. Use to refresh all tiles.
sim:dispatchEvent( "W93_REFRESH_CELLS" )


+ Way to add Age of Lever status removal to custom abilities.
simquery.LEVER_resetStatus( sim, unit, status, reverse, forced )

sim - sim
unit - unit to remove status from
status (string) - what status to remove. Possible values: "HARMLESS", "TRUSTED", "LEGIT", "ANY"
reverse (boolean) - if true, then it will remove all statuses other than one specified.
forced (boolean) - if true, will forcefully remove a status, disregarding all conditions.


+ Way to ignore magnetic reinforcements when calling EMP.
simunit:processEMP( bootTime, noEmpFX, noAttack, ignoreMagRei )

bootTime (integer) - emp duration
noEmpFX (boolean, optional) - if true, skips graphic effects, nil otherwise
noAttack (boolean, optional) - if true, EMP Vulnerable drones don't die from the EMP. Nil otherwise
ignoreMagRei (boolean, optional) - if true, ignores Magnetic Reinforcements, nil otherwise


+ Trait support to ignore Magnetic Reinforcements for following item types: ranged EMP weapons, door traps, EMP Packs.

ignoreMagReinf = true (boolean)[item trait]


+ AP cost for attacking
mpAttackRestrict (positive integer) [agent trait]


+ Expanded actionAP agent trait, used by On-File Nika by default.
- if value of variable is a number, attack will add that value as AP. Stock functionality.
- if value is a table, attacking will apply all effects inside. Possibilities:
* {"mp", X} - adds X AP.
* {"ap", X} - adds X attacks.
* {"genericPiercing", X} - adds X universal armor piercing for 1 turn.
* {"meleeDamage", X} - adds X permanent melee KO damage.
* {"tempMeleeBoost", X} - adds X melee KO damage for 1 turn.
* {"mpAttackRestrict", X} - adds X AP cost to attacking.
* {"unlimitedAttacks", true} - grants unlimited attacks for 1 turn.


+ Dynamic firewall strength tooltip
- TIPDESC for programs now gets {2} argument ("break_firewalls" variable)
- if program has "custom_firewall_break = true" variable set, you can pass custom firewall break value to the tooltip by defining "getFirewallBreak = function( self, sim, player, targetUnit)" function in the program definition that returns an integer.


+ function weighted_list:removeByItem( item )
Removes an item from weighted list by item ID (string).

+ Shop sell limits
Shops can exclude items from being sold if agency already has enough gear of specified type. To add a limit, define item types like below:

simdefs.AGENCY_ITEM_LIMITS = {
disruptor = 4,
emp_pack = 2,
stim = 2,
}

Types are completely arbitrary, any string will do.

Then add desired type to the item via a trait:

teamLimitCategory = "disruptor"

+ Custom Render Filters
A render Filter can be applied to a unit by using customRenderFilter trait. Trait value must match structure of filters defined in cdefs.RENDER_FILTERS

+ simquery.rasterOrthogonalCross( sim, xOrigin, yOrigin, rangeMin, rangeMax, width )
simquery.fillOrthogonalCross( sim, xOrigin, yOrigin, rangeMin, rangeMax, width )
Functions return a table of cells in a + pattern. "Raster" function returns only XY coordinates (format: { X1, Y1, X2, Y2, X3, Y3, ...}), while "Fill" returns entire cells.
Can also be used to return a square of cells. In that case, width parameter must be 1 higher than rangeMax parameter.


+ simquery.rasterDiagonalCross( sim, xOrigin, yOrigin, rangeMin, rangeMax, width )
simquery.fillDiagonalCross( sim, xOrigin, yOrigin, rangeMin, rangeMax, width )
Functions return a table of cells in a X pattern. "Raster" function returns only XY coordinates (format: { X1, Y1, X2, Y2, X3, Y3, ...}), while "Fill" returns entire cells.


+ targeting.customAreaTarget( game, sim, params, player )
Allows to specify more parameters than default circle.
params must be a table as follows: { shape, rangeMin, rangeMax, width }
shape[/] is a string with 3 valid values: "O", "+" and "X" These correspond to simquery functions to return those patterns of cells.
If player[/] is not nil, cannot target undiscovered or off-map cells.
Last edited by wodzu_93; 22 Aug, 2023 @ 1:15pm