Skye Posted October 13, 2018 Share Posted October 13, 2018 (edited) I've decided to try adding some new abilities to items via scripting. So, to test that out, I've created a patch block that adds a new item ability (since there's no inbuilt function) and then tried calling ADD_ITEM_EFFECT to add an effect to that ability. Although the ability was added without any problems, the ADD_ITEM_EFFECT function seems to have had no effect whatsoever. There's no new effect blocks appended to the file, there's no overwritten blocks, nothing. No errors in the debug file either. I tried running only the ADD_ITEM_EFFECT function and append it to an existing ability and it makes no difference. I don't really mind creating the effect block from scratch, it just seems like a waste of effort if there's already a patch function for it. Here's the code: LAUNCH_PATCH_FUNCTION ADD_ITEM_EFFECT INT_VAR opcode = 0x39 target = 0x01 timing = 0x01 type = 0x00 power = 0x02 header = 0x01 STR_VAR resource = ~SPWI203~ END Any ideas? Edited October 13, 2018 by Skye Quote Link to comment
Gwendolyne Posted October 13, 2018 Share Posted October 13, 2018 Type = 0 ? Item abilities are usually set to 3. 0 = None 1 = Melee 2 = Projectile 3 = Magic 4 = Launcher Quote Link to comment
Skye Posted October 13, 2018 Author Share Posted October 13, 2018 Ugh, I thought type was the resist/dispel type, not the header type that you wanna add the effect to. I completely missed it. Now I just gotta fix the insert_point and I'm golden. Thanks, you probably saved me a couple of hours. Quote Link to comment
Skye Posted October 13, 2018 Author Share Posted October 13, 2018 Hrm, alright, new problem. The effect is added to the file and the index where it's supposed to be is added to my new ability, but the effect is inserted at the base effects offset, rather than appended at the end, which completely messes up the effect indices. It seems to be an issue with me manually inserting the new ability prior to calling the patch function. I've correctly updated the effects offset and number of ability blocks in the item metadata prior to calling the function, so I don't see what could be causing the problem. Quote Link to comment
Jarno Mikkola Posted October 13, 2018 Share Posted October 13, 2018 (edited) Your definitions come from Near Infinity ?New abilities are... edited in weidu via the ALTER_ITEM_HEADER function. As you are adding a different extended header into the item, rather than just one effect. Edited October 13, 2018 by Jarno Mikkola Quote Link to comment
Skye Posted October 13, 2018 Author Share Posted October 13, 2018 But that's an equipping effect (i.e. global effect). I'm trying to add a new extended effect to my item's new ability, it's got nothing to do with equipping effects. I guess I'll check the source code. Quote Link to comment
subtledoctor Posted October 13, 2018 Share Posted October 13, 2018 (edited) Sigh. Don't mind Jarno. Equipping effects can be added via ADD_ITEM_EQEFFECT. Regular effects can be added as above. Just set "insert_point = 99" and it should be the last effect added to its header. It also could be something weong with the way you created the new header. I think there's a pretty thoroughly-vetted ADD_ITEM_HEADER macro out there (maybe written by Ardanis?), which hasn't yet made it into Weidu proper. Check the "useful macros" thread in the modding how-to forums, or just google it. Edited October 13, 2018 by subtledoctor Quote Link to comment
Jarno Mikkola Posted October 13, 2018 Share Posted October 13, 2018 Edited the above message ... there's no need for ADD_ITEM_HEADER as there already is ALTER_ITEM_HEADER. Quote Link to comment
Skye Posted October 13, 2018 Author Share Posted October 13, 2018 (edited) Ability header is fine, so is all the metadata. I went through it byte by byte. The problem seems to be with the way the macro determines the offset of the new effect. It works fine if the ability already has a pre-defined effect index, as an existing ability would have, but for a new ability, you need to set the effect index to the next available number. I was hoping I might be able to avoid these calculations but meh... Edit: It was actually more painless than I expected it would be. A simple equation to get the current number of effects and it worked like a charm. index = (SOURCE_SIZE - effects_offset) / effect_length ... WRITE_SHORT offset+0x20 index // first effect index Thanks for the help, guys. Gonna go tackle other issues now. Edited October 13, 2018 by Skye Quote Link to comment
Wisp Posted October 13, 2018 Share Posted October 13, 2018 Just set "insert_point = 99" and it should be the last effect added to its header.Setting the value to less than 0 is the issue-free way of doing it. Quote Link to comment
CamDawg Posted October 13, 2018 Share Posted October 13, 2018 Just set "insert_point = 99" and it should be the last effect added to its header.Setting the value to less than 0 is the issue-free way of doing it. Per the docs it's supposed to be last by default--you should be able to omit insert_point outright. Quote Link to comment
Jarno Mikkola Posted October 13, 2018 Share Posted October 13, 2018 Erhm, what exactly are you Skye trying to do with the above thing ? Cause if this in EE games, the opcode 0x39 is this, which is opcode #57 by the by, which doesn't have a resource name in the needed variables ... you would probably want to use the opcode #177 to apply effect to a specified creature type. Quote Link to comment
Daulmakan Posted June 15, 2022 Share Posted June 15, 2022 Sorry for the thread necromancing. I've basically the same issue as Skye did. Just wondering how to solve it. I'm using Miloch's Macro to add an extended header to an item that doesn't have it, which works, but using ADD_ITEM_EFFECT macros immediately after it don't work (ie. no effects are added to the new header), as Skye said. Here's what I have: COPY_EXISTING ~xacliver.itm~ ~override~ LPF add_spl_itm_header INT_VAR t-atk_type = 3 t-use_loc = 3 t-hdr_targ = 5 t-range = 1 t-speed = 0 t-charges = 1 t-deplete = 1 t-opcode = 54 t-eff_targ = 1 t-param1 = 0 t-param2 = 1 t-timing = 9 t-dispel = 0 t-prob1 = 100 STR_VAR t-bam = ~II342~ END LPF ADD_ITEM_EFFECT INT_VAR opcode = 54 target = 1 parameter1 = 1 parameter2 = 0 timing = 9 END LPF ADD_ITEM_EFFECT INT_VAR opcode = 12 target = 1 parameter1 = 1 parameter2 = 0 timing = 9 END LPF ADD_ITEM_EFFECT INT_VAR opcode = 9 target = 1 parameter1 = 12288 parameter2 = 19660805 duration = 2 timing = 3 END LPF ADD_ITEM_EFFECT INT_VAR opcode = 187 target = 1 duration = 3 timing = 4 STR_VAR resource = ITEMSPLL END BUT_ONLY What am I missing/screwing up? Quote Link to comment
DavidW Posted June 15, 2022 Share Posted June 15, 2022 One thought: ADD_ITEM_EFFECT by default only adds to header type 3 (magic). Any chance your item doesn't use that header type? Quote Link to comment
subtledoctor Posted June 15, 2022 Share Posted June 15, 2022 (edited) I don’t know that function but it looks like “t-atk_type = 3” is the header type. I vaguely recall having similar(ish) problems when CREATE’ing a spell from scratch, and using Ardanis’ ADD_SPELL_HEADER function, and then adding effects with ADD_SPELL_EFFECT. Something about the header or extended header index not being updated ahead of the new effects being inserted. The gist of it was, doing it all within a single COPY command led to problems. Try adding the header and then stopping; and then COPYing the item again and adding the new effects. EDIT - actually no, I think the problem there was trying to run the ADD_HEADER function within the CREATE command. Edited June 15, 2022 by subtledoctor Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.