Skip to content

Improved scripts for your BG/BG2 playing experience

sarevok57sarevok57 Member Posts: 6,002
So a little while back I made a whole bunch of new scripts for the bg games, these scripts are better improvements over the ones available already ( since some of them will only cast/use select spells or abilities, or sometimes just bug out completely and don't work at all) I've tested out some of them so far, and its been a pretty good go, the range script though sometimes is a little tricky, but still works good enough I suppose

so here is a breakdown of whats of the scripts and what they do:

Melee
MeleeP
Range

- these 3 scripts here are for your main warrior type scripts ( fighters/paladins/rangers/monks and the like)
- the warriors will use their special abilities in combat, (berserk/defensive stance/lay on hands/stunning first/ etc..) and I've tried my best to make it so they use them at appropriate times ( for example: berserkers shouldn't be using their rage against gibberlings/kobolds ect)
- when it comes to ranger/paladin spells, I set it so they only cast their defensive spells, since I believe offensive spells for those classes are much more selective ( although if you want a more offensive spell casting ranger/paladin, you can use one of the cleric scripts below)
- also, if your characters have the special abilities like cure light wounds/slow poisons/vampiric tough, they will use those as well
- the melee option is for those who are planning on staying in melee
- the range option is for those who want to stay range and will stay range as much as possible ( although they will switch to a melee weapon if someone gets to close, although sometimes it doesn't work 100 % perfect)
- the MeleeP option is the same as melee, except that the character will use healing potions/antidotes/elixers of heath as well when needed

now things are going to get a little tricky, so I will try and make it as easy as possible to understand the caster ones, first of all there is going to a lot of abbreviations for all the different types, so I will go through them all here:

DIV- this is for all the characters that use divine spells ( clerics/druids/paladins/shamans/rangers)
MAG- this is for all the characters that use arcane spells ( mages/sorcerers)
BOTH- this is for cleric/mages or illusionist/mages of for characters that can cast both divine and arcane spells

so after one of the above abbreviations there will be some letters afterwards ( M,R,X,D,O,S) these letters represent what these casters will do, as I will explain as follows:

M - M means that once the character has finished casting their spell script ( or action list empty) they will resort to melee attacks

R - R means that once the character has finished casting their spell script ( or action list empty) they will resort to range attacks and prefer range combat

X - X refers to mages who have dispelling type spells ( breach, spell thrust, pierce magic, ect..) I have tried my best to make it so if your wizard has the appropriate dispelling spell, and they see an enemy that has a shield that they can dispel, then they should do it automatically, this applies to arcane casters only and dispel/remove magic are exempt because those spells can dispel beneficial spells to easily,

D - D refers to defensive magic, for clerics, this means that if your team mates hit below 51% health they will cast their most powerful healing spell on the most damage character first ( mass cure light wounds has first dibs) also, if your party members get poisoned/ diseased/ level drained/ etc.. and if your cleric has the appropriate spell memorized then your cleric will restore that character, again using the most powerful version first, then if there is nothing to heal/ restore, your cleric/mage will begin casting defensive spells on itself or the party

O - O refers to offensive spells, your caster will start casting at the highest level spell it has, and for sorcerers/shamans, it will cast crowd control spells before damaging spells, although I've done my best again, to make the AI smart enough that if a baddie is "held" for example your caster shouldn't still be casting "hold person" on it, but I have set it so your caster you will cast out to the nearest 6 enemies for crowd control, so be aware, this script also includes spells like fireball/death fogs/webs and the such, although again I have tried my best to make it so your caster will cast it when your party isn't to close to the badguys ( although its really tricky to make it work flawlessly) be aware, that this script will cast any offensive spell, so watch out for those radius ones, plus this script will also summon in monsters if you have summon spells memorize, but it will only summon 1, starting at the highest level

S - S this script refers to summoning spells, the caster will start at it's highest level summoning spells and keep on summoning until there is 5 summoned monsters ( although your caster will only do this if your caster sees an enemy) this will summon in any creatures except for : the mage elemental summoning spells/ and the demon summoning spells ( since those summons are unreliable) plus when it comes to summoning in planetars or divs, your caster will only summon in 1 since one is the limit

next, the placement of the abbreviations in the script will also determine priority, so for example:

lets say you are using the script; DIVMDO

- this means that your divine caster will prioritize defensive type spells over offensive type spells
- once the caster has run out of defensive and offensive spells, they will resort to melee attacks
- every caster script will either have an "M" or an "R" but even though they are first in the list, your castes will always resort to attack with a weapon last

lets say you are using the script: MAGRXDSO

- this means that your mage will use their shield dispelling spells as priority if they see the need to
- if no dispelling shields is needed, then the mage will begin casting defensive spells
- once the defensive spell casting is finished then the mage will start to summon up to 5 monsters if applicable
- once the monster summoning has finished, then the mage will resort to offensive spells
- if at any time one of your defensive spells depletes or becomes dispelled, your mage will recast defensive spells on itself when applicable
- if all spells are depleted/ completed, then the mage will resort to range weaposn

lets say you are using the script: BOTHDSO

- first priority is healing/curing/restoring type spells
- then mage protection spells
- then priest protection spells
- then your cleric/mage will summon in monsters starting at the highest level alternating between the mage/cleric list
- then if all protection spells are cast/complete, and all monsters are summoned the cleric/mage will begin casting offensive spells starting at their highest level, alternating between the cleric/mage list ( based on level of the spell)

NOTE:
- regardless of script, if you have any script active that deals with mage spells, your character will always have a stoneskin cast on itself at all times (if applicable) this also counts for ironskins as well
- if you have any divine defensive spell script in use, your divine caster will always have protection from evil 10' radius cast on your party at all times ( since this spell has a long duration and is incredibly useful to have on at all times)
- for those of you playing SoA be aware that your character WILL cast spells in town with these scripts on, so be careful about those stoneskins in town
- plus im pretty sure that no matter what script you have active, if your character has the detect traps/illusions option, they will always do that while idling


So with that being said, I think that is the jist of what these scripts do, as I said I play testes some of them, with a team that started in candlekeep and went all the way to the end of ToB and they worked pretty swell, if you have questions or comments please let me know, and hopefully you find these to be useful in your journeys
Post edited by sarevok57 on
«1

Comments

  • islandkingislandking Member Posts: 426
    Hello @sarevok57, first I want to thank you for your great scripts, it’s creative to sort them via abbreviations and clearly an improvement of the original ones.

    Then some suggestions, if I may :-)
    While it’s a common choice for a spellcaster dedicate himself to spellcasting, it’s more efferent if the spellcaster is able to use melee/ranged attacks in-between, which is specially the case for multis like f/m/t, who’s fairly safe to cast spells standing among enemy hordes with just some of protection spells active already. The game generally allows one spell per round, and some spells like Mirror Image, Magic Missiles are very fast casting, a f/m/t is able to utilize to remaining time frames within rounds for melee attacks, a mage with Throwing Daggers at hand can also attack from afar until the next round comes up so he’s able to cast the next spell in sequence. So if you can make this happen, your scripts will be improvements over Advanced AI as well.

    Next, some observations so far while I play testing:
    ~Manually direct a cleric/mage to use sling will block further spellcasting until other commands are given.
    ~An interrupted spell is considered cast, ie. If a mage gets interrupted while casting Mirror Image, he’ll no longer cast it and instead move on to his next spell in sequence.
    ~Only Melee, MeleeP and Range will active Detect Trap, all other casting AI don’t, at least for my f/m/t.
    ~Archer will use cleric spells, but not Called Shot.
  • mlnevesemlnevese Member, Moderator Posts: 10,214
    I think you have gone a good way into creating the successor of BP Party AI :) Good work.
  • sarevok57sarevok57 Member Posts: 6,002



    Then some suggestions, if I may :-)
    While it’s a common choice for a spellcaster dedicate himself to spellcasting, it’s more efferent if the spellcaster is able to use melee/ranged attacks in-between, which is specially the case for multis like f/m/t, who’s fairly safe to cast spells standing among enemy hordes with just some of protection spells active already. The game generally allows one spell per round, and some spells like Mirror Image, Magic Missiles are very fast casting, a f/m/t is able to utilize to remaining time frames within rounds for melee attacks, a mage with Throwing Daggers at hand can also attack from afar until the next round comes up so he’s able to cast the next spell in sequence. So if you can make this happen, your scripts will be improvements over Advanced AI as well.

    unfortunately this is something that would be very difficult to almost impossible to implement, I don't know if it will ever be possible to make the AI use weapons in between spell casting, because once the AI is set to attack, they PC will continue to use attack on it's target until target is destroyed



    ~Manually direct a cleric/mage to use sling will block further spellcasting until other commands are given.

    yeah, I've actually noticed this as well, but again I think it has something to do with the attack enemy command, force attacking enemies will override any script the PC has, ( I guess on just how the game is programed that physically attacking enemies cancels all other script actions) that's why now adays I never force attack enemies anymore ( meaning actually clicking on them when the sword cursor comes up) because my scripts are made that as soon as they see an enemy they will start doing their thing




    ~An interrupted spell is considered cast, ie. If a mage gets interrupted while casting Mirror Image, he’ll no longer cast it and instead move on to his next spell in sequence.

    now that is interesting, because mirror image has priority over everything ( except stone skin) to be cast, and if you don't have a mirror image on, it should be cast, it's also set to only be cast when an enemy is around, so im wondering if the enemy that is interrupting you is dying to quickly to be cast again, I will definitely have to tinker with that one


    ~Only Melee, MeleeP and Range will active Detect Trap, all other casting AI don’t, at least for my f/m/t.

    ah, this can be an easy fix, I must have forgot to give the spell casters the detect trap line of code to make them automatically find traps, so I will add that in to the caster's scripts



    ~Archer will use cleric spells, but not Called Shot.

    im looking at the called shot and I have scripted it to only work at certain times, I've made so all those special abilities ( rage, called shot, kai strike, offensive spin, ect...) to only activate when fighting "tougher" enemies, so if your fighting kobolds, gibberlings, bandits and such, your character wont be wasting good abilities on fodder, the list of enemies that a character's special abilities will be used on are as follows:

    Golem
    Mist
    Kuo-Toa
    Genie
    Githyanki
    Rakshasa
    Vampyre
    Ghoul
    Mind Flayer
    Dragon
    Denomic
    Beholder
    Umberhulk
    Myconid
    Vampire
    Lich
    Demilich
    Fairy
    Wraith
    Wight
    Spectre
    Wyvern
    Basilisk
    Ogre

    so based on that list, there is only a small handful of those enemies in BG1 ( if that is the game you are playing) so it may seem that the archer won't be using called shot as much because in BG1 the enemy selection is a bit weaker, and again based on IE's programming that "force attack" action could be overriding the script action so the archer wont use called shot until it's initial target is destroyed

    thanks for the suggestions/observations keep 'em coming :)

  • islandkingislandking Member Posts: 426
    @sarevok57 I was testing in BP, second arena battle, which is fighting healthy gibberlings:-) understand Archer's behaviors now.
    "Force Attack overridden" only happens to my sling using c/m, my melee f/m/t will still cast spell when the next round comes up.
  • sarevok57sarevok57 Member Posts: 6,002
    does your f/m/t kill the opponent with it's melee weapon? because how I think the engine works is that once you start to actually attack an opponent they will not go back to spell casting until either that opponent is destroyed or unless you manually start casting spells yourself
  • islandkingislandking Member Posts: 426
    edited April 2017
    @sarevok57
    Tested again, after one or two attacks, sometimes no attack at all due to plain Quarterstaff’s slow speed factor(still turn her face to the target though), my f/m/t will begin casting spells.
    Another note, Ghost Armor seems to have priority over Mirror Image in my case.
  • sarevok57sarevok57 Member Posts: 6,002
    are you using the mage script that has the defensive spell casting in it? ( so the script that has a "D") if so, maybe what I did was go in order from highest level spell to lowest when it comes to defensive, sometime Friday morning, im going to be taking a gander at my scripts and see if I can fix these issues
  • islandkingislandking Member Posts: 426
    Now that you mention it, yes, that is the case, seems to only happen with defensive spells.
  • sarevok57sarevok57 Member Posts: 6,002
    ah, then im thinking that is intentional behaviour, I just took a look at it, and I have it set that stoneskin is first, and then the caster will start casting their highest level protection spells first and work their way down
  • sarevok57sarevok57 Member Posts: 6,002
    so I've updated the scripts, all of them now will detect traps when the character is idle,

    I fixed berserker enrage ( since the character would keep trying to enrage while fatigued, now they won't any more)

    fixed the bigby spells ( I accidently had some unnecessary trigger command in there that was preventing them from casting)
  • KahenrazKahenraz Member Posts: 70
    Is it possible to not cast Larloch's Minor Drain from my innate spell list? I prefer to keep it saved as a clutch heal and not something to initiate with.

    Also, is there a way to prioritize debuffs before aggressive spells? For example, blind/sleep before magic missile/larloch's?
  • sarevok57sarevok57 Member Posts: 6,002
    @Kahenraz

    debuff spells should be casting first, I just looked at the spell cast list and all debuffs are before offensive damaging spells, what could be happening is that you targets are already blinded or sleeping since each debuff has a tag on it to not cast the same effect on itself, and once that is done it will go to the offensive damaging spells afterwards

    which scripts are you using?
  • KahenrazKahenraz Member Posts: 70
    edited April 2017
    I'm using MAGEMO on my gnome fighter/illusionist. He is casting his innate Larloch's Minor drain before Sleep. I had to remove Larloch's from the script entirely to get him to stop initiating with it.
  • sarevok57sarevok57 Member Posts: 6,002
    ah interesting, I didn't realize that I had the innate offensive abilities in the scripts as well, I thought I only had the defensive ones in there
  • KahenrazKahenraz Member Posts: 70
    I'm not familiar with the script but at first glance it doesn't look as if you can differentiate where the spell is memorized; innate or spellbook, etc.
  • KahenrazKahenraz Member Posts: 70
    edited April 2017
    Some further notes:

    * My character is casting defensive spells even though I initiated with Sleep and there are no conscious enemies.
    * When I sleep a group of mobs my character seems to want to run to and attack the sleeping enemy at the back of the group rather than the closest one next to me.
    * When there is only one enemy my character may open with something like Dire Charm instead of some other debuff or cast Dire Charm while in the middle of a fight on the mob that I'm attacking rather than some other mob with more health to assist.
  • sarevok57sarevok57 Member Posts: 6,002
    for the innate larloch minor drain it will be classified under spin103, instead of the wizard one spwi119

    is MAGEMO casting defensive spells? because the only one it should be casting is stoneskin ( with it's huge duration and amazing usefulness, hence the reason why I made every mage script have it) and your wizard will cast stoneskin even if there are no enemies in sight ( again because of it's huge duration)

    when it comes to being waken up by baddies, it could be because the script is set by whoever attacks them first that's who they go after, so if the guy in the back attacks first then your dude will go after that monster, but the script is also set that if someone closer attacks you then it should change over to the nearest attacker, sometimes the scripting in this game can be finicky

    I didn't put any HP parameters on the spells because I found that if I did that, more than half the time they just wouldn't cast them period, even if it was in their parameters to do so

    these offensive spell scripts are made to be "overkill casting mode" where they will first off all of their spells as much as possible ( although they shouldn't being using spells like hold person on undead for example) the reason why I have them set like this is because I was annoyed with the default scripts "waiting for the perfect time to use their spells" which basically translated into not using them at all
  • cddscdds Member Posts: 55
    edited February 2019
    Hey, just wanted to say thanks for these scripts, overall they work much better than the default "advanced" AI.
    The only problem i have is with the "Range" preset (as well as "R" caster presets after running out of spells and defaulting to ranged damage): the ranged scripts seem to try to spread out and the characters often run so far away, that they are effectively out of the attack range (or even into another room). The ranged characters then stand around idle because there is nothing in their attack range..
  • sarevok57sarevok57 Member Posts: 6,002
    hmm interesting, i haven't had that problem with the ranged scripts, how close are they getting to the enemy in combat? i have it set that if an enemy is too close that they should move out of melee combat but if they get trapped in melee they should switch to a melee weapon
  • Allanon81Allanon81 Member Posts: 349
    edited May 2019
    @sarevok57 I've had the same problem with the ranged script. The character goes too far, attacks that one enemy, and then becomes ineffective by standing around. Would be nice if maybe they moved away only a small /medium amount, and stayed effective by persuing any enemies in their line of sight or any party members LOS.
  • SchmooplesSchmooples Member Posts: 22
    I tried this, and I'm really loving the AI script, a lot. It makes running a party full of casters so much more manageable. However, I have run into a problem. I have a Sorcerer that will not stop spamming Time Stop. I'm fine if they cast Time Stop, but they keep casting it until all of the 9th level spells are gone.

    Also, I was wondering if you could make this compatible with Icewind Dale or make it compatible with mods that add IWD spells (Iwdification and SCS) to BG2?
  • sarevok57sarevok57 Member Posts: 6,002
    hmm, there must be a problem with the global timers on that one, i probably won't have time until sunday to really play around with it to see if i can get it to work better

    plus i noticed another mess up with the scripts on horrid wilting and it will only be cast if there are at least 6 baddies around, that i have fixed on my end for a couple of them, so i will have to redo those ones as well

    when it comes to IWD, you can actually use these scripts with IWD as well, but as you probably know, they will only work with the spells from BG 2, i have only one script that i personally use ( ultrar ) that i have put IWD spells into, but even with that, i only put the IWD spells that i use into it

    i dont know if i will make an IWD compliant script list like i did for the BG series, those scripts took a lot of time and effort to do, and i would basically have to redo them all to do it

    so worse case scenario, you can do what i did if you want to learn how to do it, and make the scripts the way you want to make them

    so first you will need;

    EE keeper

    Near Infinity

    with these 2 programs you can open the scripts up, and see how spells function and its basically copy paste, with the exception of changing the spell names to match what you want

    so say for example:

    lets look at the level 1 priest spell; Command ( from my custom scripts looking at it from NI in the IWD folder)

    IF
    ActionListEmpty()
    InParty(Myself)
    HaveSpell(CLERIC_COMMAND) // SPPR102.SPL (Command)
    See([EVILCUTOFF])
    !Race(LastSeenBy(Myself),ELF)
    !Race(LastSeenBy(Myself),DEMILICH)
    !Race(LastSeenBy(Myself),RAKSHASA)
    !Race(LastSeenBy(Myself),LICH)
    !General(LastSeenBy(Myself),UNDEAD)
    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !StateCheck(LastSeenBy(Myself),STATE_NOT_TARGETABLE)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
    !CheckStat(LastSeenBy(Myself),1,CLERIC_SHIELD_OF_THE_ARCHONS)
    !CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    CheckStatGT(LastSeenBy(Myself),0,SAVEVSSPELL)
    !CheckStatGT(LastSeenBy(Myself),0,CLERIC_CHAOTIC_COMMANDS)
    !CheckSpellState(LastSeenBy(Myself),76)
    !CheckSpellState(LastSeenBy(Myself),77)
    !CheckSpellState(LastSeenBy(Myself),78)
    !CheckSpellState(LastSeenBy(Myself),99)
    !CheckStat(LastSeenBy(Myself),4,WIZARD_SPELL_IMMUNITY)
    CheckStatLT(LastSeenBy(Myself),80,RESISTMAGIC)
    CheckStatLT(Myself,50,SPELLFAILUREPRIEST)
    !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    !StateCheck(Myself,STATE_SILENCED)
    THEN
    RESPONSE #100
    Spell([EVILCUTOFF],CLERIC_COMMAND) // SPPR102.SPL (Command)
    END

    we see, that there is a lot of stuff here, but its not as complicated as it looks, so lets dissect this a bit;

    IF

    all scripts start this way when it comes to scripts, so this is just a must

    ActionListEmpty()

    this is the command given to a character if they have finished the above scripts and have "nothing" left to do ( aka, when you make spell scripts they will go in order of scripts, so if you made an entangle script before your command script, it will cast entangle first, then command, you will see this pattern if you open up my scripts with Near Infinity )

    InParty(Myself)

    pretty self explanatory, this just means the character itself is going to be using this script

    HaveSpell(CLERIC_COMMAND) // SPPR102.SPL (Command)

    now this one is quite important, because this line checks to see if you ACTUALLY have the spell memorized or not, if you do not have it memorized then the script will not execute, plus this is the line you edit, when you want to add a new spell to your script ( aka when it comes time to add spells you are going to be doing a lot of copy pasting and at this part you will have to retype the "spell script name" - this is where EE keeper comes in handy because when you look up spells in EE keeper it tells you the script name, so for example if you wanted to change the cleric spell command to entangle instead you would just change the caps letters to:
    HaveSpell(CLERIC_ENTANGLE)
    since that is the entangle script name for entangle, if you want to change over to a wizard spell like magic missile, then you would change it as so:
    HaveSpell(WIZARD_MAGIC_MISSILE)
    the thing that is nice about using NI is that the lines are color coded so if all the colors come back when you finish the line, you know your script is correct, plus there is also a compile button that will tell you if you have any errors )

    See([EVILCUTOFF])

    this command makes it so as soon as this character sees a hostile creature the script will begin

    !Race(LastSeenBy(Myself),ELF)
    !Race(LastSeenBy(Myself),DEMILICH)
    !Race(LastSeenBy(Myself),RAKSHASA)
    !Race(LastSeenBy(Myself),LICH)

    now notice the ! in front of those lines, that means if that race IS NOT do the command ( in this case if the *last seen* race *is not* elf,demilich,lich ect )
    if there was no ! that would mean that race would HAVE to be seen for this to script to take effect, this also applies to the:

    !General(LastSeenBy(Myself),UNDEAD)

    same case scenario, since it has the ! that means as long as the last seen race IS NOT general undead

    !StateCheck(LastSeenBy(Myself),STATE_HELPLESS)
    !StateCheck(LastSeenBy(Myself),STATE_NOT_TARGETABLE)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TRAP)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_DEFLECTION)
    !CheckStatGT(LastSeenBy(Myself),0,WIZARD_SPELL_TURNING)
    !CheckStat(LastSeenBy(Myself),1,CLERIC_SHIELD_OF_THE_ARCHONS)
    !CheckStatGT(LastSeenBy(Myself),0,MINORGLOBE)
    !CheckStatGT(LastSeenBy(Myself),0,CLERIC_CHAOTIC_COMMANDS)
    !CheckStat(LastSeenBy(Myself),4,WIZARD_SPELL_IMMUNITY)

    okay, seeing some more familiar lines, again with the ! that means IS NOT, and you can see what those parameters are, things like; IS NOT helpless or not targetable, if there was no ! that would mean the enemy would have to be either helpless and not targetable for the effect to take place
    now for the spell states, its a little bit more complicated, but not to shabby, now we are seeing some GT and some 0s, first the GT means; GreaterThan, and the 0s means exactly what the mean 0, so for this spell to fire off the line shows that as long as the enemy DOES NOT ( from the ! ) have GT ( greater than ) 0 spell traps, spell deflection, spell turning, ect then continue the script

    CheckStatGT(LastSeenBy(Myself),0,SAVEVSSPELL)

    ah, now we dont have a ! this time, so that means if the actually stat of Save vs Spell ( what the SAVEVSSPELL at the end of the script dictates ) is GT than 0, continue the script, so what this translates to is if the enemy has a save vs spell of 1 or higher then the script will continue, but if the enemy has a save vs spell of 0 or lower, then the spell will not be cast,
    you can also change it for other saves so say for example if you wanted to make it do save vs death you would put it:
    CheckStatGT(LastSeenBy(Myself),0,SAVEVSDEATH)

    !CheckSpellState(LastSeenBy(Myself),76)
    !CheckSpellState(LastSeenBy(Myself),77)
    !CheckSpellState(LastSeenBy(Myself),78)
    !CheckSpellState(LastSeenBy(Myself),99)

    now these are caused from being originally made in BG 2 and being used in IWD, what is happening is that IWD does not recoginze state 76,77,78,99, so IWD is just using the place holder of the IDS of those lines, this is because BG 2 EE has more spell states than IWD, as far as i know the script will still work, but it just won't be able to recognize what those states are so the script will not execute those lines

    CheckStatLT(LastSeenBy(Myself),80,RESISTMAGIC)

    this is a magic resistance line, the command RESISTMAGIC is the script for magic resistance of a creature and the 80 is the value in which to execute, and since we see a LT ( less than ) this script means;
    if the creature has less than 80% magic resistance, continue to execute

    CheckStatLT(Myself,50,SPELLFAILUREPRIEST)

    this line checks for spell failure of the caster, as you can gather from the SPELLFAILUREPRIEST, and we have a value of 50 and a LT command again, so this script reads as;
    if the caster has Less Than 50% spell failure, continue the script, if the caster has 50% or more spell failure, then do not attempt the script

    !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    !StateCheck(Myself,STATE_SILENCED)

    and again, these are just 2 more state checks to make sure that if you DO NOT ( because of the ! ) have insect plague or silenced then continue the script

    So that covers the "conditions that need to be met first" now we need to execute:

    THEN

    this is the part that says; okay we have met the above criteria what do we do next? then you get;

    RESPONSE #100

    this is the part that says, what % chance does the following action have to execute, and since we want our spells to go off we would always make sure to have RESPONSE #100

    Spell([EVILCUTOFF],CLERIC_COMMAND) // SPPR102.SPL (Command)

    this, is a VERY important line because this is the actual spell you will be casting, and again it is based off of the script name of the spell, so for command we see that the script name is: CLERIC_COMMAND
    remember up above when i was talking about if you want to change command into entangle instead? and up above you changed the command to entangle? well down here you will have to do the same so the actual spell you have up top will match the one down here because this is the ACTUAL spell that will go off

    END

    and this is the final part to "finish" the script off so then it can be executed ( where the IF is the mandatory start, and END is the mandatory finish to complete the script ) all scripts must end this way

    so okay, we no doubt kind of got that figured out, so lets make a new script for an IWD spell like; sunscorch

    so first we can just copy the entire script of command from IF to END and paste it either before or after command ( if you do it before command, this spell will fire first before command if you have them both memorized, if you put it after, then it will fire after command if you have both spells memorized )

    and then realistically there are only 2 things we have to change in all that jargon;

    HaveSpell(CLERIC_COMMAND) // SPPR102.SPL (Command)

    Spell([EVILCUTOFF],CLERIC_COMMAND) // SPPR102.SPL (Command)

    so since the spell script of sunscorch is; CLERIC_SUNSCORCH ( thanks to EE keeper telling me from the spells tab )

    we just make the changes as follows;

    HaveSpell(CLERIC_SUNSCORCH) // SPPR102.SPL (Command)

    Spell([EVILCUTOFF],CLERIC_SUNSCORCH) // SPPR102.SPL (Command)

    * the lettering in the green you do not have to change because once you compile and save the script the stuff in the green will change on its own

    so after you have changed that script name to sunscorch like i mentioned above, press compile, and then hopefully there will be no errors ( if you get errors, you WILL have to fix them ) and then save, and the script will be good to go

    now at first this may seem a little bit overwhelming, but after awhile you will start seeing patterns on how things work and how things are said, and then it will start to make more sense to you

    and thanks to Near Infinity you can actually use the .IDS files to look at the stat.ids and state.ids to add even more CheckStat or StateCheck if you want to add some more in or change some around

    and after tinkering a bit, you will kind of get the hand of it ( it might even be better off if you start with a blank script so then you can customize each spell one by one and not have the possibility of having a million errors that you need to go change and fix, but its up to you )

    also the other reason why i gave this mini tutorial is just in case if i dont get back or have time to fix some of the errors that i have made and hopefully if people need be can just quickly go in a fix a couple of things and be on their way sort of thing, as you notice that some of these scripts can have up to almost 20 000 lines of code, hence the reason why i haven't made an official IWD version yet, that would take ages and doing this for free really puts it on the back burner sort of deal
  • gorgonzolagorgonzola Member Posts: 3,864
    Thank you for the mini tutorial.
    I personally dont trust in scripts, not even in yours ;) as i like to micromanage my parties at a level that scripts dont allow.
    But maybe in the future i will try to write some specific custom scripts, like one to have a bard sing and attack, ranged or mlee, in the same round, thing that in EE is almost impossible to do manually.
  • SchmooplesSchmooples Member Posts: 22
    Would say copying and pasting some of the scripts available in IWD presets into your scripts also work?
  • sarevok57sarevok57 Member Posts: 6,002
    Schmooples wrote: »
    Would say copying and pasting some of the scripts available in IWD presets into your scripts also work?

    as long as you compile it afterwards with no errors, then you should be good to go

    also as i stated before ( if you are using Near Infinity ) each script line is color coded, so if you accidentally leave out a ( or , or whatever then the line will be black, until you fix it
  • SchmooplesSchmooples Member Posts: 22
    I want to thank you again for all your hard work and help. I was able to get the Icewind Dale spells scripted by substituting them with the scripts you already made. I haven't run into any problems so far. However, I'm not quite sure how to script Emotion:Hope and Emotion:Courage. Would using the Stoneskin or Protection from Evil as template work for those spells?
  • sarevok57sarevok57 Member Posts: 6,002
    im going to go with yes, but the thing to watch out for, is if you have a sorcerer and dont have some sort of condition in there on when to stop casting the spell, they will just use up all their level 4 spells and cast it over and over again, now im thinking if you use something like this ( using the stoneskin script ) ;

    IF
    CheckStatLT(Myself,2,DAMAGEBONUS)
    HaveSpell(WIZARD_EMOTION_HOPE) // SPWI408.SPL (Stoneskin)
    CheckStatLT(Myself,50,SPELLFAILUREMAGE)
    !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    !StateCheck(Myself,STATE_SILENCED)
    THEN
    RESPONSE #100
    Spell(Myself,WIZARD_EMOTION_HOPE) // SPWI408.SPL (Stoneskin)
    END

    with this command hopefully because of the first line ( CheckStatLT(Myself,2,DAMAGEBONUS) ) once you get that +2 damage bonus it will not cast this spell over and over again now for the next one;

    IF
    CheckStatLT(Myself,3,DAMAGEBONUS)
    HaveSpell(WIZARD_EMOTION_COURAGE) // SPWI408.SPL (Stoneskin)
    CheckStatLT(Myself,50,SPELLFAILUREMAGE)
    !CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    !StateCheck(Myself,STATE_SILENCED)
    THEN
    RESPONSE #100
    Spell(Myself,WIZARD_EMOTION_COURAGE) // SPWI408.SPL (Stoneskin)
    END

    since emotion courage gives a +3 damage bonus we want to change it to 3 so then the emotion hope spell will still go off, although make sure to put emotion hope BEFORE emotion courage because if you do it the other way around, you caster will cast emotion courage first and now your damage bonus will be 3 and emotion hope will not go off

    and hopefully this will make it so if you have a sorcerer they wont just keep casting this spell over and over again, unfortunately i couldn't find any stats or states ( like the stoneskin one ) to make it so it for sure won't cast over and over again, so hopefully that damage bonus stat works

    super worse case scenario if its not working at all, you can just get rid of the damage bonus line and make sure you wizard just has one of each memorized, and do it that way, but im crossing fingers that the above will make it happen

    plus if you are savy enough, perhaps you might be able to find a script line or CheckStat or StateCheck that works, if so even better

    also, this script might interfere with the cleric buff spells ( due to the damage bonus line ), but luckily those cleric spells are cast in combat while this spell should automatically go off as soon as they are memorized, so there is that just in case you get any problems with that
  • SchmooplesSchmooples Member Posts: 22
    Thank you, so much! I tried your scripts using a Wizard, and I memorized multiple casts of Hope and Courage, and my Wizard only casted each spell once. It worked perfectly! Again, thank you so much.
  • sarevok57sarevok57 Member Posts: 6,002
    Schmooples wrote: »
    Thank you, so much! I tried your scripts using a Wizard, and I memorized multiple casts of Hope and Courage, and my Wizard only casted each spell once. It worked perfectly! Again, thank you so much.

    excellent to hear, looks like the damage bonus line is working, so if that is the scenario it should work for a sorcerer as well
  • BlaecBlaec Member Posts: 2
    Hello! New to the forums and reviewed this thread with interest as I have been looking for better AI Scripts! From what I am reading, these are exactly what I am looking for - thank you for your efforts!

    There are a LOT of posts in the forum and sorting through them isn't the easiest, but I have been trying to find out how to actually add the new scripts to the game and if they can be added to an existing installation (with saved games) or only new installations? If there is an existing thread with how install the file, that would be great (I am playing in Windows and currently unmodded - very little experience with modding).
Sign In or Register to comment.