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

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

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