Can I apply a script through a class kit?
paradoxx
Member Posts: 12
Is it somehow possible to apply a script through a class kit added via weido or any other means? Essentially I would like to have a few different scripts permenantly running on a kit I'm trying to make but I can't find a way to make this possible.
0
Comments
And then, if you try this with party members, it all falls apart. NPCs already have override scripts you don't want to replace. The protagonist, or other created characters, usually have a blank spot there, but that's a very limited resource and some things (like the Black Pits adventure) may use it already. The "class" slot belongs to combat scripts, which are set through PARTYAI.2DA or in-game menus; that'll overwrite any replacement you try to make. The "area" and "specifics" slots can't be used for party members at all. The "race" and "general" slots get blanked for party members. Finally, the "default" slot gets set any time someone joins the party.
What about characters that aren't in the party? They don't even run the stuff in the CLAB; they don't get kit benefits unless those are explicitly placed in their CRE files.
So, if you try to set scripts for party members, the game will undo your hard work. You can experiment with stuff (try a script with visually obvious effects), but I don't think it'll work. That leaves adding to a global script - not elegant, but sometimes it needs to be done.
Also you say it's not elegant suggesting it could cause issues, but all the effects I'm intending will be internal to the character with the kit. Are there any problems you forsee?
What do you want to do with these scripts, anyway? There might be other ways of accomplishing things, depending on the answer.
Which global script would you recommend to append to for this purpose?
You don't need a script to restore spells on a timed interval. I did something for an early version of Skills and Abilities where every round it would have a % chance of restoring one used spell for a given spell level. You may be able to tweak something like that and add in more restrictions (i.e. no enemies present).
Basically, quick rundown, is something like this:
This looks like an amazing suggestion but I'm struggling to figure out opcode 326. How would I make it do all the things I can do very simply in a script? I can see there are lots of complicated parameters there but how would I use those to only make SPELL3 be cast out of combat for example and when there is no negative status effect and when the character is idle all at once? Spell restore is a very powerful ability and I only want it to occur under very specific, safe, short rest type circumstances.
There is another issue as well. Spell restore restores the highest level spells first, which trivialises the use of those spells as they will be the easiest to restore. In a script you can specify the ranking of the action responses, ranking low level restores over high level ones to help balance out this issue. I see no mechanism how this could be done with the method you propose.
So in summary while opcode 326 sure looks nifty I have the impression it is cumbersome and restricted compared to the freedom of scripting.
@mjerry can you pinpoint me to a global script I could use in the way you indicated?
So, here's the code for the component I wrote, assigning "Advanced AI" with the same mode choices as the player to Project Image and Simulacrum clones.
And now, the external resources this calls on. First, j8#aivar.2da:
Second, j8#aiopt.baf:
And aioptPatch.baf:
All right, how does this all work? First, I read a table to get the "default" advanced AI. Personalizing that like the game does with the bd*****c combat scripts might be possible, but it's not easy; I went with the universal option instead.
Second, I copy over some resources; a script to be assigned to a creature that changes its "class" script to the default AI, and a spell that assigns this new script to a creature.
Next, I extend that script. For each possible value of a control variable, I add a new block that detects the variable's value for the clone's original and assigns it to the clone.
Then, to get this actually working, I add an effect casting that new spell to PROJIMAG and SIMULACR, spells which are always applied to clones.
And finally, I edit the default AI itself; the standard version only works for party members, so I broaden it to function whenever the user is on the party's team.
What didn't work? Early on, I tried to detect what the player was using and assign that same script, so I could cover the .bs files in the "scripts" folder as well. That failed; I was using the ChangeAIScript script action at the time, and that doesn't allow you to assign a .bs. Also, I initially thought local variables carried over to the clone; they don't, so detecting and copying them by script was the only way.
The method I used for assigning scripts to clones? Create a spell, filter it through an allegiance check, and cast it in PROJIMAG.spl and SIMULACR.spl which are applied to clones on creation. The allegiance check is so that I don't catch clones of enemies or hostile clones of players. Then that script I assign can check stats to find out who the creature is a clone of, check the original's stuff to set local variables, and finally assign the actual combat script to the clone.
No global scripts involved.
You can target a clone from a global script by using its COPY script name, but that'll catch all clones rather than any particular one. Better to piggy-back on the spells which are applied to clones at creation, as script-changing is also available in opcode form.
Then I use a delayed timing mode to have this fire after one second. I was thinking of some SCS fights here, in which clones of the party are created and then made enemies; the delay gives that a chance to work before my spell can assign a script.
Add this new effect to the spells using the ADD_SPELL_EFFECT function, and we're set.