Jump to content

Opcode 272: Apply Effect on Condition


Recommended Posts

Posted (edited)

Is this opcode known to be buggy for type 3 (fire once every frequency x seconds)? It seems to inexplicably double, sometimes triple apply itself on the regular. I have an armor that applies a -2 THAC0 for the wearer while equipped that also uses opcode 272 with type 3 at 6 frequency (roughly but not exactly a round) to apply an effect that casts a +2 THAC0 bonus on the same creature for a duration of 7. I expect a small amount of overlap so that you *might* see a 20 THAC0 creature go down to 18 rarely, but instead it's very rarely 20, usually 18, sometimes 16, rarely 14, and pausing/unpausing the game seems to cause it to fire even more than that - by rapidly pausing and unpausing, I was able to turn what is supposed to be a +2 bonus into literally +30.

Baldur_EvU5NnC4hm.png

The hell's going on with this opcode?

 

Edited by Bartimaeus
Posted

It's funny how every "generation" has to discover the same facts for itself. If there was some universal grand tome that would be obligatory to read, something much better than the guide to effects here, new learners would start from a higher ground every time instead of ground zero. As it is, we spend a lot of the creative interval that we are given on learning the ropes, and when we are quite done learning them, 3/4 of our creative potential has evaporated.

I, too, have had to discover the irregular character of this effect. So has everyone else before me, probably... because it's not getting fixed. Beamdog is doing anything with its patches but addressing real problems with the engine. But then, maybe these aren't fixable. In answer to your question: the effect is unreliable. Although I don't think I have seen it fail to apply at the given time, it can trigger before. What you need to do, then, is to build in a protection that will block this effect until the right moment. First, you need to set up the EFF to Cast spell (opcode 146) or, if you are making your mod for the Enhanced Editions only, Apply effects list (326). The EFF must deliver this spell, with further effects down the line, not bring to bear the bonuses directly. From this spell cast another with the bonuses and below put a block for this, second, spell. So:

Your item or Spell 1: Use EFF file on condition, interval X.

EFF: Cast/Apply Spell 2.

Spell 2: Cast/Apply Spell 3, below Protection from Spell 2 (206 or 318), duration... 

Here is the tricky part, the engine is not too precise with delivering effects. They can be off by a couple of ticks. You need to find a balance between leaving Spell 2 open to duplication and blocking it so near to X that the engine will miss and Spell 3 won't be delivered this cycle. From my trial and error (where is the grand tome?), X minus 3-4 ticks is the most effective block.

Another thing to consider is that sometimes a simple self-recasting 146 is a better option. You cast a spell, include the effects in it and tell it to cast itself again with Delayed/Permanent at X. Every second, maybe. This is very accurate. The problem then is ending this cycle once, say, your item is removed. For that you include a removal spell in the combo but add a While Equipped Protection from this spell among your item's effects, target Self. That's going to look like this:

Your item, While Equipped (or Instant/Permanent...): Cast Spell 1.

Spell 1: Remove the effects of Spell 1, to avoid duplication. Second effect: such and such bonuses, to last X + a few ticks just to be on the safe side. Third effect: Cast Spell 1, Double/Penetration at X, Self. Fourth effect: Cast Spell 2, an instant duration, Self.

Spell 2: Remove the effects of Spell 1, i.e. the bonuses and recasting.

Your item, White Equipped: Protection from Spell 2, Self.

You are not so dense, but it'll give me pleasure to elaborate that so long as the item is held, Spell 2 will never stop the cycle. When you put down this piece of gear, the bonuses will quietly expire after X. It is best to make X 1 second, which is the shortest interval for Delayed/Permanent anyway. Flying with Captain Obvious here, only the Enhanced Editions allow targeted removal of effects, so this arrangement is only for EEs, but you have to think about how your wildly cycling EFF's effects are going to end, too. In an EE it's always possible to include Remove effects by resource on top of a spell and clean out any overlap.

Posted

Likely a result of this.

The engine does not track when or if the frequency opcodes have triggered (poison, disease, regen, op272), only if it is time for them to trigger, so it's possible that the game just rechecks the in-game timer to apply their effects every time you pause.

Posted (edited)

