🌱
The Insurgent's Forge
  • Home
  • Getting Started
    • Setup
    • Resources
  • Overview
    • Configuration
      • Formulas
      • Functions
      • Classes
      • Helpers
      • Assemblies
      • Middlewares
      • Dependencies
      • Options
      • Errors
    • Improvements & Additions
    • Structures & Parameters
    • Formula Workflow
      • Combo
      • Counter
      • Area of Effect
      • Reserve Party Member
      • Reflect
      • Mist
      • Trap
      • Chain Benefit
      • Summon
      • Spawn
      • Gambit
    • Limitations
      • Animations
      • Status Effects & Augments
    • Notes
      • Flags
      • Loops
      • Function in a Function
    • Helpers
      • Add Augment
      • Add Status Effect
      • Apply Knockback
      • Get Active Party Member
      • Get Action Status Effects
      • Get Augment Duration
      • Get Battle Unit Keep
      • Get Battle Unit Keep By Focus
      • Get Battle Unit Work
      • Get Character Max Hp
      • Get Character Max Mp
      • Get Character Type
      • Get Elemental Affinities Match
      • Get Equipment Status Effects
      • Get Forced Poach Rarity
      • Get Forced Steal Rarity
      • Get Formula Proc Keep
      • Get Knockback Range
      • Get Location Mist Strength
      • Get Model Evade Types
      • Get One Hit Kill State
      • Get Random Number
      • Get Reflect Target
      • Get Remedy Status Effects
      • Get Status Effect Duration
      • Get Status Effect Tick Duration
      • Get Status Effects Match
      • Get Terrain Type
      • Get Weather
      • Is Interactable
      • Modify Content
      • Modify Gil
      • Modify Hp
      • Modify Mist Charges
      • Modify Mp
      • Modify Sky Pirates Den Stats
      • Refresh Stats
      • Remove Augment
      • Remove Status Effect
      • Set Level
      • Shift Elements
      • Show Combat Log
      • Show Number Text
      • Teleport Location
  • Support & Updates
    • Changelogs
      • Version 1.0.3
      • Version 1.0.2
      • Version 1.0.1
      • Version 1.0.0
    • Known Issues
    • FAQ
Powered by GitBook
On this page
  • Description
  • Usage
  • Notes
  1. Overview
  2. Configuration

Dependencies

Description

Every class and helper has access to the following global variables:

Variable

Functions

A table with all predefined formula functions from the functions directory.

Classes

A table with all predefined functions from the classes directory that build metatables to simulate object oriented programming.

Helpers

A table with all predefined functions from the helpers directory that help reuse a block of code after defining it once.

These can be helpful when one function requires another.

Usage

Let's say you wanted to calculate an action's power based on a randomly selected character stat (e.g. strength or magick power). For that, you could write something like this:

helpers/getRandomStat.lua
local function getRandomStat(character)
  local argBase = memory.getSymbol("tif_grn_args")
  memory.execute("tif_grn_call")
  
  local rndNum = memory.u32[argBase] % 2
  if rndNum == 0 then
    return character.strength
  else
    return character.magickPower
  end
end

return getRandomStat

Now the issue with this one is that you are redefining the getRandomNumber helper which is not really desirable as its rather redundant and also error prone. Instead of doing that, you can directly use the required function by accessing the global variable helpers like this:

helpers/getRandomStat.lua
local function getRandomStat(character)
  local rndNum = helpers.getRandomNumber(2)
  if rndNum == 0 then
    return character.strength
  else
    return character.magickPower
  end
end

return getRandomStat

Keep in mind that if getRandomStat requires getRandomNumber, then the latter must be placed higher than the former in helpers.lua as only then they are loaded in the proper order. The same goes for classes, assemblies, etc.

You can do the same with assemblies and call one with the other by referencing its symbol.

Let's say that every time the party is healed with the healAll function, you also want to refresh their stats. For that, you could do the following:

assemblies/healAll.lua
local assembly =
[[
tif_ha_call:
  push rbx
  sub rsp,0x20

  mov edx,0000000F ;hp, mp, mist, negative status effects
  call 0x0030F4B0 ;healall(unused, flags)

  xor ebx,ebx
tif_ha_loop:
  mov ecx,ebx
  call 0x00320A40 ;getBattleUnitKeep

  lea rdx,[%tif_rs_args%] ;refresh stats args
  mov [rdx],rax
  call %tif_rs_call% ;refresh stats call

  inc ebx
  cmp ebx,0x27
  jna short tif_ha_loop
  
  add rsp,0x20
  pop rbx
  ret
]]
...

Notes

A class, helper or assembly cannot require another which also requires it in return as that would result in a dependency loop.

PreviousMiddlewaresNextOptions

Last updated 5 months ago