Jump to content

[code] Code fixes, aka stuff we can't fix


Recommended Posts

23 hours ago, Bubb said:

Quoting past me regarding NextTriggerObject() and how it breaks the trigger block it is in if it evaluates to an invalid creature:

  Reveal hidden contents

It's easier just to show the flaw in the trigger block evaluation code.

if (hasNextTriggerObjectOverride)
    if (nextTriggerObjectOverride != NULL)
        // do eval stuff
        hasNextTriggerObjectOverride = false
    // do eval stuff

NextTriggerObject sets both hasNextTriggerObjectOverride=true, and if it can't find a valid object, nextTriggerObjectOverride=NULL. Once this happens, the engine gets stuck in a bad state. Since nextTriggerObjectOverride is NULL it never clears hasNextTriggerObjectOverride, and it forever skips evaluating further triggers, (in the current trigger block).

Note though, while it's not evaluating the triggers, it is still running through all of them and doing janitorial actions. Meaning - every non-OR'd trigger still sets the whole block's result to false, the active OR count still ticks down - another NextTriggerOverride has the potential of fixing the deadlock, etc.

The only way a trigger block can still succeed after NextTriggerOverride breaks is:

  1. The NextTriggerOverride was in an OR block
  2. There are no subsequent triggers after the OR block
  3. A trigger in the OR block, that is positioned above the NextTriggerOverride, already evaluated to true

or, further in the same OR block, another NextTriggerOverride evaluates to a valid creature, and fixes the bad state. Once that happens, the trigger block will start evaluating normally again from that point onward. So, I suppose, one way to prevent NextTriggerOverride from breaking everything would be something like this:

        TriggerOverride(Myself,False()) // This will fix the deadlock
        // Whatever trigger here

In any case, modders should always use "TriggerOverride()", right...?

Link to comment
1 minute ago, Luke said:

In any case, modders should always use "TriggerOverride()", right...?

TriggerOverride() is just a compiler-shortcut for NextTriggerObject() + WhateverTrigger(), so it really doesn't matter whether you write it out or use the shortcut. It's convenient shorthand, but it still suffers from the same bugs. But yes, since NextTriggerObject() isn't intended to be a standalone trigger, it's probably safer to use TriggerOverride().

Link to comment

Here's something that's up for debate, quoting past me:


Did you know that any attack a thief makes while invisible will ignore the target's AC dexterity bonus?

To be exact, the attack must follow these rules:
1) Attacker must have a backstab multiplier of 2 or higher
2) Attacker must be STATE_INVISIBLE
3) Attacker's weapon must not be RANGED

In the following example:
- Attacking character THAC0 = 17
- Attacked character AC = 0, (dexterity contributing -4 bonus)

The thief's attack only requires a total roll of 13 to hit, even though a roll of 17 is required normally:



However, this mechanic isn't implemented properly...

If the attacked character has a *penalty* to AC due to dexterity, they will be harder to hit while being attacked under the above conditions.

In the following example:
- Attacking character THAC0 = 17
- Attacked character AC = 9, (dexterity contributing +5 penalty)

The thief's attack should only require a total roll of 8 to hit, though a roll of 13 is now required:



