Skip to content

Enhanced Powergaming Scripts v14.0

morpheus562morpheus562 Member Posts: 309
Introduction
This mod is a collection of player AI scripts designed for use in Baldur's Gate: Enhanced Edition, Baldur's Gate II: Enhanced Edition, the Enhanced Edition Trilogy, and Icewind Dale: Enhanced Edition. With these scripts, you can focus on the fighting aspect of combat while these take care of the nuances in the background. Of note, these scripts allow easy pre-buffing of all characters with a keystroke, take turns while healing to prevent overhealing, intelligent debuffing of enemy protections, and smart use of defensive spells and abilities. These scripts augment an existing player making choices without being overbearing.

You can download the latest release here.

Who Am I
I am a powergamer at heart constantly searching for the most efficient way to get through EET. Writing these scripts were a natural progression for me to improve my playstyle. According to Steam, I have over 1,900 hours of recorded playtime between BGEE and BG2EE, and I dread to know how much it really is since Steam doesn't register the decade plus I've played the original versions of these games before the EE was released. Needless to say, I really enjoy these games.

Why Did I Write These
You are right to ask why I'm releasing these when there are already so many AI scripts out there. To that I'd say you are correct because some of them are really good. I'd like to explicitly acknowledge Sarevok57's amazing scripts. I was dissatisfied with the scripts that the game offered and looked to better ones when I found Sarevok57's work. His scripts were really good; however, they didn't match my playstyle as well as I wanted. As a Computer Science major, I asked myself how hard can it be to make my own scripts? I used Sarevok57's scripts as a baseline and developed my own off of his work making updates and tweaks to most every area. With his blessing I am sharing these with you today.

Content
These scripts are focused on heavy physical damage parties in both melee and ranged. To me, spells are only there to protect me from enemy damage, enhance my physical damage, and strip the enemies of their spell protections. These scripts do everything to manage the minutiae of play, so the player can focus on other things. Specifically these:
  • Allow the player to pre-buff before any fight by pressing the "B" key. I hate pre-buffing, it is tedious to go through all spells and manually cast. Additionally, you have to check to ensure you cast long duration spells first and such. No bueno. Know what is bueno? Hitting the "B" key and watching all selected characters start pre-buffing. This is literally the "Easy Button" to buffing saving you time and allowing you to focus on what really matters. Characters will state when they begin pre-buffing and when they complete pre-buffing. If an enemy is sighted or the "B" key is pressed again, pre-buffing will cancel and the character will announce they were not able to complete the pre-buffing. Buffs will be cast with longest duration ones first moving to shortest duration. This takes all the guessing out of it.
  • Automatically using appropriate healing potions and antidotes in combat.
  • Automatic use of healing spells when out of combat. Focus is on casting the appropriate healing spell in relation to the amount of damage being healed (i.e. reduced overhealing). Additionally, characters using these scripts will take turns when healing to avoid overhealing.
  • Casting PfMW or Shield of Lathander (SCS IWD spell that acts as the Cleric version of PfMW) if health drops below a threshold.
  • Detecting Invisibility and intelligent debuffing of enemy protections.
  • Spells will not be cast in Wild Magic Areas, Dead Magic Areas, or in Athkatla when the licence to use magic is not purchased/Cowled Wizards are harassing you. The casting in Athkatla can be toggled on/off by pressing the "T" key in the event the player wants to fight the Cowled Wizards.
  • Intelligent use of equipment special abilities.
  • Only attack enemies that they have the capability to hit and damage. I toyed with the idea of making a more improved targeting system, but decided against it. I really dislike in other scripts if I am focusing on a target and the script reassigns my enemy to someone else.
  • Enemy threat rating calculations are done using enhanced functions offered by EEex. All visible enemies will be assessed and a threat rating determined which will assist the ai in determining if the encounter is difficult enough to warrant certain spell use. Enemy threat ratings are continually adjusted in combat and reset after a fight is completed. This means a fight may start off as a challenge, but later determined as no longer a challenge as enemies are removed. If EEex is not present, or only an older version is installed, then this feature is skipped.

Compatibility
If you are upgrading from an earlier version of this mod, I recommend uninstalling all mod components and replacing all files with the new ones before doing a fresh install.

If you are installing any of the below listed mods, they should be installed before this mod. Typically, I recommend to install my scripts at the very end of the mod install order.

As of version 0.9.0, these scripts utilize custom triggers from EEex (if installed). If EEex is not installed, the scripts will still function, just without the additional triggers. Please note: version 0.9.8 of EEex introduces additional functions that allow for enemy threat rating to be determined. If an older version of EEex is installed, this part will be skipped.

Baldur's Gate: Enhanced Edition, Baldur's Gate II: Enhanced Edition, and Enhanced Edition Trilogy

The mod has support for aTweaks, IWD spells (from either Sword Coast Stratagems or IWDification), Skills and Abilities, Sword Coast Stratagems, D5 Random Tweaks, Dark Side of the Sword Coast, Made in Heaven Spellpack and Itempack, Song & Silence, Tome & Blood, Faith & Powers, 5e Spellcasting, and for changes from Spell Revisions (Revised) and Item Revisions (Revised).

Before modding SoD games, it requires use of either DLCMerger or ModMerge (DLCMerger Preferred).

Icewind Dale: Enhanced Edition
This mod has support for Skills and Abilities.

Components
Below are the components for the install allowing you to pick and choose what changes you would like to see made. Each one will provide a prompt, so you can skip what you don't want.

