🌱
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
  • Layout
  • Usage
  • Expansion
  • Notes
  1. Overview
  2. Configuration

Assemblies

Description

Assemblies are strings with a block of assembly code that can call in-game functions and more. Once it's assembled, the required memory is allocated and its symbols are registered.

Every assembly is defined in a separate file, has a unique name, and is located in the assemblies directory.

The assemblies.lua file contains a list of all assemblies and in which order they will be loaded (higher first). The latter is important in cases where one requires another.

Layout

assemblies/getRandomNumber.lua
local assembly =
[[
tif_grn_call:
  ...
  call 0x00379CD0
  ...

  .align 0x08
tif_grn_args:
  .dd 0x00
]]

local symbols = {
"tif_grn_call",
"tif_grn_args"}

return assembly, symbols
assemblies.lua
local assemblies = {
  --more assemblies
  "getRandomNumber"
}

return assemblies

The former file returns a string with assembly code and a table with its symbols.

The latter file returns a table with every assembly. The value of a table entry equals the filename of the assembly (e.g. getRandomNumber).

Usage

Generally, you will almost always only write code in Lua for your formula functions, helpers, etc. However, there are cases where you might want to use an existing game function instead.

Let's say you wanted to create a formula function that heals all party members and removes any of their negative status effects. To do this, you would have to go through all party members, set their current hp to their max hp (with bubble in mind), check which status effects are considered negative and then remove their state and timer. So it would actually require quite a lot of code.

Now instead of doing all of this manually with Lua, you can also just reuse a game function. To do this, you would of course first have to find out if such a function even exists, at which address it is, what arguments it requires, and so on, but let's assume we already know that as part of this example.

Once you do, you can set up your assembly code:

assemblies/healAll.lua
local assembly =
[[
tif_ha_call:
  sub rsp,0x28

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

  add rsp,0x28
  ret
]]

local symbols = {
"tif_ha_call"}

return assembly, symbols
assemblies.lua
local assemblies = {
  --more assemblies
  "healAll"
}

return assemblies

and then define it as a helper:

helpers/healAll.lua
local function healAll()
  memory.execute("tif_ha_call")
end

return healAll
helpers.lua
local helpers = {
  --more functions
  "healAll"
}

return helpers

and finally call it in a formula function:

functions/...lua
local function func(formula, caster, target, functions, classes, helpers)
  helpers.healAll()
end

return func

This is just a basic example. It will get more advanced if you have to pass arguments to the assembly code or return the result. I recommend looking through already existing assemblies to get an idea on how you can do those.

Expansion

You can modify existing assemblies created by me and add entirely new ones if you want. However, this is more on the advanced side of modding, so unless you really know what you are doing, I would avoid messing with it. The option is just there in case you need it.

Notes

Symbols should be unique as they are registered by the same Lua context. So if you add any new assemblies, you should also use your own prefix for your symbols. Do NOT use the tif_ prefix from this mod as that will result in your code potentially overwriting mine whenever I introduce new assemblies.

PreviousHelpersNextMiddlewares

Last updated 5 months ago