Jump to content

AI spellcasting - how does it work? (SCS and non-SCS)


subtledoctor

Recommended Posts

I'm thinking about making a mod that alters the spelcasting system to somewhat eliminate the 6-second round. (Slight Wall of Text follows...)

 

Justification: in the realm of physical attacks, weapon speed means very little, rather APR is king. And APR can change as a warrior gets more powerful. But with spellcasting "SPR" (spells per round...?) never changes. You can lower your casting speed but that is only useful for 2 things: not being interrupted, and the super-cheese Vecna+Alacrity.

 

A mod could alter spellcasting such that every caster in the game has permanent Aura Cleansing... and rebalancing the casting times of every spell and item. The result should be *mostly* similar to vanilka gameplay... but will allow more, and more interesting, bonuses and penalties for stuff like kits, Alacrity, the Robe of Vecna, casting in armor with IR, etc.

 

There are a few ways to make this work. One is to give Aura Cleansing to everyone and simply increase casting time for all spells to 5+, to prevent crazy cheese. Alacrity and RoV could each give a 2-point deduction. Problem with this is, it drastically increases the chance of spell interruption. It might be okay with TobEx's 'Concentration Check' mod, but that can't be used on the EEs and the devs seems like they might never allow it to be implemented.

 

A better solution would mix mild casting time increases with some kind of pause after the spell is cast. I thought about trying to apply an instantaneous Aura Cleansing on a ~3 second delay, but there are technical challenges to implementing that. (No way to apply an effect on an x second delay for y seconds without weird work-arounds.)

 

Another possibility, with permanent Aura Cleansing for everyone, is to apply an undispellable, unresistable Silence for a couple seconds after every spell. But I think that would trigger SCS mages to cast Vocalize.

 

I could apply a 'pause' like with IRv4's crossbows, but I think that freezes you in place, and I don't want to impair mobility.

 

Another possibility is to simply apply a 'Disable Spellcasting Button' effect for a couple seconds after every spell. This has the benefit of giving the player visual feedback when they can cast again. And it would be pretty easy to implement. (In theory.)

 

Question is, would it work for the AI? Is this, or is there another, way to force on the AI a ~2-second pause between the end of casting one spell and the beginning of casting the next one?

 

Would any such mechanism even work for the AI? Or is it scripted to just cast every 6 seconds, rendering Aura Cleansing meaningless?

 

Any input appreciated, thanks for listening.

Link to comment

This:

Another possibility is to simply apply a 'Disable Spellcasting Button' effect for a couple seconds after every spell. This has the benefit of giving the player visual feedback when they can cast again. And it would be pretty easy to implement.

-won't work on the AI, it can just cast as many spells as it has, cause it doesn't care if you disable the players ability to push the buttons to cast spells, as it doesn't use the buttons.
Link to comment

There's also an opcode to "Disable Spellcasting" with separate options for priest or wizard spells. It leaves the button usable but, for the player, the spelks themselves are greyed out once you press the 'cast' button. Any idea whether that would work for the AI?

 

Does the AI ever use Tenser's Transformation? Or Wraithform, of any other spell that temporarily disabled casting? If that stuff works for the AI then I should be able to use that effect...

Link to comment
Would any such mechanism even work for the AI? Or is it scripted to just cast every 6 seconds, rendering Aura Cleansing meaningless?

 

Vanilla doesn't care, SCS and other AI mods do use a six-second timer. You can change that, but you'll have to re-compile the entire AI - which is none impossible, but will be quite overwhelming if you had to ask.

Link to comment

Another possibility, with permanent Aura Cleansing for everyone, is to apply an undispellable, unresistable Silence for a couple seconds after every spell. But I think that would trigger SCS mages to cast Vocalize.

Yup.

 

 

Question is, would it work for the AI? Is this, or is there another, way to force on the AI a ~2-second pause between the end of casting one spell and the beginning of casting the next one?

 

Would any such mechanism even work for the AI? Or is it scripted to just cast every 6 seconds, rendering Aura Cleansing meaningless?

 

Any input appreciated, thanks for listening.

What you could do in theory, is apply a 100% spell failure chance. That will stop any SCS mage not immune to that effect (I know for certain Mellisan is, but her spells are timer-based, not spellbook) not to cast for duration.

AI is scripted via GlobalTimer. Every time AI casts a spell, it's set to 6 seconds. When it reaches 0, AI casts again.

 

 

