News:

Rings of Reznor!

Main Menu

Possible fix for FFX Heal state swap

Started by oktokels, June 10, 2026, 12:25:21 AM

Previous topic - Next topic

oktokels

Hi everyone,  :thumbup:  :thumbup:

I wanted to share a possible fix for a bug I ran into while testing the FFX Heal state swap in FFvTTR / FFX.

The bug

I was testing a custom support power using:

energise -> heal

The intended behavior was a one-time heal. However, in some setups, after using Heal once, the target could appear to keep healing again later, especially after being attacked. This made the power behave more like a persistent healing effect instead of a one-shot health restore.

The FFX documentation describes **Heal** as returning some of the target's health, not as a regeneration state. So I started looking at the `HEALER` section in `ffx.py`.

## Suspected cause

In the original `HEALER` block, several Heal swap functions apply the heal but do not remove the original carrier state first.

For example, the original `energisetoheal()` looks like this:

def energisetoheal(event):
char=event.object
source=event.string
bonus=5*COST_ENERGYSURGE
if bonus>=1:
RegTimer('removeFX',0.5,1,char)
makehealed(char,bonus)

The same pattern appears in `energysurgetoheal()`, `increasetoheal()`, and `buoyancytoheal()`.

That means the carrier state may remain on the target after the heal is triggered. Other FFX swaps usually consume the state first, for example:

Object_SetSecondaryState(char,SCSTATE_ENERGIZED,0,REMOVE_STATE)
FFX_UpdateStates(char)

So I tried making Heal behave the same way: consume the triggering state, update states, then apply the heal.

## Proposed replacement block

This is the replacement I tested for the
################### HEALER ############################
section in `ffx.py`.

Please back up your original `ffx.py` first.

################### HEALER ##########################################

def rallytoheal(event):
char=event.object
source=event.string
bonus=Object_GetAttr(char,'attackBonus')
oldBonus=Object_GetAttr(char,'oldAttackBonus')
if bonus!=oldBonus:
RegTimer('removeFX',0.5,1,char)
bonus=Object_GetAttr(char,'attackBonus')*COST_RALLY
Object_SetAttr(char,'attackBonus',oldBonus)
makehealed(char,bonus)

def buoyancytoheal(event):
char=event.object
source=event.string
if Object_GetSecondaryStates(char)&SCSTATE_BUOYANT:
Object_SetSecondaryState(char,SCSTATE_BUOYANT,0,REMOVE_STATE)
FFX_UpdateStates(char)
bonus=5*COST_BUOYANCY
else:
return
if bonus>=1:
RegTimer('removeFX',0.5,1,char)
makehealed(char,bonus)

def increasetoheal(event):
char=event.object
source=event.string
if Object_GetSecondaryStates(char)&SCSTATE_SPEED_INCREASED:
Object_SetSecondaryState(char,SCSTATE_SPEED_INCREASED,0,REMOVE_STATE)
FFX_UpdateStates(char)
bonus=5*COST_INCREASE
else:
return
if bonus>=1:
RegTimer('removeFX',0.5,1,char)
makehealed(char,bonus)

def energisetoheal(event):
char=event.object
source=event.string
if Object_GetSecondaryStates(char)&SCSTATE_ENERGIZED:
Object_SetSecondaryState(char,SCSTATE_ENERGIZED,0,REMOVE_STATE)
FFX_UpdateStates(char)
bonus=5*COST_ENERGYSURGE
else:
return
if bonus>=1:
RegTimer('removeFX',0.5,1,char)
makehealed(char,bonus)

def energysurgetoheal(event):
char=event.object
source=event.string
if Object_GetSecondaryStates(char)&SCSTATE_AREA_ENERGIZED:
Object_SetSecondaryState(char,SCSTATE_AREA_ENERGIZED,0,REMOVE_STATE)
FFX_UpdateStates(char)
bonus=5*COST_ENERGYSURGE
else:
return
if bonus>=1:
RegTimer('removeFX',0.5,1,char)
makehealed(char,bonus)

def makehealed(target,bonus):
amount=int(bonus*5)
if amount<1:
return
try:
missing=Object_GetAttr(target,'maxHealth')-Object_GetAttr(target,'health')
if missing<1:
return
if amount>missing:
amount=int(missing)
except:
pass
Trigger_Damage(target,-amount)

## What this changes

The main change is that the triggering state is removed before the heal is applied:

Energise      -> removes SCSTATE_ENERGIZED
Energy Surge  -> removes SCSTATE_AREA_ENERGIZED
Increase      -> removes SCSTATE_SPEED_INCREASED
Buoyancy      -> removes SCSTATE_BUOYANT

I also added a small overheal cap in `makehealed()`, so it only heals the amount of HP actually missing. That part is optional, but it prevents unnecessary negative damage from being applied to a fully or almost fully healed target.

## Test result

I tested this with a custom character power using:

["x character", "energise", "heal", "all"]

The power healed **25 HP**, and after further attacks on the target I did not see the previous repeated-healing behavior come back.

## Notes

This has only been tested locally in my current setup. I have not fully stress-tested it in campaign missions, multiplayer, save/load situations, or every possible Heal source.

If anyone else has had trouble with Heal behaving like persistent regeneration, this may be worth testing. I would be interested to know if others can reproduce the original issue and whether this fix solves it in their installations too.