Okay, this is ridiculous
chimeric
Member Posts: 1,163
A person is trying to set a creature to a state by a spell so he can later read that state from a script. This needs to be done from a script because that is the only way to manipulate a creature's AI, having it do certain actions, without the creature being left AI-less after the programmed sequence has run through. What does our modder find?
He can set a state through effects, but available states are taken from SPLSTATE.IDS.
He can add to SPLSTATE.IDS, but scripts only read from STATE.IDS.
He finds an unused state in STATE.IDS he could set a creature to - if only effects worked with that file at all.
He can make a script look into SPECIFIC.IDS or assign to a creature a value from there, but no effect sets SPECIFIC.IDS either.
The script world and the effects world are like the two brain hemispheres, separated by a deep gulf. Our modder thinks this is a catch 22.
He can set a state through effects, but available states are taken from SPLSTATE.IDS.
He can add to SPLSTATE.IDS, but scripts only read from STATE.IDS.
He finds an unused state in STATE.IDS he could set a creature to - if only effects worked with that file at all.
He can make a script look into SPECIFIC.IDS or assign to a creature a value from there, but no effect sets SPECIFIC.IDS either.
The script world and the effects world are like the two brain hemispheres, separated by a deep gulf. Our modder thinks this is a catch 22.
0
Comments
I dabbled with scripts at one point, and the system is a real mess.
SPLSTATE.IDS: 0x40E2 CheckSpellState(O:Object*,I:State*splstate) States in STATE.IDS are hard-coded creature states(offset 0x20 of the *.cre file), set through various opcodes, including: 3, 5, 13, 16, 20, 24, 25, 38, 39, 40, 45, 63, 65, 69, 74, 76, 119, 128, 129, 130, 131, 132, 134, 137, & 159. None of them are unused AFAIK. Opcode 72
0x40e1 ExtendedStateCheck(O:Object*,I:State*extstate)
Coincidentally, those are iwd(ee)'s hardcoded states (mostly).
About Opcode 72: I tried that one. It's very complicated, but I don't think it does what I wanted it to do - set the creature to a line in SPECIFIC.IDS. There is a way to do that from a script, but this effect does something to the AI, as the name says.
http://www.shsforums.net/topic/36779-using-cd-state-notvalid/
Well, it changes one of the object identifier fields. They are collectively named 'AIType'. But it is exactly what you asked for. Parameter2 determines which field to alter:
0 EA
1 General
2 Race
3 Class
4 Specific
5 Gender
6 Alignment
You can use it with permanent timing to alter the field permanently, exactly the same effect as the Change* actions.
Anyway, that's how I did it. I can hit the marked creatures with anything I want from a script or an effect now. However, I still can't seem to overcome their AI when it is running. ActionOverride doesn't work on them once they are in combat. They are just too willful. They ignore script commands from another creature. I found a roundabout way to make them attack, but that's all I can command them to do. Maybe I'm doing something wrong with ActionOverride there. It was a regular Attack() assignment, though, and even preceded with ClearAllActions(). The game uses ActionOverride to make NPC do all sorts of things, but not when they are already red and fighting. I suppose I could turn them green first, but would it stop the combat script?
I guess I should lift my lazy ass off the sofa and upload the latest Detectable Spells lib, its code can be used yo assign slots dynamically... Unless I forgot something and WeiDU has an internal function to append IDS dynamically.
As for AI... Considering how random and decentralized its implementation in IE games is, I'm afraid you just can't do anything about that, short of re-designing the entire system For example, SoD uses a more centralized approach to AI implementation, where pretty much all the actors use one script for general behavior and a set of class-specific combat scripts generated from a single source, all full of override checks that enable the control of actors' behavior from external sources. However, there is no standard for the rest of the game (and mods), so there's no hope to control it externally since the scripts don't have any checks built in.
Tl;dr - if you want to use it on your own characters, and only on them, then add a NoAction() blocker section to the top of their custom AI. Check BDSHOUT + BD****01 Siege scripts (where **** is CLER, Figh, MAGE etc.) for examples. If you want to affect any creature, then... better to just forget it. Interfering with existing scripts is not something I would take responsibility to advise.
With AI - I'm thinking of prefacing ActionOverride with SetInterrupt(FALSE). I don't want to mess with people's scripts, hence all this Herculean struggle with marking and creature control. There was a script in Torment, in Litany of Curses, which just swapped targets' AI for a single-minded attack script. They would chase after Morte until mowed down, it was the only thing they could ever do. I didn't want that simple solution. *sigh*
An ADD_SPLSTATE command doesn't exist yet, so I use a homemade function to do it. It's still unknown exactly which numbers above 255 actually work though, and can be misleading since some always return false, some always return true, some only work when check through scripts, and I think some only work when checked through opcodes.
Weidu already has commands to extend PROJECTL.ids and MISSILE.ids (ADD_PROJECTILE - it does both).