Does the AI ever use Tenser's Transformation? Or Wraithform, of any other spell that temporarily disabled casting? If that stuff works for the AI then I should be able to use that effect...

Yes, Tenser is used. I'm not sure how AI handles it if it prevents casting- I'm otoh sure that if it doesn't disable casting AI will cast spells.

Other spells which prevent spellcasting (fwiw, in SRv4 Tenser doesn't prevent casting anymore) are not, I think.

Link to comment

 

Would any such mechanism even work for the AI? Or is it scripted to just cast every 6 seconds, rendering Aura Cleansing meaningless?

 

Vanilla doesn't care, SCS and other AI mods do use a six-second timer. You can change that, but you'll have to re-compile the entire AI - which is none impossible, but will be quite overwhelming if you had to ask.

And, just so I know I've exhausted all options:

 

1) That six-second timer starts from the *begginning* of casting a spell, right? There's no (relatively simple) way to add spells' casting time to the counter?

 

2) There's no (relatively simple) way to add a variable so that the length of the timer would depend on the AI NPC's level? So NPC=level 1 would use a six-second timer, and NPC=level 20 would use a three-second timer?

 

And NPCs under IA would use a 1-second timer? (How do these mods deal with IA? They must interact with it somehow to become exempt from the timer while it's in effect...)

Link to comment
1) That six-second timer starts from the *begginning* of casting a spell, right? There's no (relatively simple) way to add spells' casting time to the counter?

 

If you generate AI from a source, e.g. .ssl files in SCS, you can adjust the code to accept timer argument. If not, you can still do it manually via regexp search and replace, though it will be slightly less reliable.

 

2) There's no (relatively simple) way to add a variable so that the length of the timer would depend on the AI NPC's level? So NPC=level 1 would use a six-second timer, and NPC=level 20 would use a three-second timer?

 

You can set a local var from SPL, like Spell Revision does for Glitterdust, and check for that var instead of timer.

If there items/abilities that should adjust the delay duration, you can use a combination of 146/206 opcodes to set custom value if an item is equipped.

 

And NPCs under IA would use a 1-second timer? (How do these mods deal with IA? They must interact with it somehow to become exempt from the timer while it's in effect...)

 

It should be OR(2) UnderIA !GlobalTimerNotExpired(), but iirc most mods don't care about IA check inclusion.

Link to comment

How do you check a local variable that isn't set in a script?

If it's via a spell. Then it depends on to whom it's set to, if it's set to your creature, you check it alike it was a global(with a few differences, just alike in it's setting).

If it's set to someone else, just like if it's set by someone elses script, you can't, so you won't. The glitterdust's effects can be detected on the creatures affects side(usually), but that's totally different aspect.

Link to comment

Local vars are really stored as 309th opcode, so you can set them directly by a SPL effect. No way to set a timer like that, unfortunately, but you can instead set a local for specified duration - or at least I think that's what SR does to Glitterdust.

Link to comment

How do I check it like a global since it is creature dependent?

 

Like, what would a script snippet look like when a local is set and then checked. I'd love to be able to set local variables and check them. Like, if I equip a shield, I'd like to be able to script to see if player1 had a shield equipped. There is no way to do that unless you script for all instances of every shield. If you could set on equip a local variable and I could check it in baldur.bcs, that would be most excellent.

 

Sorry for ninjaing your thread. I am 39 and I said ninjaing.

Link to comment

To check locals from external scripts, you'll need NextTriggerObject(), otherwise it's not possible. It only exists in ToBEx so far, however SoD will feature it as well, once released.

 

I don't think you can detect a shield being equipped without new engine features anyway, though. When I played with Shield Bash ability, which I wanted SCS AI to use as well, I had to use ToBEx to patch all the shields to set a custom SHIELD_EQUIPPED stat.

 

PS Theoretically, you could check if offhand slot is occupied - HasItemSlot(), - but I don't know offhand (pardon the pun :D ) how/if it can be distinguished from offhand weapon.

Link to comment

...

Instead of:

IF
  Global("xxx","GLOBAL",1)
THEN ...
You just:

IF
  Global("yyy","LOCALS",1)
THEN...

To check locals from external scripts, you'll need NextTriggerObject(),

Yes, you probably could do that...

But I am quite sure there would be better things to do that use those for this.

Like said, one usually doesn't, cause there's no point to use locals for these.

Link to comment

Archived

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

×
×
  • Create New...