Avoiding cutscene trouble
Making mods with FFX can be nasty: you start off a mission with 'hero_1','hero_2','hero_3' and 'hero_4' on your squad. By the end of your mission 'hero_3' is gone and been replaced by some wierdo called 'form_5'. Why? Because he's a SHAPESHIFTER or a MIMIC!
This means all those hard-worked cutscenes will crash if you try to get hero_3 to speak, or move or do anything really. It can also disrupt all that cinematic goodness if he's MIMIC'd Mr. Mechanical and hasn't turned back to normal!
FFX now records who the original heroes were at the start of each mission automatically. At the start of any cutscene which happens after some action, i.e. not the base ones or the intro to a a mission, you can turn everyone back to normal by adding the line:
"regTimer('restoreHeroes',0.1)",
at the beginning of your cutscene. This will cause all heroes to turn back to their original names and forms within the next 2 seconds, so its your responsibility to make sure you DON'T reference anyone who might be a shapechanger (e.g. a custom character or a buil-in who's optional) until the 2 second wait is over.
Note that this may have gameplay ramifications. Say you've got a quick little cutscene that occurs mid-mission around 'hero_1' who is definitely not a shapeshifter, after this the fighting goes on as normal. If there's no need to reference the other heroes in this scene, then don't restoreHeroes(), as someone might have just MIMIC'd into a particularly juicy form and not want to change back to their weak normal self at this point.
If you're allowing custom characters, make sure you test the mission with a shapeshifter or mimic.
You can retrieve the list of hero templates who started the mission by calling:
originalHeroes()
at any time. This one's useful for the ending of missions to dish out custom bonuses, or for missions where characters have been dynamically destroyed due to teelporting out etc.
To use this sytem you need to keep a list of built-in heroes so the FFX system can index them: change
builtinHeroes=()
to
builtinHeroes=('devil_doll','kingzero','adamzorn','anemone','law','order','thespider','chaosgirl','jimmy_jupiter','aceofswords','miss_amazing','jackied','drummond','echo','aquilus','tart_hero','hunk_hero','penny','fly5000','spidr','dd_tulpa','anemone_tulpa','biffbateman')
ie a full list of ANY hero class characters who could be present. If a hero spawns mid-mission, and you want them in the originalHeroes() list, call:
addExtraHeroToList(template)
Finally, a function has been added to cshleper called FFX_Animate. This functions the same as AI_Animate but checks for the characters existence first. This allows you to safely animate a character who may NOT be there.