Bug(?): Should backstabs (which invert a creature's AC Dex modifier) make a creature with a Dex penalty harder to hit?

Link to comment
5 minutes ago, CamDawg said:


I ask because some people have fought me on this, saying that it's like that in PnP. I agree that it seems silly from a gameplay perspective, but I don't know what the intent was, (or if that PnP claim is true).

Link to comment
41 minutes ago, Bubb said:

some people have fought me on this, saying that it's like that in PnP

There’s no way. 2E was the last edition of D&D governed by common sense (fight me), I highly highly doubt anyone can produce a textual source for this. “DEX bonus doesn’t apply against invisible attackers” in no way implies “DEX penalties are reversed against invisible attackers.”

Also, mostly commenting because I never knew the engine was coded to encompass this rule. For some reason I had it in my head that invisible attackers got a straight +4 bonus to hit. 

Link to comment
1 hour ago, Bubb said:

I ask because some people have fought me on this, saying that it's like that in PnP. I agree that it seems silly from a gameplay perspective, but I don't know what the intent was, (or if that PnP claim is true).

The idea that backstabs deactivate Dexterity modifiers comes from 3rd edition D&D (ideas from which trickle into the IE games, even though they're mostly AD&D 2nd edition): flat-footed characters "can't use a Dexterity bonus to AC (if any)". (And 3rd edition very carefully distinguishes between 'bonus', 'penalty', and 'modifier': a negative dexterity modifier is a dexterity penalty, not bonus. 

In AD&D, the defender just gets a 4-point AC penalty if the attacker is invisible.

Link to comment

So then, in the (EE) Infinity Engine games they get both. A +4 attack bonus for attacking in melee from invisibility, and negating Dex bonuses. All characters get the former, only characters with Sneak Attack or Backstab get the latter. Then there are the bonuses for melee against unarmed/ranged; another +4 to hit and +4 to damage.

It all stacks, and it can make an utterly enormous difference. Suppose Imoen is level 5 with a +1 shortbow and normal arrows, and the +2 shortsword, fighting Nimbul. If she backstabs him, that's base THAC0 18, +2 to hit from the weapon, +4 to attack from invisibility, and +4 to hit because he's wielding a throwing axe. Against that, he has base AC 5 and no Dex bonus due to the stab. Imoen hits on a 3, for a minimum of 21 damage - a guaranteed kill. If she shoots an arrow at him instead, that's base THAC0 18, +2 to hit from her dexterity, and another +1 from the arrow. Against that, Nimbul has AC 1 including his Dex bonus and an additional -5 bonus versus missiles from his boots. She now hits on a 19, dealing 2-7 damage or twice that on a critical. 90% chance to hit and kill one way, 10% chance to hit and definitely not kill the other.

Link to comment

Though that does support having both an attack bonus and Dex negation. Creatures with Dex penalties to AC in these games are also exceedingly rare. Searching BGEE for Dexterity 5 or less ...

CENTEO (Centeol), NEDEER1 (Deer), PHEOARCH (Phoenix Guard), PHEOGURD (Phoenix Guard), PHOENIX (Phoenix Guard), RABBIT (Rabbit), Squirrel (Squirrel), TTSER1 (Jospil), TTSER2 (Brevin). Would you ever even consider backstabbing any of them?

Same search in BG2EE:

CENTEO01 (Centeol), DEER01 (Deer), GRHOG01 (Groundhog), MOOSE (Moose), PHEAS01 (Pheasant), RABBIT (Rabbit), SQUIRR (Squirrel), TTSER1 (Jospil), TTSER2 (Brevin).

Basically the only time this would ever come up is if you started applying Dex penalties to enemies, like Polymorph Other or Haer'Dalis' sword Chaos.

I'd file this one under "bug, but very low impact".

Link to comment
3 hours ago, suy said:


This is a quote from the PHB, revised edition (AD&D 2nd edition, of course). It's obviously a bug, IMHO.

Maybe I'm missing something, but to me it seems to be an issue with ambiguous terminology.  "Negate" can mean:

  1. nullify; make ineffective; cancel out
  2. to make negative.  e.g. an integer (in this case, negating a [negative] penalty produces a bonus)

To me, the intent is clearly meaning 1, whereas a select few may interpret as 2.

Link to comment

I also have the old edition in paper, but in Spanish, so that's let's useful to share here of course. :) There it says roughly the same, and instead of "negate" it says "anular", which I would translate as "nullify" or "cancel". I think it makes sense, as it says that the idea is that the target is not aware of the attack, so it can't attempt to dodge it (or, in the case of awful dexterity, accidentally get hit with more ease). So it should just have a 0 bonus/penalty IMHO.

Link to comment
18 hours ago, DavidW said:

Huh. I’m not sure I even knew there’d been a revised edition.

DriveThruRPG claims the following was the revision which doesn't really sound significant in terms of content, but moreso as presentation:


Many Printings. The new Player's Handbook was reprinted more than ten times following its 1989 release. Then, about halfway through AD&D 2e's life cycle, a second edition (1995) of the book appeared. This was primarily a cosmetic change. It expanded the amount of color, revamped the illustrations, and increased the page count by 25% thanks to a looser layout. This new book was the foundation of AD&D 2.5e (1995-1997), though that nomenclature is based mainly on the books that followed it; the core rules were largely unchanged.


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.

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