Jump to content

A possible SpellCast() bug


critto

Recommended Posts

If not a bug then definitely another weirdness :) I seem to run into these every other day lately.

 

Now, this might appear a bit of a contrived scenario, but it did actually happen, so bear with me. I have global scripts (baldur.baf) that track each of party members casting certain spells like SI to facilitate further usage of specific variables in the enemies' AI scripts. The tracking is done via code blocks of the following structure:

IF
  OR(6)
    SpellCast(Player2,WIZARD_SPELL_IMMUNITY_ABJURATION)
    SpellCast(Player2,WIZARD_SPELL_IMMUNITY_NECROMANCY)
    SpellCast(Player2,WIZARD_SPELL_IMMUNITY_INVOCATION)
    SpellCast(Player2,WIZARD_SPELL_IMMUNITY_ENCHANTMENT)
    SpellCast(Player2,WIZARD_SPELL_IMMUNITY_CONJURATION)
    SpellCast(Player2,WIZARD_SPELL_SHIELD)
THEN
...
END
We've noticed when we were testing a new enemy's behaviour that he casts too many spells at one party member and absolutely zero at the other which made no sense. I started debugging via DisplayString calls and found out that every casting of the aforementioned spells by one caster (Player3, in this case) gets detected by SpellCast(Player2,...) trigger call!
I am not going to make you suffer through the description of the God-awful amount of tests I did, but I narrowed down the problem somewhat, trust me on this. It has turned out that the tester had two very similar characters, custom-created Berserker(9)->Mages. During those tests I've found out that if you have two custom chars of the same base class (not necessarily berserker and not of that specific level), of the same alignment (!) and, possibly, gender (I just didn't have it in me to do any more tests, re-creating custom parties via multiplayer, cluaing XP and relevant spells, etc.) then SpellCast would detect the second character's castings as that of a first one.
I definitely know that values of the primary stats, current level of XP, weapon choices and certain cosmetic things like a portrait have no impact on this. I know that it doesn't matter which slot in the party the second almost-copycat char takes (he can be Player4, etc.). I have no idea how this works if there are more than two such chars in the party.
The situation does happen, however. When it comes to SpellCast() trigger, the game thinks those are the same character (the one that was created the first). I have some CheckStatGT() calls as well in that script. When those are triggered, every character is treated by the game distinctly, no overlaps or anything like that. It properly detects who's Player2, who's Player3 and so on.
Yes, this is a very unlikely situation to happen and probably doesn't deserve that much attention, but it definitely got mine for I have spent days looking for bugs in the AI script. This is just so weird. Is there any information available on how the game handles Players 1 thru 6?
This bug/feature/whatever that is appears both in ToB and EE.
Link to comment

What would be interesting to see if this is reproducible with npc-alikes. Otherwise it could be limited to the multiplayer mode.

From what you describe it seems like internally it replaced the object match with a filter ([EA....]), but yeah WTF.

Link to comment

Did some more tests (can't look at the Create Character screen anymore...)

 

I think you are right, this is restricted to multi-player code and custom chars. Imoen is customised to sorceress in my game, created a human neutral good female sorcerer protagonist in single game. Each char is tracked properly. The same when protagonist is created in multi-player game. However, if I add another such character (non-protagonist), her castings are detected as that of the protagonist. The game doesn't mess with Imoen.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...