Main Component
This is the main component that will auto-detect your mod installations and provide scripts based on the installs listed above. These can dynamically create over 1.5 MILLION scripts depending on what spell/kit mods you have installed. You will have the option to select having either pre-buffing cast at a normal speed or an accelerated speed. Regardless of either option chosen, characters will stop pre-buffing if either the "B" key or "N" key is pressed again or an enemy is sighted.

Normal Pre-Buffing Speed
It will take the normal casting time for a spell to be cast and there will be the standard delay between spells being cast. This is meant for the purists that do not want to bend the rules for expediency sake. For testing, it can take 2 1/2 minutes plus to cycle through all spells if you have all spells for pre-buffing in your spellbook.

Accelerated Pre-Buffing Speed
This is for people who walk on escalators and want to bend the rules a bit. Spells will be instantly cast and there will be no delay between spell castings. With this option, you may have spells active that would normally expire by the time normal pre-buffing ends. In effect, you may have certain spells active that you shouldn't. For testing, using the same spells as the Normal Pre-Buffing Speed testing, it took approximately 20 ~ 30 seconds to complete all pre-buffing. Just over a 2 minute decrease in time waiting for your characters to pre-buff.

Intelligent Enemy Debuffing
If an enemy has PfMW, Mantle, Improved Mantle, Absolute Immunity, or Shield of Lathander, the scripts will automatically get to work removing spell protections to take those down and allowing your fighters to do what they do best: putting the pointy end in the bad guy. The scripts use the minimum level spell necessary to strip spell protections, so you will not launch Spellstrike on an enemy when Secret Word will do (assuming you have Secret Word).

Intelligent Detection of Invisible Enemies
These are the most advanced scripts at detecting and countering invisible enemies. As soon as an enemy is detected that is invisible or stealthed, nomatter the means, characters will get to work using the appropriate spell to detect them. Many times, your characters will cast the appropriate detection spell before you even realize an invisible enemy is present. These are that advanced.

Item Usage
These scripts will utilize items such as Amulet of the Cheetah, Ilbratha+1, Ring of Duplication, Gargoyle Boots, Headband of the Devout, Girdle of Fortitude, Ring of Spell Turning, Cloak of the Stars, Cowl of the Stars, Belt of Minor Invulnerability, Cloak of the Dark Moon, and the Shield of Fyrus Khal. Additionally, these scripts will also assist in automatically swapping items in order to cast an items effect and then swapping back to the original item. This will be done seamlessly. For example, if you have either Gargoyle Boots or Boots of Speed equipped with the other item in your inventory, then the script will automatically swap items to equip the Gargoyle Boots, cast Stoneskin (if there is a charge), then swap back to the Boots of Speed. The player will not notice any item swapping from the game screen, but they will have a seamless casting of Stoneskin. This saves a lot of micromanagement to swap boots and cast Stoneskin. Similarly, Monks will similarly swap with Ilbratha+1 and the Scarlet Ninja-To (in the off-hand) in order to cast Mirror Images.

The Scripts
The scripts are now listed as Enhanced Powergaming Scripts listed under the previous Advanced AI option. Here, the player has the option to select multiple radial buttons to custom tweak the interaction the AI scripts have.

This script is designed for all classes with the ability to customize the character's action by adjusting the settings in the menu above. The character can use the following hotkeys with this script:
  • Cast pre-buffing spells when the 'B' key is pressed
  • Cast long duration buffing spells when the 'N' key is pressed
  • Toggles on and off to cast spells in Athkatla if the character has not paid the bounty or finished fighting the Cowled Wizards when the 'T' key is pressed
  • Swaps the between melee and ranged weapons so long as either can be equipped when the 'E' key is pressed
  • Swaps between solo and party buffing when the 'K' key is pressed
  • Swaps between the various skill modes when the 'V' key is pressed

For lack of a better term, there can be some inherent wonkiness when initially setting up advanced ai on a character. If the scripts are not working for a character and you have ensured the AI lantern is on, then follow these steps:
  • Set the character's AI scripts to "None", save the setting, and go back to the game screen.
  • Go back into the script page and set the AI to "Enhanced Powergaming Scripts".
  • Save the setting and go back to the game screen.
  • Go into the character records page and verify the assigned script is "bddefai".
  • You should now be all set. Follow the above steps for each character, one character at a time.

Advanced AI script options:
  • Attack Enemies - The character will attack enemies on sight.
  • Solo Buffing - The character will only focus on buffing themself during pre-buffing. For example: The character will only use Improved Haste on themself instead of other members in the party.
  • Group Buffing - The character will buff fellow party members in addition to themself during pre-buffing. For example: The character will use Improved Haste on themself AND other members in the party.
  • Use Items - The character will use items such as potions.
  • Enemy Debuffing/Curative/Healing - The character will use debuffing spells against enemies, curative spells to remove enemy debuffs on themself and allies, and healing spells. The spells used include Breach, Ruby Ray of Reversal, True Sight, Remove Paralysis, Raise Dead, and Heal.
  • Use Offensive Spells - The character will use offensive spells such as Sunray, False, Dawn, Insect Plague, and Greater Malison.
  • Use Defensive Spells - The character will use defensive spells such as Mirror Image or Stoneskin.
  • Find Traps in Combat - The character will constantly search for traps and illusions, even when in combat. Please Note: if a character is capable of finding traps, these ai scripts will already have the character use this ability when outside of combat. This option is to constantly force the character to find traps, even when in combat.
  • Hide in Shadows - The character will hide in shadows when idle.
  • Sing Bard Song - The character will sing a bard song.
  • Turn Undead - The character will constantly turn undead.

