View Full Version : Disable AI for henchmen, Kotor and TSL

06-26-2009, 10:33 AM
Don't you hate it when your companions attack enemies automatically, without waiting for your orders? I hate that. They always engage in melee combat. I hate that in Kotor, in TSL and in NWN2. In Kotor and TSL, this AI behaviour is controlled through the file k_ai_master. If you want your companions to wait for your orders, comment out the line


for all henchmen events (like KOTOR_HENCH_EVENT_ON_PERCEPTION) and then recompile the script.

Don't touch the KOTOR_DEFAULT_EVENT_ON_... events! Those control enemy behaviour. You don't want enemies to just stand around doing nothing. lol.

It may also be possible to change henchmen AI style, haven't tested it yet, but there's a function in TSL that allows to do this:

// Sets the party ai style
void SetPartyAIStyle(int nStyle);

The AI styles are defined in nwscript.nss script. This one is interesting:

int NPC_AISTYLE_PARTY_REMOTE = 14;//RWT-OEI 09/08/04 - Combat AI for the floating remote.

The Bao-Dur remote does pretty much nothing, so it may be interesting to change your party AI style to remote's style

06-26-2009, 11:47 AM
Cool. I hate it when the npc's run off and chase creatures.

06-26-2009, 08:05 PM
I think this would be better implemented by a new aiscripts.2da entry, named Following or something (a la NWN's Follow Me command).

Sometimes I just want the NPC's to tag along for conversation only. I usually equip and level them so strongly that most could run through the entire campaign plot on their own at Hardcore setting with no input from me.

Other times when you are forced to take a companion, such as the DS Star Forge plot, I'd prefer that they also do nothing but follow.

So, I guess, great work and idea, but I don't think it's quite flexible enough! :)

06-26-2009, 08:32 PM
I'd actually like some better-done party scripts, like:

Throw your nastiest Force power, then attack.
Hang back and fire your guns.
Keep casting force powers
Stay back and cast protection and healing powers.
Defend yourself (activate shields, cast protective powers on self)

06-26-2009, 08:42 PM
The Bao-Dur remote does pretty much nothing, so it may be interesting to change your party AI style to remote's style

That style only works for party puppets; if the object running it doesn't have an owner assigned it will not follow, and will just run the default AI routines instead. (If it is a puppet it will make it follow the owner around and heal any droids in the party that gets damaged.)

06-27-2009, 07:11 PM
I re-added some of the originally planned scripts for KotOR back into aiscripts.2da. These were: No Script, Aid, Melee Attack, and Ranged Attack.

I only looked briefly, but I think only Melee Attack will actually function; the rest will simply behave like No Script (following, but not attacking or using any power).

Here are the descriptions of those scripts as they were left in the game:
No Script: The character will do nothing but basic following of the leader, it will not attack or heal.
Melee Attack: The character will only use melee weapons.
Ranged Attack: Character will only used ranged weapons.
Aid: Whenever possible the character will use Force powers and med kits to heal party members that are below 50% in vitality points. Otherwise the character behaves in the same manner as the 'Default attack' setting.

I played through DS Star Forge with Bastila set to No Script, and it worked great! When combat began, she would halt in position and only return once it was over.

It's unfortunate that the other scripts probably won't work. Improved AI is something KotOR always needed. I would like to take a try at it, but since beating the game again I find myself reluctant to begin playing once more.

aiscripts.2da (http://www.mediafire.com/file/zwhmmmvhhgn/aiscripts_restored.zip)

07-01-2009, 11:56 AM
I just noticed that the Handmaiden sisters are using the henchmen AI scripts in TSL. This is an oversight on Obsidian's part, since Handmaiden sisters are technically copies of the henchman Handmaiden that follows you. So if you fight the handmaiden sisters in the battle circle at the Telos jedi academy, either remove the k_ai_master.ncs from the Override folder until you finish the fights or edit all the sisters' character files and adjust their AI scripts. Otherwise they won't determine combat rounds (means they won't attack you if you edited the henchmen portions of the k_ai_master script)

07-02-2009, 07:36 AM
I also noticed that the first time you encounter Visas (when she attacks you on the ship) in TSL, she's also using the henchmen scripts. This is beginning to get annoying. Ok, so maybe removing the DetermineCombatRound function altogether wasn't such a good idea after all. Instead, I recommend the following approach:

if( (GetTag(OBJECT_SELF) == "VISASCUT" || GetTag(OBJECT_SELF) == "DOJO" || GetTag(OBJECT_SELF) == "DOJOSISTER") && !IsObjectPartyMember(OBJECT_SELF) )
// original code here

or, even more reliable and simple:

if( !IsObjectPartyMember(OBJECT_SELF) )

this will basically prevent your party members only from determining combat rounds.

There still may be a problem with Handmaiden fights on the Ebon Hawk. Have to look into this