Note: LucasForums Archive Project
The content here was reconstructed by scraping the Wayback Machine in an effort to restore some of what was lost when LF went down. The LucasForums Archive Project claims no ownership over the content or assets that were archived on archive.org.

This project is meant for research purposes only.

Getting enemy to use force powers more than melee attacks

Page: 1 of 1
 LoKarWin
09-13-2006, 10:47 AM
#1
I can't figure out how to do this, if it's even possible. I have a unique .utc character, and I'm trying to see if I can make him use the force more often than anything else. I have stoffe's modified AI, and the game balance mod.

I'm guessing that it can't be done through the .utc script modifying section. Does a new script need to be written?
Or is it essentially impossible? Considering that the Sith Lords in the Trayus Academy often just try and melee you to death, I get the feeling that the game is too fundamentally stupid to pull this off. On the otherhand, k_ai_master does contain references to various behaviours that would seem to do the trick. But AI scripting is not at all familiar to me.

I've also found another problem. I'm testing this character within a module right now. Everything works fine, but when I choose a dialogue option that leads to a fight, he seems to forget which force powers I gave him in the .utc file, and ends up using ones which I never gave him at all. For example, he used insanity, when I know that I did not grant him that spell.
I have tried putting his .utc file in the Override as well as packed up in the .mod, but the problem remains.

Thanks for the help
 stoffe
09-13-2006, 11:44 AM
#2
I have a unique .utc character, and I'm trying to see if I can make him use the force more often than anything else. I have stoffe's modified AI, and the game balance mod.

I'm guessing that it can't be done through the .utc script modifying section. Does a new script need to be written?
Or is it essentially impossible? Considering that the Sith Lords in the Trayus Academy often just try and melee you to death


The force users attacking you at the Trayus Academy tend to know a very limited arsenal of powers, unless you've modified their templates to give them some powers to use. Also make sure they have enough force points to make use of what they have. If they run out of force points they'll usually not use their force powers.

You could also try enabling the BOSS-AI for them if it isn't already, since this makes them use force powers more often. At least for the Modified AI the BOSS-flagged characters use their force powers more than others.


As for your own custom character, is it set to use the standard game AI scripts? Does it have enough force points? Does it have any of the powers that NPCs can't/won't normally use?

If you want an NPC to only fight using the force you'll have to remove the generic Combat AI for them and write your own that won't initiate any normal attacks, and will cancel any queued normal attacks (since the game engine seems fond of bypassing the combat AI and issuing attack orders directly in some circumstances). If you know exactly what powers the NPC have, and who he/she/it will face, what allies if any are in the fight and where the fight takes place such an AI wouldn't need to be very complex. The Generic AI is massive and complex since it'll need to take all character types, possibilities and situations into account.


Everything works fine, but when I choose a dialogue option that leads to a fight, he seems to forget which force powers I gave him in the .utc file, and ends up using ones which I never gave him at all.


Check that you don't have more than one UTC template with the same name within sub-folders of the override folder and the override folder itself. Or within both the override folder or the module. It sounds like something that will happen when there is more than one and the game picks the one you haven't modified recently.
 LoKarWin
09-13-2006, 2:06 PM
#3
You could also try enabling the BOSS-AI for them if it isn't already, since this makes them use force powers more often. At least for the Modified AI the BOSS-flagged characters use their force powers more than others.

Is this if I check the "Plot" box in KOTOR Tool .utc editor?
This is where I come into problems, as I said "But AI scripting is not at all familiar to me" :(, I see references for initiating boss behaviour with GN_RunBossAIRoutine, which I cannot find anywhere else. I'm assuming that it's hard-coded.


As for your own custom character, is it set to use the standard game AI scripts? Does it have enough force points? Does it have any of the powers that NPCs can't/won't normally use?

I modelled it on a Jedi and made some changes. It has a lot of force points, and a small set of specific powers.

If you want an NPC to only fight using the force you'll have to remove the generic Combat AI for them and write your own that won't initiate any normal attacks, and will cancel any queued normal attacks (since the game engine seems fond of bypassing the combat AI and issuing attack orders directly in some circumstances). If you know exactly what powers the NPC have, and who he/she/it will face, what allies if any are in the fight and where the fight takes place such an AI wouldn't need to be very complex. The Generic AI is massive and complex since it'll need to take all character types, possibilities and situations into account.

Well, this is precisely what would happen. I know the place the fight would occur, and so in theory it should be simple. But I run into problems. As I can't find any other small specific AIs anywhere, I don't have any examples for where to start, and this is normally how I learn.


Check that you don't have more than one UTC template with the same name within sub-folders of the override folder and the override folder itself. Or within both the override folder or the module. It sounds like something that will happen when there is more than one and the game picks the one you haven't modified recently.

I think you're right. I will check this, probably an oversight somewhere.

Thanks for your time :)
 stoffe