Install Enhanced Scripts for Summoned Celestials
This provides enhanced ai scripts for celestials. Overall, the scripts allows the player to be more hands off with summoned celestials, and they will act intelligently in targeting enemies. Like the other scripts listed above, this script will cast pre-buff spells when the "B" key is pressed. Spell Revisions also rewrote their spellbooks, and the scripts will accommodate these changes.

Install Enhanced Scripts for Simulacrums
This provides enhanced ai scripts for summoned Simulacrums allowing the player to be more hands off while the Simulacrums will act intelligently in targeting enemies, casting protection spells, detecting invisible/hidden enemies, debuffing enemy protections, and capable of pre-buffing! The Simulacrum will work with all of the hotkeys offered in my scripts.

ini File
The ini file allows players to customize certain settings to their preference.

Hotkeys
Type in the hotkey you wish to map to the corresponding action.
  • hot_key_Buffing - Default "B" - toggles the key to begin and cancel pre-buffing.
  • hot_key_LongBuffing - Dafualt "N" - toggles the key to begin and cancel buffing long duration buffs.
  • hot_key_CowledCheck - Default "T" - toggles on and off to cast spells in Athkatla if they have not paid the bounty or finished fighting the Cowled Wizards.
  • hot_key_WeaponSwap - Default "E" - swaps the between melee and ranged weapons so long as either can be equipped.
  • hot_key_SoloBuff - Default "K" - swaps between solo and party buffing. This allows you to have some characters buff everyone in the party, while other characters (such as sorcerers) will not burn through their spells on the party if they are set to solo buff.
  • hot_key_SwapSkills - Default "V" - swaps between the various skill modes: no special skill use, find traps, hide in shadows, singing, and turn undead.

Script Tweaks
This allows the player to fine-tune aspects of the scripts. 1 turns the feature on while 0 turns it off.
  • script_dialog is defaulted to 1. This turns on or off hover text appearing when certain abilities are used in combat.
  • fast_healing is defaulted to 0. This turns on or off instant casting of healing spells to speed up the healing process when out of combat.

Final Note
I hope you all enjoy these as much as I enjoyed making them. A lot went into these and I believe they offer quite a lot that no other scripts do. Final thank you to Sarevok57 for all of his work with his improved scripts.
Post edited by morpheus562 on
«13456

