AI don't attack high HP enemies

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Benoz
Corporal
Corporal
Posts: 140
Joined: Tue May 28, 2013 12:34 pm
Projects :: Clone Wars Era Mod Version 2
Games I'm Playing :: OldFront - EAFront
xbox live or psn: No gamertag set
Location: Germany

AI don't attack high HP enemies

Post by Benoz »

Hey guys, so I wanted to make an Obi-Wan and Yoda vs 501st mode on Coruscant. You get forced to play as a Clone Trooper and win if you kill either Obi-Wan or Yoda. This all works fine.
Now to make it more interesting and not winning in the first few seconds I gave Obi-Wan and Yoda each 10.000 HP. Suddenly all my units from the clone side don't shoot at the targets anymore, even right in front of them. They just walk around. I changed the health in the LUA like this:

SetClassProperty("rep_hero_obiwan_cloaked", "MaxHealth", "10000")

Then as a comparison I set the health of the jedis to 1000 each and tested it. And now all troopers start shooting again.
Is there some sort of threshold that prevents units from attacking objects with too much health? Or is there another way to do this?

Thanks in advance!
User avatar
Needo62
Private Third Class
Posts: 49
Joined: Fri Jan 12, 2018 12:26 am
Projects :: is a secret owo
Games I'm Playing :: SWBF2
Location: STRAYA MATE
Contact:

Re: AI don't attack high HP enemies

Post by Needo62 »

i have no idea why its doing that but have you tried giving them 10000 health in their odfs instead of the lua?
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: AI don't attack high HP enemies

Post by AnthonyBF2 »

You may also consider changing the AI goals to force the clone AI to "destroy" the enemy AI.

I'm not actually sure how to set that up but it works something like this:

Code: Select all

AddAIGoal(ATT, "Destroy", 100, DEF)
ATT/DEF can also be 1/2 or REP/CIS (or whatever the team name ID is), 100 is the intensity of their focus, 100 should be they focus 100% on their target.
You'll might have to play around with this to get it right, if you're interested in this solution.
Bob
Brigadier General
Brigadier General
Posts: 633
Joined: Thu May 27, 2010 4:28 am
Location: at home

Re: AI don't attack high HP enemies

Post by Bob »

I could be wrong, but I do think I remember there beeing a "don't even bother with too durable targets"-threshold. What you could try is giving the jedi scum 1000 hp and set every clone weapon ordenance PersonScale to "0.1". That way the difference between raw damage and target hp stays normal, might trick the ai into shooting again.
Sporadia
Corporal
Corporal
Posts: 151
Joined: Thu Jan 24, 2019 11:02 pm
Projects :: No Mod project currently
Games I'm Playing :: None
xbox live or psn: No gamertag set

Re: AI don't attack high HP enemies

Post by Sporadia »

Just to corroborate this:

I've made myself an AI hero user script in the past with these lines:
SetProperty(charUnit, "MaxHealth", 1e+37)
SetProperty(charUnit, "CurHealth", 1e+37)

Where charUnit by this line would contain the userdata of the hero. So it's basically the same lua that you've used, but the SetProperty version rather than the SetClassProperty version. 1e+37 is the amount of health you use to make heroes invincible. I've never noticed the AI not attacking the heroes before. Just gave it a test run now (followed some heroes around with the freecam) and it's really hard to tell if the AI are targeting the heroes or not; it looks like they're not. The heroes are occasionally getting shot by accident but not targeted with blaster weapons. I saw wrist rockets were being fired at Mace Windu by super battle droids. They looked targeted but they are secondary weapons. And, the heroes definitely target each other. I just watched Princess Leia fighting the Emperor on Naboo. If it's a cannon odf thing, then there'd have to be something special about Princess Leia's blaster. I don't think that's the case.

When the heroes have their normal health, I'm seeing the same behaviour you are: They're definitely being targeted by everyone.

I'm force spawning the heroes but they're still added with SetHeroClass not AddUnitClass, so they are treated like AI heroes and not regular units. Maybe that's why they can fight each other. Or maybe units only target each other with blasters when they have similar health. I really want to know what's going on with the wrist rockets because I've not seen the invincible heroes being targeted with grenades. Also no idea what happens when you set your own health to 1e+37.

List of odf parameters: http://www.secretsociety.com/forum/down ... meters.txt
I agree it's probably best to try a workaround with other lines from the odfs. Looking at the odf parameters for the GameObject class and Soldier class, you could try adding a shield instead with these:
CurShield
MaxShield

Or you could set up a health regen thing like the Jedi used in the Coruscant campaign. I think it somehow uses AddHealth. Or I guess you could mess with the damage that weapons do like the previous suggestion.

Edit: Originally I wrote that charUnit should contain the name of the hero as a string. That's not right. It contains the userdata of the unit playing as a hero.
Last edited by Sporadia on Wed May 20, 2020 7:46 pm, edited 1 time in total.
User avatar
Benoz
Corporal
Corporal
Posts: 140
Joined: Tue May 28, 2013 12:34 pm
Projects :: Clone Wars Era Mod Version 2
Games I'm Playing :: OldFront - EAFront
xbox live or psn: No gamertag set
Location: Germany

Re: AI don't attack high HP enemies

Post by Benoz »

Thanks for all the input guys!
Needo62 wrote:i have no idea why its doing that but have you tried giving them 10000 health in their odfs instead of the lua?
Yes I've tried that, doesn't make a difference.
AnthonyBF2 wrote:You may also consider changing the AI goals to force the clone AI to "destroy" the enemy AI.
I haven't even heared of that AI goal. I'll give it a try
Bob wrote:I could be wrong, but I do think I remember there beeing a "don't even bother with too durable targets"-threshold.
My assumptions also tend to the threshold. I tested it by raising the HP each time by 1000. Somewhere at 8000 the AI didn't bother anymore. So I currently gave the jedi 5000 HP and an AddHealth value to compensate for the low HP.

EDIT: Unfortunately the threshold also kicks in when you give the jedi 1000 HP and set the damage of the blaster to PersonScale = .1
Sporadia wrote:I agree it's probably best to try a workaround with other lines from the odfs. Looking at the odf parameters for the GameObject class and Soldier class, you could try adding a shield instead with these:
CurShield
MaxShield
The shield idea is an interesting workaround. If the AIGoal method fails I'll try that.

EDIT: The workaround with the shield works. Now it gives me the sound of a shield impact though. I used a custom sound for this so I can't work with this idea. I probably gotta stick to the AddHealth workaround
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: AI don't attack high HP enemies

Post by Marth8880 »

The correct syntax for the destroy goal is

Code: Select all

AddAIGoal( team, "Destroy", weight, gameObjectPtr );
AddAIGoal( team, "Destroy", weight, integerChrIdx );
Post Reply