Module twdll.battle

Battle functions and hooks for Total War: Attila.

To use twdll in battles, load it inside battle_scripted.lua:

-- In battle_scripted.lua:
local twdll = package.loadlib("twdll", "luaopen_twdll")()
twdll.battle.EnableSmeHealthBars(true)

Functions

EnableSmeHealthBars ([enabled=true]) Updates health bars on unit cards and 3D banners in real time for 1-man units (SMEs, monsters, single heroes) based on remaining hit points.
GetBattleInfo () Returns live runtime telemetry and reinforcement structure about the current tactical battle.


Functions

EnableSmeHealthBars ([enabled=true])
Updates health bars on unit cards and 3D banners in real time for 1-man units (SMEs, monsters, single heroes) based on remaining hit points.

Parameters:

  • enabled boolean whether to enable (true) or disable (false) (default true)

Returns:

    boolean true on success, false otherwise

Usage:

    -- In battle_scripted.lua:
    local twdll = package.loadlib("twdll", "luaopen_twdll")()
    twdll.battle.EnableSmeHealthBars(true)
GetBattleInfo ()
Returns live runtime telemetry and reinforcement structure about the current tactical battle. Returns nil while no battle is active (e.g. on the campaign map).

When inside a battle, returns a table with fields: - battle (string): hexadecimal memory address of the BATTLE object. - manager (string|nil): hexadecimal memory address of REINFORCEMENTS_MANAGER. - cap (integer|nil): active maximum units per army in battle. - size (integer|nil): number of reinforcing armies currently queued.

Returns:

    table or nil table containing battle state, or nil when not in a tactical battle

Usage:

    -- Example returned table:
    -- {
    --     ["battle"] = "0x2A4F8900",
    --     ["manager"] = "0x2A4F8B40",
    --     ["cap"] = 40,
    --     ["size"] = 2
    -- }
    
    local info = twdll.battle.GetBattleInfo()
    if info then
        if info.size and info.size > 0 then
            -- Reinforcements are queued to enter the battlefield
        end
    end
generated by LDoc 1.5.0