Comments

  • FlashburnFlashburn Member Posts: 1,847
    If the Archer has Gargoyle Boots, he will keep up stoneskins so long as there is an active charge on the boots. This next part I am particularly proud of: if you have either Gargoyle Boots or Boots of Speed equipped with the other item in your inventory, then the script will automatically swap items to equip the Gargoyle Boots, cast stoneskin (if there is a charge), then swap back to the Boots of Speed. The player will not notice any item swapping from the game screen, but they will have a seamless casting of stoneskin. This saves a lot of micromanagement to swap boots and cast stoneskin. The Archer will use mirror image from either offhand Ilbratha or Ring of Duplication whenever more than three enemies appear or a certain type of difficult enemy appears.
    That is NICE!
  • morpheus562morpheus562 Member Posts: 309
    edited January 2021
    Good day everyone! I am currently in the process of updating the scripts with improved detection of invisible creatures (True Sight, True Seeing, Detect Invisibility, and Invisibility Purge) and some other additions. What is currently in the scripts works, but it is pretty basic. These improvements I am working on will be more robust at using these detection spells than anything available that I've seen, and I am really excited to get these out to all of you after some additional testing on my end. The code available does not make this easy, so I'm having to get a little creative with it.

    Additionally, in the next release I am thinking of either releasing a script for Monk (any kit) or Skald. Please let me know if there is a preference to one or the other. Thank you and enjoy!

    Post edited by morpheus562 on
  • Adam_en_tiumAdam_en_tium Member Posts: 99
    Hello,

    Thanks for sharing your scripts. They seem to be very cool !
    Unfortunately I'm way too busy to play BG/BG2 for a couple of months, so I can't test them.

    I have a question : you haven't done scripts for thieves. Is it by lack of time, interest or just you don't think it would be useful ?

    Monk or Skald ? Skald !
  • morpheus562morpheus562 Member Posts: 309
    Hello,

    Thanks for sharing your scripts. They seem to be very cool !
    Unfortunately I'm way too busy to play BG/BG2 for a couple of months, so I can't test them.

    I have a question : you haven't done scripts for thieves. Is it by lack of time, interest or just you don't think it would be useful ?

    Monk or Skald ? Skald !

    Skald it will be. They bring a lot of bard specific items, so it will be interesting getting it all scripted out.

    As for thieves, it is never a class I was able to run right. Any builds I made were never as powerful nor had equivalent damage output as other builds. I don't use traps and backstabbing isn't my jam. The only reason I bring one around anymore is to pick locks and disarm traps. If someone is able to get the skald to do those, then I will be eternally grateful.

    The FigMage script will constantly be detecting traps if you are running a FMT (my go-to thief build). I'll take a look at the ClerRang script to have it constantly detect traps if using it for a Cleric/Thief. Otherwise, that's really the extent I use thieves for.
  • jmerryjmerry Member Posts: 3,881
    With backstabbers, I'm not sure any AI script could really capture the methods of play. I've done a lot of backstabbing, and I tend to set the AI to not automatically attack so that I can choose my targets better. Also, there's probably no way to get the AI to actually move behind targets; enemies cheat and stab you in the front.
    When I go for strike and retreat repeated backstabbing, that's full control mode. I'll have auto-hide on, but that's all the AI gets to do for me.

    The Detect Illusion skill is very useful in combat; being able to have that mode on while auto-attacking would be a nice quality-of-life improvement. As it is with the standard AI, you have to issue an attack order and then activate detection mode, refreshing that every time you switch targets.

    Other thief skills such as disarming traps, opening locks, picking pockets, and setting traps are generally done outside of combat and don't need AI help. Issuing explicit orders is fine.

    Incidentally, the vanilla AI block for automatically using bard song leaves quite a bit to be desired. It only activates when you see an enemy, rather than starting up even when no enemies are in sight so that it will be active when the action starts. I've tweaked that in my own game to always activate unless the bard is invisible. It still takes priority over auto-attacks.
  • morpheus562morpheus562 Member Posts: 309
    edited January 2021
    jmerry wrote: »
    With backstabbers, I'm not sure any AI script could really capture the methods of play. I've done a lot of backstabbing, and I tend to set the AI to not automatically attack so that I can choose my targets better. Also, there's probably no way to get the AI to actually move behind targets; enemies cheat and stab you in the front.
    When I go for strike and retreat repeated backstabbing, that's full control mode. I'll have auto-hide on, but that's all the AI gets to do for me.

    The Detect Illusion skill is very useful in combat; being able to have that mode on while auto-attacking would be a nice quality-of-life improvement. As it is with the standard AI, you have to issue an attack order and then activate detection mode, refreshing that every time you switch targets.

    Other thief skills such as disarming traps, opening locks, picking pockets, and setting traps are generally done outside of combat and don't need AI help. Issuing explicit orders is fine.

    Incidentally, the vanilla AI block for automatically using bard song leaves quite a bit to be desired. It only activates when you see an enemy, rather than starting up even when no enemies are in sight so that it will be active when the action starts. I've tweaked that in my own game to always activate unless the bard is invisible. It still takes priority over auto-attacks.

    Yea, backstabbing builds and sorcerers seem to be done by players who want to micro every aspect of play. My scripts are made to reduce most of the micro where backstabbers and sorcerers want to control every aspect of it. No wrong answer here. The game allows people to play how they want and that is awesome. As such, I don't think I'll be investing the time on either of those since the scripting will probably end up getting weird if it will perform "smartly". Thieves to me are just a quality of life improvement and having them constantly search for traps while out of combat is perfect for my needs.

    For my skald script, I tested the option to toggle if the skald will sing in and out of combat by using a keystroke; however, it just makes sense to always sing unless performing another action. As such, I removed this feature and honestly view this class as a song bot with the ability to strip the enemy of their spells protections.
    Post edited by morpheus562 on
  • morpheus562morpheus562 Member Posts: 309
    edited January 2021
    I wanted to post specifically what I am doing to improve invisibility detection and the thought process going behind what is actually happening. There is scripting documentation out there for reference, but I feel a lot of it is outdated, incomplete, or doesn't do the best of jobs saying the "why" and "how" things actually work. More testing needs to occur on my end to determine if these actually do what I want and go live, but so far the results are promising. I will update this post once these go live and include any updates/changes that I made along the way. The code below is specifically from the FigMage script; however, much of it is the same being carried over to the other scripts with only slight edits because Clerics and Inquisitors each use their own unique version of True Sight/Seeing.

    One of the earlier challenges I had was determining if anyone in my party had True Sight cast. Last thing I want is to cast True Sight on myself and the person next to me already has it up. I attempted running a manual check on myself and all of my nearest party members to see if they had True Sight active; however, this always failed (and was frankly an inefficient use of code). To get around this, I decided to run one global variable for the party "MOR_PartyTrueSight" with 0 meaning it is not active and 1 meaning someone has it. I also setup a local variable "MOR_TrueSightActive" to determine which specific character had it active: 0 meaning the character does not have it while 1 means they do have True Sight active.

    This checks if "MOR_TrueSightActive" is showing true but is no longer active on the character. If this is true, it will reset both "MOR_TrueSightActive" and "MOR_PartyTrueSight" to 0.
    IF
    	Global("MOR_TrueSightActive","LOCALS",1)
    	CheckStat(Myself,0,TRUE_SIGHT)
    THEN
    	RESPONSE #100
    		SetGlobal("MOR_TrueSightActive","LOCALS",0)
    		SetGlobal("MOR_PartyTrueSight","GLOBAL",0)
    END
    

    This checks if "MOR_TrueSightActive" is not active; however, my character actually has it. If this is true, it will set both "MOR_TrueSightActive" and "MOR_PartySightTrue" to 1. This check is very important if the player manually casts True Sight so the scripts behave correctly.
    IF
    	Global("MOR_TrueSightActive","LOCALS",0)
    	CheckStatGT(Myself,0,TRUE_SIGHT)
    THEN
    	RESPONSE #100
    		SetGlobal("MOR_TrueSightActive","LOCALS",1)
    		SetGlobal("MOR_PartyTrueSight","GLOBAL",1)
    END
    

    So this is the first actual check to determine if True Sight should be cast. This specifically determines if the enemy [EVILCUTOFF] cast any of the following spells in the prior round: Project Image, Simulacrum, Mislead, Shadow Door, Improved Invisibility, or Invisibility. The script will cast True Sight if all of the following are true: the enemy cast any of those spells listed, I have the spell True Sight available to cast, the enemy is not protected from Spell Immunity: Divination, no one in the party has True Sight active, and finally I am able to actually cast the spell. When casting True Sight, the script will set "MOR_TrueSightActive" and "MOR_PartyTrueSight" to 1.
    IF
    	IfValidForPartyDialog(Myself)
    	HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    	OR(6)
    		SpellCast([EVILCUTOFF],WIZARD_PROJECT_IMAGE)  // SPWI703.SPL (Project Image)
    		SpellCast([EVILCUTOFF],WIZARD_SIMULACRUM)  // SPWI804.SPL (Simulacrum)
    		SpellCast([EVILCUTOFF],WIZARD_MISLEAD)  // SPWI607.SPL (Mislead)
    		SpellCast([EVILCUTOFF],WIZARD_SHADOW_DOOR)  // SPWI505.SPL (Shadow Door)
    		SpellCast([EVILCUTOFF],WIZARD_IMPROVED_INVISIBILITY)  // SPWI405.SPL (Improved Invisibility)
    		SpellCast([EVILCUTOFF],WIZARD_INVISIBILITY)  // SPWI206.SPL (Invisibility)
    	!CheckStat([EVILCUTOFF],3,WIZARD_SPELL_IMMUNITY)
    	Global("MOR_PartyTrueSight","GLOBAL",0)
    	CheckStatLT(Myself,20,SPELLFAILUREMAGE)
    	!StateCheck(Myself,STATE_SILENCED)
    	!CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    	!CheckSpellState(Myself,WILD_MAGIC_AREA)
    	!CheckSpellState(Myself,DEAD_MAGIC_AREA)
    THEN
    	RESPONSE #100
    		SetGlobal("MOR_TrueSightActive","LOCALS",1)
    		SetGlobal("MOR_PartyTrueSight","GLOBAL",1)
    		SetInterrupt(FALSE)
    		Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    		SetInterrupt(TRUE)
    END
    

    This next part required lots of trial and error to determine how the Detect() check actually works and what it does. Detect() can find hidden enemies through sight or sound; however, the only check it can do is against [EVILCUTOFF]. Attempts to use NearestEnemyOf(Myself) failed because NearestEnemyOf() only returns true if the target is visible. The whole point for these scripts is the target is NOT visible. The LastSeenBy(Myself) is set by the target identified in Detect([EVILCUTOFF]). This is really good if there are thieves hidden that are attempting to backstab your characters or the enemy went invisible offscreen/prebattle and the check above didn't catch it. If I detect an enemy, I am checking to see if they have Improved Invisibility, Invisible (either through Invisibility spell/potion or stealth), or Sanctuary cast or if the target is an illusionary creature type. The script will cast True Sight if all of the following are true: the enemy cast any of those spells listed, I have the spell True Sight available to cast, the enemy is not protected from Spell Immunity: Divination, no one in the party has True Sight active, and finally I am able to actually cast the spell. When casting True Sight, the script will set "MOR_TrueSightActive" and "MOR_PartyTrueSight" to 1.
    IF
    	IfValidForPartyDialog(Myself)
    	HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    	Detect([EVILCUTOFF])
    	OR(4)
    		StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    		CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    		Gender(LastSeenBy(Myself),ILLUSIONARY)
    	!CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
    	Global("MOR_PartyTrueSight","GLOBAL",0)
    	CheckStatLT(Myself,20,SPELLFAILUREMAGE)
    	!StateCheck(Myself,STATE_SILENCED)
    	!CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    	!CheckSpellState(Myself,WILD_MAGIC_AREA)
    	!CheckSpellState(Myself,DEAD_MAGIC_AREA)
    THEN
    	RESPONSE #100
    		SetGlobal("MOR_TrueSightActive","LOCALS",1)
    		SetGlobal("MOR_PartyTrueSight","GLOBAL",1)
    		SetInterrupt(FALSE)
    		Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    		SetInterrupt(TRUE)
    END
    

    So this next part goes against what I said in my previous Detect() check verbiage above, and I have my reasons. There are times when a target is "invisible", but the game can see them. For example, an enemy has Improved Invisibility active and started casting. At this point, my characters can see the Improved Invisible enemy and even attack them; however, I am not able to cast a spell against the enemy until Improved Invisibility is removed. Additionally, you can see enemies with Sanctuary cast. This next bit is basically the same as above, but I am doing a different check type using See() instead of Detect(). I am also cycling through the six nearest enemies to my character (I am showing only one instance of this for the sake a brevity) to ensure that I am not missing anybody.
    IF
    	IfValidForPartyDialog(Myself)
    	HaveSpell(WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    	See(NearestEnemyOf(Myself))
    	OR(4)
    		StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    		CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    		Gender(LastSeenBy(Myself),ILLUSIONARY)
    	!CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
    	Global("MOR_PartyTrueSight","GLOBAL",0)
    	CheckStatLT(Myself,20,SPELLFAILUREMAGE)
    	!StateCheck(Myself,STATE_SILENCED)
    	!CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    	!CheckSpellState(Myself,WILD_MAGIC_AREA)
    	!CheckSpellState(Myself,DEAD_MAGIC_AREA)
    THEN
    	RESPONSE #100
    		SetGlobal("MOR_TrueSightActive","LOCALS",1)
    		SetGlobal("MOR_PartyTrueSight","GLOBAL",1)
    		SetInterrupt(FALSE)
    		Spell(Myself,WIZARD_TRUE_SIGHT)  // SPWI609.SPL (True Sight)
    		SetInterrupt(TRUE)
    END
    

    I will finally use Detect Invisibility (or Invisibility Purge for Clerics) if True Sight is not available. This covers lower level parties that do not currently have access to True Sight or if all uses of True Sight have been expended. This is similar to the Detect() section above, except it is checking if the enemy has Improved Invisibility, Invisible (either through Invisibility spell/potion or stealth), or Sanctuary. The script will cast Detect Invisibility if all of the following are true: the enemy cast any of those spells listed, I have the spell Detect Invisibility available to cast, the enemy is not protected from either Non-Detection or Spell Immunity: Divination, no one in the party has True Sight active, and finally I am able to actually cast the spell.
    IF
    	IfValidForPartyDialog(Myself)
    	HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    	Detect([EVILCUTOFF])
    	OR(3)
    		StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    		CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    	!StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
    	!CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
    	Global("MOR_PartyTrueSight","GLOBAL",0)
    	CheckStatLT(Myself,20,SPELLFAILUREMAGE)
    	!StateCheck(Myself,STATE_SILENCED)
    	!CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    	!CheckSpellState(Myself,WILD_MAGIC_AREA)
    	!CheckSpellState(Myself,DEAD_MAGIC_AREA)
    THEN
    	RESPONSE #100
    		SetInterrupt(FALSE)
    		Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    		SetInterrupt(TRUE)
    END
    

    So this is the same as casting True Sight above with See() instead of Detect(). Same checks and conditions for casting Detect Invisibility. I am also cycling through the six nearest enemies to my character (I am showing only one instance of this for the sake a brevity) to ensure that I am not missing anybody.
    IF
    	IfValidForPartyDialog(Myself)
    	HaveSpell(WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    	See(NearestEnemyOf(Myself))
    	OR(3)
    		StateCheck(LastSeenBy(Myself),STATE_IMPROVEDINVISIBILITY)
    		StateCheck(LastSeenBy(Myself),STATE_INVISIBLE)
    		CheckStatGT(LastSeenBy(Myself),0,SANCTUARY)
    	!StateCheck(LastSeenBy(Myself),STATE_NONDETECTION)
    	!CheckStat(LastSeenBy(Myself),3,WIZARD_SPELL_IMMUNITY)
    	Global("MOR_PartyTrueSight","GLOBAL",0)
    	CheckStatLT(Myself,20,SPELLFAILUREMAGE)
    	!StateCheck(Myself,STATE_SILENCED)
    	!CheckStatGT(Myself,0,CLERIC_INSECT_PLAGUE)
    	!CheckSpellState(Myself,WILD_MAGIC_AREA)
    	!CheckSpellState(Myself,DEAD_MAGIC_AREA)
    THEN
    	RESPONSE #100
    		SetInterrupt(FALSE)
    		Spell(Myself,WIZARD_DETECT_INVISIBILITY)  // SPWI203.SPL (Detect Invisibility)
    		SetInterrupt(TRUE)
    END
    

    These checks are pretty all encompassing, and I have not seen any scripts as robust as this one to detect and handle invisible enemies. I am still testing and fine tuning, but it seems to work how I want it to. I want to specifically note that similar scripts cast True Sight if Mirror Image is detected on the enemy which is an approach I personally disagree with. For these scripts, the order they are written in matter. As such, I choose to detect and remove invisibility before getting into dispelling enemy protections (i.e. PfMW, Mantle, Absolute Immunity, etc.). If, for example, an enemy has PfMW and Mirror Image both active and they are not invisible, I do not want to spend time removing Mirror Image with True Sight when I should instead be working to bring PfMW down ASAP. Similarly, if an enemy has only Mirror Image active, I do not want to waste a True Sight spell when I can just hit them repeatedly with my six characters that will each have anywhere from 4.5 - 10 APR depending on what spells/abilities are active. From an efficiency standpoint, I do not see any instance where using True Sight to remove Mirror Images will be beneficial.

    If this type of explanation is helpful for new or experienced scripters, I am happy to do similar reviews on other areas of my scripts. I think the more knowledge in the community the better.
    Post edited by morpheus562 on
  • morpheus562morpheus562 Member Posts: 309
    edited February 2021
    Version 1.1 is now available, and with it a number of updates and tweaks (to include the Skald script)! I am really pleased with how detecting invisible creatures and casting the appropriate detection spell turned out. It works even better than I expected it to.

    Edit to remove these instructions to update the action.ids file since weidu does this for you.
    Post edited by morpheus562 on
  • EndarireEndarire Member Posts: 1,519
    @morpheus562
    What say you to adding the ability to account for these mods which add spells?
  • morpheus562morpheus562 Member Posts: 309
    Endarire wrote: »
    @morpheus562
    What say you to adding the ability to account for these mods which add spells?

    Always looking to improve upon these scripts. Are there spells from a particular package that you are referring to or generally all of the mods you listed?
  • EndarireEndarire Member Posts: 1,519
    edited February 2021
    @morpheus562
    Since I intended to use all or close to all of these, I meant all of these spells. In general, the more spells in a mod, the more interested I am in having scripts to auto-handle their casting. Warlocks (at-will casters) are especially in need of proper scripts. Note that The Darkest Day has spells listed at that link but wasn't on my part of the list.

    Do you also account for not casting in Athkatla to avoid provoking the Cowled Wizards?

    If Spell Revisions is installed, do you account for those spell versions?

    Thankee!
  • morpheus562morpheus562 Member Posts: 309
    edited February 2021
    @Endarire I'm currently doing a playthrough to test out a few more scripts for when I release version 1.2. Aiming to release next week. It will include Monk and FMC (C/M) scripts and various other improvements. I can look at adding those spells for version 1.3 release, but I don't have a timetable when that will be.

    I like the idea of doing Athkatla spellcasting checks since they are not currently included. I just need to hunt down what variable changes when you buy the license. Is this strictly on mage only spells? Can clerics/druids cast in Athkatla without the cowled wizards getting upset? What about innate abilities? I think this is very doable to include in the next release.
  • EndarireEndarire Member Posts: 1,519
    To my understanding, all spells and items that cast spells (wands, scrolls, etc.) count. This is intentional.

    I also request checking for wild magic and no magic zones to determine if the area is safe to cast in. If not, don't auto-cast. (There may be various flags for this to allow this stuff to work in mods, meaning specific area codes alone aren't enough.)

    My most urgent request is to add an option to make all prebuffs instant cast. SCS prebuffed foes do it, and it may be a 'cheat' for a player, but I have better things to do than watch my team spend hours or more of my real time buffing over the course of a run. (I quit BGII for years because of needing to buff a team of 6.)
  • morpheus562morpheus562 Member Posts: 309
    @Endarire
    Scripts will automatically detect and not cast in wild magic and dead magic zones. This has been included since day one. Athkatla should be similar, and I imagine easy to add.

    I hear you on the pre buffing all at once with one click. The problem I ran into when I first looked at instant casting is the casting level of the player is ignored. All spells are cast at their lowest levels meaning less layers of stone skin, less mirror images, and less time up for all of the other protection spells. Not a good trade off for a little bit of saved time. Is the current way perfect and exactly how I want it? No, I'd prefer instant too. However, it's current state is the best the system will allow me to be and it is infinitely better than manually having to do everything.
  • morpheus562morpheus562 Member Posts: 309
    @Endarire
    Now I remember why I didn't do the Athkatla magic license check sooner. The problem is not detecting if I have the license (it is global variable BRIBEDCOWLED with a value of 1 for those interested). The problem is detecting if I am in a location where the Cowled Wizards enforce. If I do spellcasting solely off the check to see if the player has the license, then there will be no spellcasting in all of BGEE and until BG2EE when the license is purchased. I just need to determine a way to have an additional check if I am in Athkatla and how intrusive that would be. I have some ideas, but need to spend some time playing around with them to see if they are feasible.
  • jmerryjmerry Member Posts: 3,881
    The problem I ran into when I first looked at instant casting is the casting level of the player is ignored.
    There are multiple instant-casting modes supported by the game. Mode 2 casts at a level specified in another field - which, if you didn't set it, will be zero. Mode 1 uses the creature's caster level. NI has slightly confusing names here, calling mode 1 "cast instantly (ignore level)" and mode 2 "cast instantly (at level)".

    Athkatla casting ... there's a short list of areas that it applies to. And they're conveniently listed in certain blocks in some of the NPC scripts that are already in the game. For example, here's a block from Jan's combat script:
    IF
    	Global("BDAI_NO_ARCANE","LOCALS",0)
    	Global("BribedCowled","GLOBAL",0)
    	ActionListEmpty()
    	InParty(Myself)
    	AreaType(OUTDOOR)
    	OR(7)
    		AreaCheck("AR0020")
    		AreaCheck("AR0300")
    		AreaCheck("AR0400")
    		AreaCheck("AR0500")
    		AreaCheck("AR0700")
    		AreaCheck("AR0900")
    		AreaCheck("AR1000")
    THEN
    	RESPONSE #100
    		SetGlobal("BDAI_NO_ARCANE","LOCALS",1)
    END
    

    This and related blocks, so he won't autocast Stoneskin the moment he joins you and bring the Cowled Enforcers down on you.

    And as for BGEE? You don't have to use the same script for both games. And if it's a trilogy version, then area codes will be different anyway. You'll definitely need to detect which game the scripts are being installed for to make appropriate edits.

    Only mage spells call the enforcers. Most items won't cause you trouble; they'll only do it if they actually, directly, cast a mage spell. Wands of fear, magic missiles, paralyzation, fire, frost, lightning, sleep, polymorphing, monster summoning, heavens, cloudkill, spell striking, and cursing are all safe (in the standard game).
    One item that will do it is the ring of air control - that casts mage Improved Invisibility.
  • EndarireEndarire Member Posts: 1,519
    edited February 2021
    @morpheus562
    What about using the area codes of the outdoor areas to determine Athkatla casting? If the group has a license has beaten the Cowled Wizards into not bothering them anymore about in-town casting, they're free to auto-cast. (Some mods also make casting inside Athkatla structures to summon Cowled Wizards, but that's a secondary concern.) Note the map names for Athkatla in BG2 and EET are likely different. I recommend talking with the Gibberlings3 Forum people about this.

    To clarify regarding instant pre-buffing, I meant out of combat only for the instant speed.
  • morpheus562morpheus562 Member Posts: 309
    @jmerry @Endarire
    Thank you! I'll take a look into the different auto casting modes because that will definitely be useful. The script I created to test not casting in Athkatla without the license is almost identical to that, so I'm happy I'm on the right track. I have another block to check if the players leave the Athkatla area and can cast again without the license. I'll also see if there is another global to track of the player had the two fights with the cowled wizards and will be left alone going forward. So expect this to be in the next release.
  • jmerryjmerry Member Posts: 3,881
    The variable for tracking the Cowled Enforcer fights is CowledWarning. Starts at zero, increments by 1 after each time they come. You fight generic enforcers at 1-5, then the high-level bunch at 6. After that, it goes up to 7 and the block to summon the first enforcer turns off. (It tests for CowledWarning < 7)
  • EndarireEndarire Member Posts: 1,519
    @morpheus562 @jmerry
    Thankee and alleluia!
  • EndarireEndarire Member Posts: 1,519
    @morpheus562
    Also of note from the spells to which I linked you were the OlvynSpells which include metamagic! (Search for metamagic on this page.)

    This means that spells can deal more damage (Empower & Maximize), affect a larger area (Widen), last longer (double duration with Extend Spell, last for a day with Persistent Spell, or last 48 hours with Persistent + Extend Spell), cast faster (Quicken), avoid hurting allies (Safe Spell), affect other targets with Mass Spell, and give penalties to saves (Intensify Spell AKA Heighten Spell).
  • morpheus562morpheus562 Member Posts: 309
    @jmerry @Endarire

    So here is what I have on my plate for the version 1.2 release in the next week or so:
    • FMC (Cleric/Mage) and Monk scripts. I have another mage one I use for dual classes while the fighter level is inactive. Happy to share this one, but it is extremely focused for my play.
    • Added Hardiness HLA for the Archer, ClerRang, and Inquis scripts
    • ClerRang character can switch between attacking enemies and turn undead mode by pressing the "V" key
    • Prevent casting spells in Athkatla without the license or if the Cowled Wizards will bother you
    • Look at autocasting all spells for pre-buffing or a hybrid of autocasting and manual casting
    • Working to reduce inactive time during combat (i.e. mage casts a spell and waits to cast the next one). It will now pause spellcasting and fill the inactive time by attacking.

    I love the idea of meta magic and first remember it from NWN2. I would love a crack at implementing it in scripts, but that is going to be sometime down the road. Any other ideas I am happy to look at and consider to see if it can release with v1.2. Thank you!
  • EndarireEndarire Member Posts: 1,519
    I also want the ability to remap keys for your AI scripts. Notably, I want to be able to use Alt/Shift/Control + Key so I have more keyboard keys for spell/ability hotkeys.

    Thankee!
  • morpheus562morpheus562 Member Posts: 309
    edited February 2021
    @Endarire @jmerry
    I tested my checks to cast in Athkatla this morning and it appears to be working as desired. It checks the player's location, if the player has a license, and the Cowled Warning, so all aspects will be covered. Please note, these are not implemented yet, but will be for version 1.2.
  • EndarireEndarire Member Posts: 1,519
    Thankee! Alleluia!
  • EndarireEndarire Member Posts: 1,519
    edited February 2021
    @morpheus562
    For the quick auto-buff, you may be able to set the casting time for this script for all spells to 0 (like by making the casting speed increased by 20; see Robe of Vecna for more casting speed decreasers) and add aura cleansing to ensure things are cast ASAP. When the script ends including via interruption, end the aura cleansing added by this script.

    Perhaps this effect would be a buff or an effect specific to your script that ended upon script completion, manual script deactivation, or entering combat. You could call it Matrix Time.
    Post edited by Endarire on
  • morpheus562morpheus562 Member Posts: 309
    Conducted some testing for pre buffing for my ranger cleric. With the original scripts it takes 2 minutes, 31 seconds to pre-buff the following: armor of faith, bless, remove fear, duhm, prayer, death ward (2x), defensive harmony, negative plane protection ,(4x), prot from evil 10', recitation, chaotic commands (2x), magic resistance, physical mirror, righteous magic, blade barrier, entropy shield, shield of the archons, mirror image, and hardiness. With the updated scripts, this is now done in 28 seconds. I'm pretty pleased with shaving 2 minutes off the casting time.

    Still more testing needs to be done for the other features in the v1.2 release, but this will be a nice addition.
  • RyofuRyofu Member Posts: 268
    Hi, have a question, if i have a pure cleric or a pure mage in my party should i just use the F/M/C script or should i use a different script if i want them to attack from distance with a ranged weapon in combat?
  • morpheus562morpheus562 Member Posts: 309
    Either cleric/ranger of fmc will work with a pure cleric. With both, if you have a ranged weapon equipped it will be used. I don't do the whole swapping between melee weapon and ranged weapons in my scripts.

    The sorcerer script will have your mage constantly keep up melfs minute meteors and use those. Once that spell runs out, it will resort to using magic missiles. This was a simple one I created in the interim while I was stalking kensai into mage and haven't gotten my kensai class activated.
  • morpheus562morpheus562 Member Posts: 309
    Version 2.0 is in the works. It will offer better support for BG2EE and EET games both with and without IWD spells added, and I'll be focusing on getting them to run with Spell Revisions. Lots of testing will need to be done with Spell Revisions since changes to invisibility will require lots of testing and troubleshooting.

    It will also offer the option to restore a couple items that Item Revisions changes back to the vanilla item. Each item will have it's own prompt, so you can pick and choose what you want. Additionally, if Spell Revisions is installed it will provide the option to restore Haste and Improved Haste back to their vanilla versions.

    Finally, there is the option to install a component to bring a certain helm and +3 sword from SoD into BG2EE. It will make a tough encounter even more challenging. Rounding it off will be another optional component to add two new katanas into the game. A +2 katana will be added to BGEE and on par with similar items, a +5 katana added into BG2EE, and a pair of kensai focused bracers (Item Revisions let's me do it).

    If someone from g3 is reading this, I'd like to migrate this mod over to your site. Please reach out and let me know next steps.
Sign In or Register to comment.