Skip to content

Add script to an item? Proficiencies and Polymorph.

DaturaDatura Member Posts: 12
edited November 2018 in General Modding
I need your help!

I've spent hours in Near Infinity, on https://gibberlings3.github.io/iesdp/main.htm and on the various guides listed on shsforums.net/topic/36781-comprehensive-ie-modding-tutorial-index/, but I can't seem to figure this out: is it possible to add a script I created to an item, as you would do with magic effects (e.g. AC bonus (0), Set color (7), Haste (16),...) ?
All I got for my troubles is a wicked headache and a lack of sleep :smiley:

The only effect I found that seems to be somewhat related to scripts is Modify script state (282) but I have no idea what the hell it does, the description on IESDP doesn't explain what the "Scripting state" is and I have found nothing about it in the guides on SHS :'(

Does this require some clever trick ? Is this even possible ?

Please, oh wise ones, release me from my torment!
Post edited by Datura on

Comments

  • The user and all related content has been deleted.
  • DaturaDatura Member Posts: 12
    edited November 2018

    It's not directly possible, no. Items don't have scripts, so I'm not actually sure what you mean by "add a script to an item." If you mean run a script (once) on a person who equips the item, then that can be done.

    @subtledoctor Thanks for your reply!

    Indeed, that is more or less what I'm trying to do, let me explain:

    I want to negate the bonus that the Single-Weapon Style proficiency gives to the "natural" weapons you get when polymorphed.

    For example, when transformed into a black bear, you get a temporary weapon "PLYBEAR2.ITM" representing the bear's paws to which the aforementioned proficiency fully applies, which doesn't make a lot of sense to me...
    I can see your proficiencies being applied to a Flind's halberd or an Ogre's morning star, but to a paw? That's just silly :p

    Anyway, I tried changing the weapon's item category from Hand-to-hand weapons (28) to something else like Miscellaneous (0) or Teeth (76), but that doesn't prevent the proficiency bonus being applied.
    I also tried adding a Modify proficiencies (233) effect to reduce PROFICIENCYSINGLEWEAPON - 113 when worn, but trying to Increment (1) by a negative number of stars isn't allowed by Near Infinity.

    So... I wrote a script that checks whether or not you have one of these "natural" weapons equipped and, if so, sets your PROFICIENCYSINGLEWEAPON to 0 for the duration of the spell.
    My hope was to be able to attach this script to the "natural" weapons in question so that it runs when you polymorph and equip these... that's the idea anyway !

    Maybe I'm stupid though, and there's a much simpler way to achieve my goal?

    Thanks for any help you can provide ! ;)
  • The user and all related content has been deleted.
  • DaturaDatura Member Posts: 12
    @subtledoctor Thank you very much for your detailed explanation!
    I guess my penultimate sentence turned out to be true: I was unnecessarily overcomplicating things :D

    I'm pretty new to IE modding, so I don't (yet) have a good grasp of its capabilities, especially when it comes to Weidu... I'm used to the Elder Scrolls or KotOR (amongst others) way of doing things—i.e., overwriting a file instead of patching it, and lots of scripting.

    Guess I'll go check those Weidu tutorials for a couple (dozen) hours :tongue:
  • kjeronkjeron Member Posts: 2,367
    IIRC one of the item flags (in the same field as "Two-handed") will disable single-weapon style from being applied to the item. I don't remember which or have access to look atm though.
  • DaturaDatura Member Posts: 12
    kjeron said:

    IIRC one of the item flags (in the same field as "Two-handed") will disable single-weapon style from being applied to the item. I don't remember which or have access to look atm though.

    @kjeron I initially thought that EE: Fake two-handed(12) would do the trick nicely... but as per IESDP it just forces two-handed animations and doesn't affect proficiencies.

    Anyway, I just tried all 31 flags (even the Unknown ones) and I couldn't find it, so I guess I'll have to do as @subtledoctor pointed out.

    But if you eventually remember or manage to take a look, please keep me posted ;)
  • kjeronkjeron Member Posts: 2,367
    No, you're correct, it is just the animation - there is one to force two-handed animation, and another that can sometimes force dual-wield animation.
  • DaturaDatura Member Posts: 12
    edited November 2018
    Ok, it seems the target="_blank" attribute doesn't work on links here, so please open each screenshot in a new tab manually T_T.

    @subtledoctor
    I'm nearly there !

    - The EFF files each correctly reduce the proficiency by the specified amount when added to the weapon.
    I added each file as its own parent (see screenshot).


    - I modified SPLPROT.2DA so that I now have two new entries (again, see screenshot).



    However, I'm puzzled by opcode 318. The entry in IESDP states:

    #318 (0x13E) Protection: from Spell
    Parameter #1: Value
    Parameter #2: Stat Type
    Description:
    The creature type specified by the 'Type' field becomes immune to the spell or item specified in the 'Resource' field.


    So I figured out that Parameter #2: Stat Type must be set to my corresponding entries in SPLPROT.2DA (in my case 144 for -1 prof and 145 for -2 prof) and the "Resource" field must point to my .EFF files (DECSWS1.EFF for -1 & DECSWS2.EFF for -2).
    (On a side note: does Parameter #1: Value do anything?)

    BUT my .EFF files don't appear in the list of selectable resources for opcode 318 (see screenshot).


    Even when I force the Resource via the correct offset, it defaults to DECSWS1.ITM, not .SPL (another screenshot).


    I still tested it ingame, but the "finished" weapon sets my SWS proficiency to 7 with one pip and to 0 with two pips, so there's clearly something wrong with my opcode 318 implementation :anguished:

    Any suggestions?
  • kjeronkjeron Member Posts: 2,367
    Datura said:


    BUT my .EFF files don't appear in the list of selectable resources for opcode 318 (see screenshot).
    Any suggestions?

    Right-Click the field -> Edit as String -> Type in Manually
  • The user and all related content has been deleted.
  • DaturaDatura Member Posts: 12
    kjeron said:

    Datura said:


    BUT my .EFF files don't appear in the list of selectable resources for opcode 318 (see screenshot).
    Any suggestions?

    Right-Click the field -> Edit as String -> Type in Manually
    Ooooh didn't think of that! I forced the whole thing in hex :D

    Also, set the "resource type" in the two .EFF files to "spell" in the field at 0x90.

    Also, you can check the "show hex offsets" option in NI so that you can see the offsets without having to use the "raw" tab. (Raw hex editing gives me the willies.)

    Finally, the opcode 318 effects must occur before the 177 effects on the item. I think the only way to reorder effects in NI is to 'cut' all the effects above the 318 ones and then 'paste' them back below.

    I'll change the resource type as suggested, right now it is set to "none".

    I already have activated the option to show hex offsets don't worry :tongue:
    I use the raw view when checking IESDP for reference, I don't know why but it makes it easier for me to see that the offsets sizes are correct.

    I have the opcodes 318 below the 177 ones... guess that explains it :disappointed:

    I'll try again tomorrow, as it is currently 1 h 30 AM in Belgium and I must wake up pretty early.

    A lot of thanks to you both for your help, it is greatly appreciated!
  • DaturaDatura Member Posts: 12
    edited November 2018
    @subtledoctor
    Following your advice, I changed the resource type of the two .EFF to "Spell", then placed the two 318 opcodes before the two 177 opcodes and... it kind of worked.

    Meaning it worked when the character had 1 or 0 pips in SWS, but didn't when it had 2 pips, where it merely reduced it by 1.

    Yeah, I don't get it either. The logic is sound, it should go like this:
    # of pips in SWS =!2 ->Prot. from DECSWS2 =!1 ->Prot. from DECSWS1 Resulting proficiency
    2NOYES0
    1YESNO0
    0YESYES0
    But it doesn't for some reason, and I can't figure out why. I tried switching the order of the opcodes 318 and 177 around (still keeping the 318 before the 177, mind you), but it always failed when SWS proficiency=2.

    SO I changed my entries in SPLPROT.2DA to check for PROFICIENCYSINGLEWEAPON < 2 and PROFICIENCYSINGLEWEAPON < 1 instead, meaning the following would occur:

    IF PROFICIENCYSINGLEWEAPON < 2 (=>1 or 0)
    ->Protection from DECSWS2

    IF PROFICIENCYSINGLEWEAPON < 1 (=>0)
    ->Protection from DECSWS1

    At first glance, the problem here would be when your proficiency equals 2 you would get hit by both .EFF files, reducing your proficiency by 3... but it doesn't happen in-game as far as I can tell: when you have 2 pips in SWS, it gets reduced to 0 and no further:sweat_smile:

    Huzzah ! It works now (kind of) !

    Seriously though, it does what I wanted it to do, but I have no idea why your implementation doesn't work with 2 pips in SWS proficiency ?!
    Logic dictates it should work just fine, but it doesn't... whereas my method shouldn't work with 2 pips in SWS, but it does ?!

    I feel like crying :cry:
  • kjeronkjeron Member Posts: 2,367
    edited November 2018
    Each opcode (and their parameter2 modes) has a priority order relative to each other, that can supersede the order they are listed in a spell/item. The splprot opcodes (318/324/326) are notable examples, as they can evaluate their trigger before certain other opcodes are processed, regardless of effect order.

    The "Set if Higher" mode of opcode 233 has the same priority as the splprot opcodes trigger, while the "Increment" mode has a lower priority.

    If a character has 0 in SWS, within the same spell/item effect list:
    Opcode 233: SWS prof : Set if Higher : 4
    Opcode 318: SWS prof > 0 = true
    
    Opcode 233: SWS prof : Increment : 4
    Opcode 318: SWS prof > 0 = false
    Any checks occurring in the next "tick" of game time would return true, just not those ocurring in the same tick in which it is applied.

    Similar effects can be seen with opcodes that alter saving throws, for which a new parameter2 mode was added specifically to process before the effects following it, so the modifier could affect any saves following it in the spell.
    Opcode 37: P1=(-20), P2=0 : (-20 save vs spell)
    Opcode 12(damage), Save vs Spell to negate, will ignore the above modifier
    Opcode 37: P1=(-20), P2=3 : (-20 save vs spell, instant)
    Opcode 12(damage), Save vs Spell to negate, will include the above modifier
  • DaturaDatura Member Posts: 12
    edited November 2018
    @kjeron
    Thank you for your explanation, but I'm not sure I understand.
    I thought it worked like this:

    2 pips:
    !=2 ? => NO => no protection from DECSWS2
    !=1 ? => YES => protection from DECSWS1
    => Apply DECSWS2 => resulting proficiency = 2-2 = 0

    1 pip:
    !=2 ? => YES => protection from DECSWS2
    !=1 ? => NO => no protection from DECSWS1
    => Apply DECSWS1 => resulting proficiency = 1-1 = 0

    0 pip:
    !=2 ? => YES => protection from DECSWS2
    !=1 ? => YES => protection from DECSWS1
    => Apply nothing => resulting proficiency = 0-0 = 0

    You said that the "Increment" mode of opcode 233 has a lower priority than opcode 318, which would suggest that the game should check both opcodes 318 THEN lower the proficiency via opcode 233, shouldn't it?

    However, "2 pips" seems to get affected by DECSWS1 regardless.
    Does that mean the opcode 318 somehow "interrupts" the full application of opcode 233 ?

    I probably don't understand it correctly :disappointed:

    Sorry to be such a noob, but it bothers me to no end.
    Post edited by Datura on
  • kjeronkjeron Member Posts: 2,367
    I can only guess which bug is influencing it without seeing the actual files, it's not the only bug possible involving proficiency values. As long as you've found a method that works I wouldn't worry about though.
  • DaturaDatura Member Posts: 12
    kjeron said:

    I can only guess which bug is influencing it without seeing the actual files, it's not the only bug possible involving proficiency values. As long as you've found a method that works I wouldn't worry about though.

    Yeah, I know I'm nitpicking, it just bothers me not to understand why it doesn't work as it should :tongue:

    Anyways, since I seem to have found a working solution, I'll now try to understand how to patch all "paw weapons" using WeiDU.

    I have the following documentation: WeiDU readme, SHS's IE modding tutorial index, and @subtledoctor's How to do stuff in WeiDU.

    Anything else I should be aware of ?
Sign In or Register to comment.