09-13-2006, 5:28 PM
#4
Is this if I check the "Plot" box in KOTOR Tool .utc editor?
This is where I come into problems, as I said "But AI scripting is not at all familiar to me" :(, I see references for initiating boss behaviour with GN_RunBossAIRoutine, which I cannot find anywhere else. I'm assuming that it's hard-coded.


No, the Plot flag will just make the NPC completely invulnerable, so that wouldn't be too useful for someone who the player should fight. :) The "Boss" flag is set by adding the following line to the OnSpawn event script of the NPC (the script name is set in the UTC file). I'd suggest you make a copy of k_def_spawn01 which is the standard AI OnSpawn script, add the line and save it under a different name, compile it to NCS and update the UTC to reference to this new name.

GN_SetSpawnInCondition(SW_FLAG_BOSS_AI);


It will make them a little more agressive and more liberal in their use of grenades and force powers while fighting, in particular when using the Modified AI.

* * *

As for tracking the flow of the combat related AI, one of the event scripts of the NPC fires, which in turn runs the k_ai_master script, which tends to call the GN_DetermineCombatRound() function which is the combat AI main function. This in turn checks the AI style of the NPC and some other things and fires the correct sub-routine to make them fight accordingly. The GN_RunBossAIRoutine() function is one of those that is run by GN_DetermineCombatRound() if the Boss flag is set.

You should generally be careful about editing k_ai_master or any of its include files directly unless it's absolutely necessary for what you want to accomplish. This script is run by pretty much every character and creature in the game, so any changes you make here will have consequences throughout the game.

The same goes for changing the k_def_* (non-party) and k_hen_* (party) scripts since those standard AI event scripts are used by many different characters throughout the game. If you just want your own NPCs to behave differently you should make new scripts for them with different names instead so your changes only affect your own NPCs.


Well, this is precisely what would happen. I know the place the fight would occur, and so in theory it should be simple. But I run into problems. As I can't find any other small specific AIs anywhere, I don't have any examples for where to start, and this is normally how I learn.


I'm not aware of any AI scripting tutorials since the combat AI tends to be a little more tricky and time consuming than the scripting most modders usually do, from what I've seen, so there don't seem to be much demand.

However, if you post the specifics of what powers should be used, how and against whom etc (how the NPC should behave) I might perhaps be able to create an example script for you to customize further upon.
 LoKarWin
09-13-2006, 6:15 PM
#5
No, the Plot flag will just make the NPC completely invulnerable, so that wouldn't be too useful for someone who the player should fight. :) The "Boss" flag is set by adding the following line to the OnSpawn event script of the NPC (the script name is set in the UTC file). I'd suggest you make a copy of k_def_spawn01 which is the standard AI OnSpawn script, add the line and save it under a different name, compile it to NCS and update the UTC to reference to this new name.

GN_SetSpawnInCondition(SW_FLAG_BOSS_AI);


It will make them a little more agressive and more liberal in their use of grenades and force powers while fighting, in particular when using the Modified AI.

* * *


Thanks :) I will try this out, see what results I get.


I'm not aware of any AI scripting tutorials since the combat AI tends to be a little more tricky and time consuming than the scripting most modders usually do, from what I've seen, so there don't seem to be much demand.

However, if you post the specifics of what powers should be used, how and against whom etc (how the NPC should behave) I might perhaps be able to create an example script for you to customize further upon.

Basically, I'm talking to the NPC, inform him that I'm going to kill him, at which point he utters, Anakin-style :D, "You will try", then the atkonend script fires and the fight begins. Ideally, from there, I am aiming to have him attack me primarily with force powers, and also to heal/buff himself. I am aiming to keep any physical attacks to a minimum. I'm only giving him a small number of force powers, such as Grip, Strike and the Kill Series, along with some healing and buffs, because I don't want to overcomplicate it or let him get confused by having every power in the game available. TBH, I may remove buffs from him altogether, not sure yet. The NPC is supposed to be able to fight me throughout with a barrage of force powers that will make him a bit of a challenge to defeat. Especially with HLFPs like Grip, it may make him insufferably hard.
I am currently unsure as to whether it will be him vs my party or him vs just me ATM.
If you can give me some pointers that would be grand, don't use up too much of your time on account of me though.

cheers
 LoKarWin
09-14-2006, 9:53 AM
#6
I've just discovered an interesting problem. I added the line you said to a new k_def_spawn02 script, but it wouldn't compile. At first I thought I had put the line in the wrong place (incidentally, where should you put it?).

However, I loaded up k_def_spawn01.nss, and tried to compile it. This also failed. Specifically, it had errors on the un-commented parts of the script, even the parts that the text says you should keep un-commented (listening, I think).
I was under the impression that the commented lines are those that are not active and the un-commented lines are active.
But why would an original .nss script refuse to compile? That doesn't make sense, surely?
 stoffe
09-14-2006, 11:06 AM
#7
I've just discovered an interesting problem. I added the line you said to a new k_def_spawn02 script, but it wouldn't compile. At first I thought I had put the line in the wrong place (incidentally, where should you put it?).

However, I loaded up k_def_spawn01.nss, and tried to compile it. This also failed. (snip)

It this from the Improved AI mod, or the standard game AI scripts extracted from scripts.bif?

If it's the standard game scripts make sure you have extracted all the include files that are required, or you will get strange compilation errors.

If it's from the Improved AI, make sure to update the st_inc_powers.nss include file with the correct line numbers from spells.2da for the HL powers, if you haven't already, before attempting to compile the scripts that indirectly uses it.

What are you using to compile the scripts?

Ideally, from there, I am aiming to have him attack me primarily with force powers, and also to heal/buff himself. I am aiming to keep any physical attacks to a minimum. I'm only giving him a small number of force powers, such as Grip, Strike and the Kill Series, along with some healing and buffs, because I don't want to overcomplicate it or let him get confused by having every power in the game available. TBH, I may remove buffs from him altogether, not sure yet.


So, the NPC should use HLFP-Grip, Kill, HLFP-Strike, Master Heal. Which buffing powers should be used? Be aware that unless you use a fixed force power impact script some powers will work poorly when used by NPCs.

If it's the NPC vs. the party, should the NPC focus at one party member at a time until that person is dead, or switch targets depending on circumstances? Should he stand his ground and just pummel the player with force powers or attempt to move around?

Should the NPC be "smart" in its power usage, e.g. realize that the player has Force Immunity or Energy Resistance active and use Force Breach to get rid of it?

I'll have a look at this tonight or tomorrow night when I have a few hours to spare and see if I can come up with something for you. :)
Page: 1 of 1