Jump to content

IWD2 Scripting Notes


Gimble

Recommended Posts

Moderator: Please feel free to move this elsewhere if there's a better spot for it to "live".

 

After a lengthy absense, I'm back in the mood to try to improve the IWD2 user scripts once again. I found that leaving a track of 'bread crumbs' as things are discovered on the Internet was very helpful: there's a lot of information that was originally posted by myself or others that I had forgotten. See (as a partial example) http://www.gibberlings3.net/tools/iwd2_scripting_info.txt

 

This time, I've begun with isolating the user scripts slots, as my intended design will probably use most or all of them in an attempt to modularize the system as much as possible. According to scrlev.ids, the following slot IDs should be in play:

0 OVERRIDE
1 SPECIAL_1
2 TEAM
4 SPECIAL_2
5 COMBAT
6 SPECIAL_3
7 MOVEMENT

Note the non-contiguous numbers on the side. To my lack of surprise, the IDS file is wrong: the available slots for scripts is still zero to six (0-6) and not seven. As a point of interest, the user-selectable script slot is slot 3 (unnamed according to the original IDS file).

 

To test this code required a user script like the following:

IF
!TimerActive(200)
THEN
RESPONSE #100
	FloatMessage(Myself,1983) // ::Yawn::
	StartTimer(200,7)
	ChangeAIScript("SLOT1",1)
	ChangeAIScript("SLOT2",2)
	ChangeAIScript("SLOT4",4)
	ChangeAIScript("SLOT5",5)
	ChangeAIScript("SLOT6",6)
END

Each of the slots has their own script in override, similar to the following (this is SLOT1.BCS):

IF
True()
THEN
RESPONSE #100
	FloatMessage(Myself,24088) // 1
	ChangeAIScript("",1)
END

Testing indicates that the above works (with SLOTn.BCS using the approriate FloatMessage index and AI Script slot), and changing slot 3 changes the user-selected script.

 

Hopefully I'll post more findings as I dig back into the project. There's a lot of dust I have to sort through to figure out where I was. It's doubtful that anyone cares, but if they do, at least they'll have some more information to work with.

Link to comment
What about slot0 and slot7 then?

{Briareus}IIRC, the script you assign to a PC is in Special3

  • Slot zero exists and works as expected.
  • Slot 7 does not exist. If a script is assigned to slot 7, it is never executed.
  • PC scripts are definitely assigned to slot 3, not SPECIAL_3 (slot 6 according to the "offical" SCRLEV.IDS). Briareus remembered incorrectly.

Edited again for brevity.

Link to comment

New thing: CheckStat(Myself,*,ARMORCLASS) seems to crash the game. I'm a little confused, since the i2Series scripts uses it (actually, CheckStatGT(), but I've tested both), but I can say any attempt to look at the ARMORCLASS stat results in a game crash.

IF
CheckStatGT(Myself,6,ARMORCLASS)
THEN
RESPONSE #100
	NoAction()
END

In my IDS file, ARMORCLASS maps to 2. If someone has an explanation, I'd love to hear it.

Link to comment

I can definately confirm that crash. This is a pure guess but; I think it started happening with the official IWD2 patch/update as I've definately had one full runthrough and many more tests while building the i2series scripts. That crash p!ss£d me off enough that I've never played IWD2 again.

 

-Y-

Link to comment

More snippets:

  • The StrongestOf seems to apply to the party member with the most experience points. In my test game, StrongestOf selected my Sorceress 11/Paladin 2/Rogue 1 character, while bypassing my Paladin 2/Fighter 11 (most hitpoints, most BAB) and pure Sorceress 14 (more and higher level spells).
  • HasItemEquiped seems to work just like HasItem: it resolves to true if the item is in the player inventory.
  • I may edit this post and add more minor discoveries here.

