Skip to content

Okay, this is ridiculous

chimericchimeric 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.

Comments

  • AbelAbel Member Posts: 785
    edited July 2016
    I don't have the solution to your problem, but yes it's the kind of trouble you run into when trying to work with this old engine.
    I dabbled with scripts at one point, and the system is a real mess.
  • The user and all related content has been deleted.
  • kjeronkjeron Member Posts: 2,367
    chimeric said:

    He can add to SPLSTATE.IDS, but scripts only read from STATE.IDS.

    STATE.IDS: 0x4037 StateCheck(O:Object*,I:State*State)
    SPLSTATE.IDS: 0x40E2 CheckSpellState(O:Object*,I:State*splstate)
    chimeric said:


    He can set a state through effects, but available states are taken from SPLSTATE.IDS.
    ...
    He finds an unused state in STATE.IDS he could set a creature to - if only effects worked with that file at all.

    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.
    chimeric said:

    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.

    Opcode 72
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    Don't forget extstate.ids
    0x40e1 ExtendedStateCheck(O:Object*,I:State*extstate)

    Coincidentally, those are iwd(ee)'s hardcoded states (mostly).
  • chimericchimeric Member Posts: 1,163
    kjeron said:


    CheckSpellState(O:Object*,I:State*splstate)

    THIS wins the day, @kjeron, and gets you a place in the credits for the spell I'm making. It's exactly what I need. It's not in the Triggers list for BGEE at G3, though. I wonder what else is missing there? Catch-22 is what you get when you can't ask the question you want answered. Now that I can manipulate spell states from effects and check for them from inside scripts, the gap is bridged.
    None of them are unused AFAIK.
    There is a weird one called CD_STATE_NOTVALID...

    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.
  • AstroBryGuyAstroBryGuy Member Posts: 3,437
    chimeric said:

    There is a weird one called CD_STATE_NOTVALID...

    It's a state check for whether or not a character is valid for dialog. The "CD" is @CamDawg's personal prefix.

    http://www.shsforums.net/topic/36779-using-cd-state-notvalid/
  • The user and all related content has been deleted.
  • chimericchimeric Member Posts: 1,163
    Still going with that, aren't you? :lol:
  • The user and all related content has been deleted.
  • chimericchimeric Member Posts: 1,163
    The prefixes thing, I'll never live it down.
  • The user and all related content has been deleted.
  • Avenger_teambgAvenger_teambg Member, Developer Posts: 5,862
    Opcode 72 "does something to the AI".

    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.
  • ArdanisArdanis Member Posts: 1,736
    edited August 2016
    chimeric said:


    He can make a script look into SPECIFIC.IDS or assign to a creature a value from there

    Not really, you might break some scripting if you do that. E.g. most of SoD actors rely on specifics to decide whether they should be assisting player or his enemies, and other allegiance/faction matters. Randomly changing their value will wreck the whole system.
  • chimericchimeric Member Posts: 1,163
    I pieced together a solution in the end. Doing it through SPECIFIC didn't work out for me for some reason, though I didn't try that way twice. I added a custom state to SPLSTATE.IDS (line 248, TAUNTED, please don't take that one), and now it's easy to assign effects to the creatures. By the way, I would appreciate advice on how to handle these differences in IDS entries. Is there any way to make different versions compatible - add entries on top of others or such? Has anyone else added anything to SPLSTATE? If you have, please say what entries those are and I'll change my file accordingly. I want my SPLSTATE.IDS to be broadly compatible when I include it in the mod.

    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?
  • ArdanisArdanis Member Posts: 1,736
    edited August 2016
    Using fixed ID values might be problematic in perspective, since there's no database on who uses what and where.
    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.
  • chimericchimeric Member Posts: 1,163
    A software solution to assigning slots or a way to append with Weidu would be a good thing. Or a central list, not just for SPLSTATE but also for SPECIFIC, PROJECTL and MISSILE.

    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*
  • kjeronkjeron Member Posts: 2,367
    chimeric said:

    A software solution to assigning slots or a way to append with Weidu would be a good thing. Or a central list, not just for SPLSTATE but also for SPECIFIC, PROJECTL and MISSILE.

    A central list will not work for these, they need to be added dynamically, as its not always possible to know how many will be needed ahead of time. For example, just one of my mods adds 45 new entries to Spell State, of which only 9 are predefined in the mod, the rest are created as it finds a spell or item that needs one during the installation.

    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).
Sign In or Register to comment.