Jump to content

Photo

apply effect on attack


8 replies to this topic

#1 K4thos

K4thos
  • Modders
  • 1198 posts
  • Gender:Male

Posted 24 September 2018 - 11:10 AM

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....694#entry263300


Edited by K4thos, 24 September 2018 - 06:40 PM.


#2 subtledoctor

subtledoctor
  • Modders
  • 2759 posts
  • Gender:Male

Posted 24 September 2018 - 12:09 PM

I have opcode 248 effects that affect the attacker... I think you might have to do:

 

Effect on attacker:

- opcode 248, target = 2, resource = EFF1

 

EFF1:

- opcode 146, target = 2, resource = Spell2

 

Spell2:

- [effect on attacker], target = 9

 

Something like that.


Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#3 K4thos

K4thos
  • Modders
  • 1198 posts
  • Gender:Male

Posted 24 September 2018 - 06:15 PM

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.

Attached Files

  • Attached File  test.zip   541bytes   3 downloads

Edited by K4thos, 24 September 2018 - 06:21 PM.


#4 K4thos

K4thos
  • Modders
  • 1198 posts
  • Gender:Male

Posted 25 September 2018 - 02:41 AM

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, 25 September 2018 - 02:43 AM.


#5 subtledoctor

subtledoctor
  • Modders
  • 2759 posts
  • Gender:Male

Posted 25 September 2018 - 02:58 AM

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, 25 September 2018 - 05:59 AM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#6 K4thos

K4thos
  • Modders
  • 1198 posts
  • Gender:Male

Posted 25 September 2018 - 03:39 AM

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, 25 September 2018 - 04:04 AM.


#7 subtledoctor

subtledoctor
  • Modders
  • 2759 posts
  • Gender:Male

Posted 25 September 2018 - 05:58 AM

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, 25 September 2018 - 06:02 AM.

Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE


#8 K4thos

K4thos
  • Modders
  • 1198 posts
  • Gender:Male

Posted 25 September 2018 - 07:07 AM

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, 25 September 2018 - 07:15 AM.


#9 subtledoctor

subtledoctor
  • Modders
  • 2759 posts
  • Gender:Male

Posted 25 September 2018 - 07:13 AM

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.


Faiths & Powers: Spell spheres and kit pack for priests and paladins
Might & Guile: Tweaks and kits for warriors and rogues
Scales of Balance: Game tweaks and rule overhauls
NPC_EE: More options for NPCs in BGEE, SoD, & BG2EE




Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users