(And Yovaneth, thanks for the confirmation. I walk away from IWD2 every so often for a few months or years until I just can't help it.) As a side note, I'll probably post soon some findings about MarkedSpell and spell selection. While scripting for IWD2 is rather different than the other IE engines, I'm finding it a little easier to script massive spell lists than I have the other engines.

Link to comment

Spells not safe without extra checks for MarkSpellAndObject (See below):

  • CLERIC_ANIMAL_RAGE -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPPR517
  • CLERIC_AURA_OF_VITALITY -- Use !CheckSpellState(Myself, AURA_OF_VITALITY) REQUIRES MODIFICATION OF SPELL SPPR729 and SPLSTATE.IDS
  • CLERIC_AID -- Use !CheckSpellState(Myself, AID)
  • CLERIC_BEAST_CLAW -- Use !CheckSpellState(Myself, SUMMONED_WEAPON) REQUIRES MODIFICATION OF ITEM BCLAW and SPLSTATE.IDS Done to prevent double-casting and also to start a spell state to keep someone with one summoned weapon from summoning another one.
  • CLERIC_BLESS -- Use !CheckSpellState(Myself, BLESS) . Caliban's note in iwd2_scripting_info.txt is correct.
  • CLERIC_CHAMPIONS_STRENGTH -- Use !CheckSpellState(Myself, CHAMPIONS_STRENGTH) REQUIRES MODIFICATION OF SPELL SPPR507
  • CLERIC_EXALTATION -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPPR316
  • CLERIC_HOLY_AURA -- Requires SPELLCAST_IGNORE_VALID_SPELL_TARGET as a flag to MarkSpellandObject. Use CheckStatLT(Myself,25,RESISTMAGIC) for detection if you don't want to modify the spell.
  • CLERIC_IMPERVIOUS_SANCTITY_OF_MIND -- Use !CheckSpellState(Myself, IMPERVIOUS_SANCTITY_OF_MIND) REQUIRES MODIFICATION OF SPELL SPPR716 and SPLSTATE.IDS
  • CLERIC_IRON_SKINS -- use CheckStatLT(Myself,1,STONESKINS)
  • CLERIC_MAGIC_RESISTANCE -- Requires SPELLCAST_IGNORE_VALID_SPELL_TARGET as a flag to MarkSpellandObject. Use CheckStatLT(Myself,21,RESISTMAGIC) for detection if you don't want to modify the spell.
  • CLERIC_NEGATIVE_ENERGY_PROTECTION -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPPR326
  • CLERIC_PRAYER -- use !CheckSpellState(Myself,BENEFICIAL_PRAYER)
  • CLERIC_REMOVE_FEAR -- Use !CheckSpellState(Myself, REMOVE_FEAR) REQUIRES MODIFICATION OF SPELL SPPR108 and SPLSTATE.IDS
  • WIZARD_CATS_GRACE -- Use !CheckSpellState(Myself, CATS_GRACE)
  • WIZARD_DEATH_ARMOR -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPWI214
  • WIZARD_MIND_BLANK -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPWI804
  • WIZARD_MINOR_GLOBE_OF_INVULNERABILITY -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPWI406
  • WIZARD_STRENGTH (Bull's Strength) -- Use !CheckSpellState(Myself, CHAMPIONS_STRENGTH) REQUIRES MODIFICATION OF SPELL SPWI214
  • WIZARD_PROTECTION_FROM_PETRIFICATION -- Missing SetState on spell. REQUIRES MODIFICATION OF SPELL SPWI108
  • Additional entries added here as discovered

MarkSpellAndObject is supposed to check for possible target validity. However, not all necessary checks are made, and as a result, you may have to do additional checking prior for MSAO for some spells. The above is just a (evolving) list of spells I've verified that are not properly state-checked.

Link to comment

Near Infinity apparently will corrupt a spell on occasion after editing if you've added an extra effect in a way it's not happy with. Still, overall it's a great tool. Tread carefully, and make changes in small increments!

 

I'll be waxing eloquent before too long about the wonders of the MarkSpell system. Before I do so, though, let me give a warning. On occasion, MarkSpellAndObject with multiple selectable spells (at least in my usage) on a Sorceror will decrement an incorrect spell level. It's my guess that the level being wrongly decremented is the level of the first spell on the MSAO list. *Edit* After some time away and rest, I realize that my strange spell counts may be attributable to the effects of expiring/non-expiring Eagle's Splendor and the presence of multiple characters with similar spell sets, all performing buffs. More investigation is needed, but I think I cried "foul" too quickly this time.

Link to comment

Oh, a brief rant about spell durations. As I've long suspected (but not proven until now), a "minute" in a spell description is a very nebulous term. In various spells, a "minute" might mean a round, 2 rounds, three rounds, or even 10 rounds. An example of each:

  • BLESS : Description says "one minute per level", spell does ten rounds per level
  • SPELL RESISTANCE : Description says "one minute per level", spell does three rounds per level
  • PROTECTION FROM EVIL : Description says "one minute per level", spell does two rounds per level
  • REMOVE FEAR : Description says "ten minutes", spell does ten rounds

Link to comment

For some reason, CLERIC_HOLY_AURA is broken. It always fails the IsSpellTargetValid(Myself,CLERIC_HOLY_AURA,0) check. Also, MarkSpellAndObject will always fail to select the spell unless the SPELLCAST_IGNORE_VALID_SPELL_TARGET flag is set. Suggestions are welcome.

 

Edit: CLERIC_MAGIC_RESISTANCE has the same problem. I suspect it has something to do with the spell setting resistance levels. We'll see when I get to other SR spells.

Link to comment
Seeing that long list for MarkSpellAndObject one might think it would be easier to list the working cases :)
It seems like it. As best I can tell, MSAO was built on an as-needed basis. Since AI scripts use few (if any) buffs, a lot of the buff triggers were ... less well done. I'll know more about the offensive spells once I get into them.

 

MarkSpellAndObject, like everything else in IWD2, has some really great things to it and some very bizarre behaviors as well. I'm still sorting those through in my head. Getting closer to proof of concept, though.

Link to comment

New annoyances.

  • The Paladin description doesn't mention anything about Protection From Evil, but any Paladin gets one (and only one, as best I can tell) innate PFE spell. Also, no mention of the spell in SPELL.IDS (so I added, see above).
  • The FindTraps() action doesn't work for a number of classes- I tested Paladin, Monk, Barbarian, Cleric, Druid, Wizard. Of those six, only the Monk would enable Search via script (the FindTraps() call). It's my strong suspicion that only rogue-like classes ( Rogue, Monk, Bard ) have this functionality enabled.
  • To my surprise, even characters with "paid-for" skill points apparently may not be access their class abilities via the menus, much less script. I have a first-level Wizard with two purchased cross-class points in Disable device, and the unlock icon is "greyed out" when he selects the skill: so he is unable to unlock anything despite having bought points in the ability.

Link to comment

Archived

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

×
×
  • Create New...