Jump to content

apply effect on attack


K4thos

Recommended Posts

I'm looking for a reliable way to apply SPL or EFF effect on Self target only if character attacks (it should be applied even if character missed the attack). I've experimented with following opcodes without success:

- Cast spell on condition (232) -> Target = self, parameter1 = 0 (Caster), parameter2 = When attacked (7)

- Apply effects list (326) - I didn't find any splprot condition that would work for this

- Melee hit effect (248) - this seems to work only when the attack hit the target and I need it to fire also on miss

 

Is it even possible with current EE engine?

 

edit: hmm, even if I scrap the idea to apply effect on miss Melee hit effect opcode (248) seems to be working only on Target that has been hit. Any ideas how to set it up to make it run on the creature from which the spell effect originated? Target = Original caster (9) doesn't seems to be working.

 

edit2: new question: http://gibberlings3.net/forums/index.php?showtopic=29694&do=findComment&comment=263300

Edited by K4thos
Link to comment

thanks, I will test it. One more question:

 

I'd like to implement an item that applies global effect (+1 attack per round) but only if character wearing that item is under specified spell state. The problem is that when I'm trying to use opcode 326 (Apply effects list) as a global item effect the same way as normally opcode 177 is used (Use EFF file) the effects of the applied spell are permanent even though I've set both 326 and the applied spell Timing Mode to 2 (Instant/While equipped). Any ideas how to make it work only when item is eqquipped? I've attached STAF01.ITM with opcode 326 (EA -> ANYONE condition) and the spell in case someone would like to test it in game. Thanks in advance.

test.zip

Edited by K4thos
Link to comment

regarding the above question - looks like Instant/While equipped doesn't work like that, no matter what, so as a workaround I've implemented it like this:

ITM -> global opcode #272 (Apply Repeating EFF) -> once per 1 second

EFF -> opcode #326 (Apply effects list) -> condition: spell state = x

SPL -> melee opcode #1 (Modify attacks per round) limited duration = 1

 

Works as expected, although if someone has better idea how to implement it feel free to post.

Edited by K4thos
Link to comment

Stat-dependent effects while equipped are one thing that are basically impossible. More or less the only way to do it is to use a hack. Which hacks work are very dependent on the particular effect you want to apply.

1) Apply the effect via 177 with timing mode 2. The referenced EFF must have its own filename as its "parent resource" at 0x94, 7 letters max and must be capitalized. And the "resource type" at 0x90 set to "spell." Now add a 324 immunity effect with timing mode 2 before the 177 equipping effect, providing immunity to the EFF filename if you do not have the relevant stat.

2) If you need something more complicated (say, you may gain or lose the stat while the item is equipped and it needs to recognize that and change in response): you would have to cast self-canceling spells through 326 via a repeating EFF (use 177 -> 232, not 272).

Edited by subtledoctor
Link to comment
1) Apply the effect via 177 with timing mode 2. The referenced EFF must have its own filename as its "parent resource" at 0x94, 7 letters max and must be capitalized. And the "resource type" at 0x90 set to "spell." Now add a 324 immunity effect before the 177 equipping effect, providing immunity to the EFF filename if you do not have the relevant stat.

 

I think this information is missing something:

- what opcode should be used on the EFF file?

- how exactly the SPL effects will be removed after the item is no longer eqquipped if your proposed implementation doesn't use opcode #272?

- you've mentioned #324 on ITM providing immunity to the EFF - in NI resource field only accepts ITM and SPL files, not EFF

 

Do you have some example item that works exactly like this in one of your mods that I could use as a base to test it?

 

edit:

2) If you need something more complicated (say, you may gain or lose the stat while the item is equipped and it needs to recognize that and change in response): you would have to cast self-canceling spells through 326 via a repeating EFF (use 177 -> 232, not 272).

 

what's the benefit in this implementation over the one I've posted in my previous post? Seems like it's the same thing, but harder to implement, unless I'm missing something. If one of your mods has such item I'd like to take a look how exactly it's implemented (timing modes and cancelling stuff).

 

And yes, the effect should go away as soon as CRE is no longer under spell effect, even if the item is still equipped.

Edited by K4thos
Link to comment

I think this information is missing something:

- what opcode should be used on the EFF file?

- how exactly the SPL effects will be removed after the item is no longer eqquipped if your proposed implementation doesn't use opcode #272?

The opcode in the EFF is whatever your effect is. So you would add a 177 effect with param2 = 2, param1 = 0 (EA/all, so it affects anyone holding the weapon) and with timing mode 2. If you want to give an APR bonus the EFF will have opcode 1, with timing mode 2.

 

In other words, you can apply EFFs with "while equipped" timing. The effect goes away when the item is no longer equipped. That's the first half of the trick. The 2nd half is...