For something to apply once/round, use opcode 177, specifying an EFF. In the EFF, use opcode 232, fire whenever target’s HP are below %special%, and set the special value to 102. Set it to cast a subspell. 

On the old engine, I would set the subspell’s duration to 6 - better a fraction of a second with no effect than a full second with a doubled effect, IMHO. On the EE engine I set the duration to 8 and preface the subspell with a 321 effect canceling itself, so you get full coverage but no doubling. 

You can make the subspell’s application conditional via opcode 206 (on the old engine) and 318 (on the EE engine). Lots of trickery can be do e this way. 

NB if this is for an aura, the characteristics of the projectile you use will heavily affect it. (See people complain about how bard songs can sometimes be “outrun” if your bard and the beneficiary are moving in the same direction, with some distance between them.) Realistically, for auras that ‘long duration, with opcode 321’ thing is not so much useful, as necessary. The old engine is really not set up to handle auras well. 

EDIT - I played around with self-recasting spells a while ago... I recall having unexplained crashes several dozen hours into games. I never discovered if that was the cause... but I’m wary of doing that these days. I haven’t found an effect I wanted that couldn’t be done as well or better with other techniques. (On the EE engine, at least.)

Edited by subtledoctor
Posted (edited)
8 hours ago, temnix said:

Although I don't think I have seen it fail to apply at the given time, it can trigger before. What you need to do, then, is to build in a protection that will block this effect until the right moment

Unfortunately, the intended effect relies on the opposite to be true - it's supposed to stack. The idea of the effect is that several bats together will create a "swarming" effect that will each give additional THAC0 to each other (+2, to be exact). But with just *one* of these effects, it's already badly breaking - with an intended max of 5 summonable bats all using this effect on themselves and each other, the effect goes completely and utterly bonkers.

6 hours ago, kjeron said:

Likely a result of this.

The engine does not track when or if the frequency opcodes have triggered (poison, disease, regen, op272), only if it is time for them to trigger, so it's possible that the game just rechecks the in-game timer to apply their effects every time you pause.

Thanks.

6 hours ago, subtledoctor said:

For something to apply once/round, use opcode 177, specifying an EFF. In the EFF, use opcode 232, fire whenever target’s HP are below %special%, and set the special value to 102. Set it to cast a subspell. 

On the old engine, I would set the subspell’s duration to 6 - better a fraction of a second with no effect than a full second with a doubled effect, IMHO. On the EE engine I set the duration to 8 and preface the subspell with a 321 effect canceling itself, so you get full coverage but no doubling. 

You can make the subspell’s application conditional via opcode 206 (on the old engine) and 318 (on the EE engine). Lots of trickery can be do e this way. 

NB if this is for an aura, the characteristics of the projectile you use will heavily affect it. (See people complain about how bard songs can sometimes be “outrun” if your bard and the beneficiary are moving in the same direction, with some distance between them.) Realistically, for auras that ‘long duration, with opcode 321’ thing is not so much useful, as necessary. The old engine is really not set up to handle auras well. 

EDIT - I played around with self-recasting spells a while ago... I recall having unexplained crashes several dozen hours into games. I never discovered if that was the cause... but I’m wary of doing that these days. I haven’t found an effect I wanted that couldn’t be done as well or better with other techniques. (On the EE engine, at least.)

That condition is EE-only, and sadly 206 cannot be used for this case for reasons stated above in my reply to temnix. I've made aura-like effects before, but generally they have been the non-stackable (or harmlessly stackable) kind - this particular SR aura (Monster Summoning I) is the only one I can think of where that's not the case, and it appears to be a non-workable. I think I'll just have to disable the effect...perhaps I could try tying it to the use of their weapon. It wouldn't be as reliable, but at least it might not go (as?) insane.

Edited by Bartimaeus
Posted (edited)

How do you summon the bats? Maybe make it non-stackable, give each bat its own special and filter effects based on that?

Edited by Magus
Posted
5 hours ago, Magus said:

How do you summon the bats? Maybe make it non-stackable, give each bat its own special and filter effects based on that?

Yeah, I think that would work. Though slightly annoying to implement, but it'd work. Thanks!

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