Jump to content

Issues with ADD_ITEM_EFFECT


Skye

Recommended Posts

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? :huh: Edited by Skye
Link to comment

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.

Link to comment

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.

Link to comment

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 by subtledoctor
Link to comment

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 by Skye
Link to comment

 

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.

Link to comment

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.

Link to comment

thread_necro.gif

 

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?

Link to comment

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 by subtledoctor
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...