- you've mentioned #324 on ITM providing immunity to the EFF - in NI resource field only accepts ITM and SPL files, not EFF

You can artificially give EFF files a .SPL resource (by using 0x90 and 0x94, as described above). This makes them susceptible to being blocked by 206/318/324. This is what underpins my multiclass sorcerers mod, among many other things. In NI, in the 324 effect, you have to change the field type to "string" or "text" or whatever, and manually type in the resource name you put in 0x94 of the EFF. (I don't think it has to match the actual EFF filename, but I always do that for the sake of simplicity.) Again, 7 letters or less and all-caps.

 

So you can't apply equipping effects based on the presence of a stat or state. But you can apply equipping effects, and block them based on the absence of the stat or state.

 

2) If you need something more complicated (say, you may gain or lose the stat while the item is equipped and it needs to recognize that and change in response): you would have to cast self-canceling spells through 326 via a repeating EFF (use 177 -> 232, not 272).

what's the benefit in this implementation over the one I've posted in my previous post? Seems like it's the same thing, but harder to implement, unless I'm missing something. If one of your mods has such item I'd like to take a look how exactly it's implemented (timing modes and cancelling stuff).

272 is buggy, always has been. If you have multiple 272 effects with different rates (your weapon effect at 1/second, and regeneration at 1/3 seconds, or poison over time, or whatever) then some of the will randomly not fire.

 

Apply opcode 177, to EA/all again, and have the EFF be 232, with condition = "hp < special %" and special = 102, and resource = your subspell. It will cast the subspell every round, with no weird text feedback, and without interfering with any other ongoing effects (including other 232 effects with the same conditions). So this can safely be applied in lots of circumstances without compatibility concerns.

And yes, the effect should go away as soon as CRE is no longer under spell effect, even if the item is still equipped.

In that case I'm not entirely sure option 1 will work. But it might! Try it out. If it does work, it is WAY better than a hacky repeating effect.

Edited by subtledoctor
Link to comment
You can artificially give EFF files a .SPL resource (by using 0x90 and 0x94, as described above). This makes them susceptible to being blocked by 206/318/324. This is what underpins my multiclass sorcerers mod, among many other things. In NI, in the 324 effect, you have to change the field type to "string" or "text" or whatever, and manually type in the resource name you put in 0x94 of the EFF. (I don't think it has to match the actual EFF filename, but I always do that for the sake of simplicity.) Again, 7 letters or less and all-caps.

 

thanks, I wasn't aware about this trick.

In that case I'm not entirely sure option 1 will work. But it might! Try it out. If it does work, it is WAY better than a hacky repeating effect.

 

doesn't seems to work:
- if you equip item before spell state is applied and later apply spell state then the effect won't work (since opcodes #318/#324 are not updated, even with timing mode = 2 and you're still protected from the EFF file)
- if the item is equipped after spell state is active then opcodes #318/#324 will prevent the EFF from working (which is good thing, since that's what we're aiming for here) BUT
- even if the spell state ends EFF file will still work (since opcodes #318/#324 are not updated)
with such limitations this approach can't be used here, although I will probably find other use cases for this trick in future (for conditions that can't change dynamically), thanks.
Apply opcode 177, to EA/all again, and have the EFF be 232, with condition = "hp < special %" and special = 102, and resource = your subspell. It will cast the subspell every round, with no weird text feedback, and without interfering with any other ongoing effects (including other 232 effects with the same conditions). So this can safely be applied in lots of circumstances without compatibility concerns.

 

Waiting up to whole round (6 seconds) is not good enough. If the effect is not removed each second player could cheat by switching weapon while the effect is still applied and attack up to whole round with applied bonuses that shouldn't be there. So this implementation doesn't sound like an optimal apporach too.
272 is buggy, always has been. If you have multiple 272 effects with different rates (your weapon effect at 1/second, and regeneration at 1/3 seconds, or poison over time, or whatever) then some of the will randomly not fire.
Are you sure the problem is still there in EE engine? Is there a Beamdog redmine entry for this issue? If no, please consider creating one with a test case. Beamdog fixed tons of opcodes already, so there is a good chance they could handle this one too (especially considering opcode 272 is used in many places in original files - even SoD added items with those opcodes). I would do it myself but I'm not able to reproduce it - I've just added 5 more effects with different times, as described in this post, and all of them seems to work correctly.
Edited by K4thos
Link to comment

Waiting whole round (6 seconds) is not good enough. If the effect is not removed each second player could cheat by switching weapon while the effect is still applied and attack whole round with applied bonuses that shouldn't be there. So this implementation doesn't sound like an optimal apporach too.

Meh, cheating players are gonna cheat no matter what you do. But my weapon styles revision mod gets around this by adding a 146 effect casting the subspell once as soon as you equip it (global effect with timing mode 1, I think) and patching all other weapons with an equipping effect that 321 cancels the subspell.

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