Page 1 of 2

Making AI Repair Hardpoints? [Solved]

Posted: Thu Sep 15, 2016 4:58 pm
by Ascertes
I'm trying to find out how to get the AI to repair Shield Generators, Mainframes, etc. By default they don't do this on their own (though I swear the CIS AI repaired the defense mainframe once on the Coruscant Space level...) I've browsed through the ODF files for the hardpoints and fusion cutters, but I've found nothing of relevance. I know people have done this before and it's probably super simple, but I can't seem to figure out what values to add or change. Tried searching the forums but came up empty on that front. Anyone know the answer for this?

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 6:35 pm
by Oceans14
I'm pretty sure AI repair behavior is dependent on the class label of the prop and the unit, as well as the prop's team. If the class label is something like "destructible building" and the unit is a pilot or engineer class, and the prop is on their team, they'll repair it when it's destroyed or damaged. Check the documentation on AI behavior if you haven't already, and check the classes of props like shield generators and whatnot.

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 7:34 pm
by Ascertes
Oceans14 wrote:I'm pretty sure AI repair behavior is dependent on the class label of the prop and the unit, as well as the prop's team. If the class label is something like "destructible building" and the unit is a pilot or engineer class, and the prop is on their team, they'll repair it when it's destroyed or damaged. Check the documentation on AI behavior if you haven't already, and check the classes of props like shield generators and whatnot.
Auto turret mainframe label: "destructablebuilding"

Shield Generator label: "armedbuilding"

Fusion cutter doesn't have either of these labels within its ODF. However, other items that have those class labels the AI WILL repair, like the turrets on Kashyyyk or Naboo. The relevant section for the fusion cutter reads as follows:

Code: Select all

TargetEnemy             = "1"
TargetNeutral           = "1"
TargetFriendly          = "1"

TargetPerson            = "0"
TargetAnimal            = "0"
TargetDroid             = "0"
TargetVehicle           = "1"
TargetBuilding          = "1"
TargetMine              = "1"

LockOnRange             = 4.0
LockOnAngle             = 90.0

VehicleHealth           = 200
BuildingHealth          = 100
BuildingBuild           = 50
BuildingRebuild         = 50
DroidHealth             = 0
MineHealth              = -1000

As far as AI documentation, I don't have any within my documentation folder. Which doc are you referring to specifically?

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 8:40 pm
by Oceans14
https://sites.google.com/site/swbf2modt ... parameters

Go alllllllllll the way down to the "soldier" heading and note those unit types. Some have the ability to repair (pilot, support). I was incorrect when I said it's the unit's class label that matters. It's the unit type.

The fusion cutter settings shouldn't matter. What I would do is add some sort of object that can be damaged, make it friendly to one team, and watch to see if the engineer units (unit class: support) repair it.

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 9:03 pm
by Ascertes
Oceans14 wrote:https://sites.google.com/site/swbf2modt ... parameters

Go alllllllllll the way down to the "soldier" heading and note those unit types. Some have the ability to repair (pilot, support). I was incorrect when I said it's the unit's class label that matters. It's the unit type.

The fusion cutter settings shouldn't matter. What I would do is add some sort of object that can be damaged, make it friendly to one team, and watch to see if the engineer units (unit class: support) repair it.
I just checked the ODF's for the CIS pilot and engineer, and both their unit types are "pilot". Same goes for both Republic counterparts. The 2 units on each team both use the exact same fusion cutter as the other on their team.

Engineers obviously repair and build stuff, but for some reason the pilots won't. I'm also not seeing anything within these ODF's that would cause such a glaring difference.

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 9:16 pm
by Marth8880
The UnitType needs to be support.

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 9:20 pm
by Ascertes
Marth8880 wrote:The UnitType needs to be support.
Alright, thank you.

But a couple questions:

1. If the unit type needs to be support, why do engineers with the "pilot" UnitType still repair stuff?

2. If I switch the pilot's type in my space map to support, will they not be able to repair the vehicles they are in?

Re: Making AI Repair Hardpoints?

Posted: Thu Sep 15, 2016 9:33 pm
by Marth8880
Sticking this here for reference.
[color=#FFFFFF]ODF Parameters.txt[/color] wrote: Scout
Anti-Armor rocket
Assault rocket
Repair
Support repair
Pilot
Trooper
Special - repair
I could swear there was more thorough documentation on the different UnitType values, but I can't seem to find it.

Ascertes wrote:1. If the unit type needs to be support, why do engineers with the "pilot" UnitType still repair stuff?
I honestly don't know what to tell you lol. The best answer I can give is that Battlefront is just..."special".
Ascertes wrote:2. If I switch the pilot's type in my space map to support, will they not be able to repair the vehicles they are in?
I'm not sure, but it wouldn't be very difficult to test. ;)

Re: Making AI Repair Hardpoints?

Posted: Fri Sep 16, 2016 11:49 am
by thelegend
AINoRepair = "1" disables all AI from repairing it. Maybe by adding: AINoRepair = "0" will help.

Re: Making AI Repair Hardpoints?

Posted: Fri Sep 16, 2016 12:30 pm
by Samee3
This probably has something to do with AI Goals (Deathmatch, Conquest, CTFOffense, CTFDefense).
So unless you would like to try adding something other than Deathmatch in the script, you're probably not going to get them to do what you want.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 2:05 am
by Ascertes
Here is what I have done:
1. Added AINoRepair = "0" to the auto turret mainframe, no AI moved to repair it.
2. Created a custom unit with the support UnitType armed with a fusion cutter. No luck.
3. Damaged and destroyed the mainframe, in neither case were the AI motivated to fix it.
Samee3 wrote:This probably has something to do with AI Goals (Deathmatch, Conquest, CTFOffense, CTFDefense).
So unless you would like to try adding something other than Deathmatch in the script, you're probably not going to get them to do what you want.
I wouldn't mind giving it a go, personally. Just how complicated is it, though?

EDIT: I just tested on Space Coruscant in campaign mode, the AI are in fact repairing the auto mainframe if you destroy it during the mission. Now just have to figure out why they do it there and not anywhere else.

EDIT2: I poured over the LUA for the Space Coruscant mission, and this line stuck out to me:

Code: Select all

SetProperty("spa_prop_liquidgen", "Team", 2)
spa_prop_liquidgen is the ODF for the auto defense mainframes in the game. I wonder if setting that property does anything related (though I'm not sure why it wouldn't just do that via the Team box in ZE...) Any other ideas?

EDIT3: Played the Kashyyyk space mission, lo and behold the AI were repairing that mainframe as well. There was no line about the team for the mainframe though, so I guess that theory is out the window. I think this does have something to do with the campaign AI objectives. It's worth noting the CIS droids will repair their team's mainframe, but the Republic AI will not.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 3:19 am
by AnthonyBF2
It may be because the CIS mainframe is part of the objective, and the republic one is not. I may be wrong because I haven't played the campaigns in ages. Study spa3c_c.lua and also study the scripts it calls for at the top of the file and you might get what you want.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 1:40 pm
by Ascertes
AnthonyBF2 wrote:It may be because the CIS mainframe is part of the objective, and the republic one is not. I may be wrong because I haven't played the campaigns in ages. Study spa3c_c.lua and also study the scripts it calls for at the top of the file and you might get what you want.
I'm half tempted to just start adding those scripts to my LUA and see which one gets the AI to repair, though I suspect it will be a little more complicated than that.

EDIT: After studying both spa2c_c and spa3c_c LUA's, these are the scripts shared between them:
1. setup_teams (though I doubt this is the right one because all maps use that one as well.)
2. ObjectiveAssault
3. MultiObjectiveContainer
4. LinkedShields (I don't think any of the "Linked" scripts are our controllers.)
5. LinkedTurrets
6. LinkedDestroyables
7. PlayMovieWithTransition (Don't see how this could be related.)

So likely suspects are ObjectiveAssault, MultiObjectiveContainer. I'll have to do a little more digging to see if these work properly when added to my LUA.

EDIT2: After reading MultiObjectiveContainer, I don't think this is it either. The LUA description says its sets a number of objectives to be completed, and when all sets are completed. the map ends. That would explain why its only used in campaign LUA's.

EDIT3: Found something interesting! I studied the kashyyyk conquest LUA and there is an objective in there, it reads as follows:

Code: Select all

    conquest.OnStart = function(self)
    	conquest.goal1 = AddAIGoal(REP, "Defend", 30, "gatepanel")
		conquest.goal2 = AddAIGoal(CIS, "Destroy", 30, "gatepanel")
		conquest.goal3 = AddAIGoal(CIS, "Destroy", 10, "woodl")
		conquest.goal4 = AddAIGoal(CIS, "Destroy", 10, "woodc")
		conquest.goal5 = AddAIGoal(CIS, "Destroy", 10, "woodr")
		conquest.goal6 = AddAIGoal(REP, "Defend", 10, "woodl")
		conquest.goal7 = AddAIGoal(REP, "Defend", 10, "woodc")
		conquest.goal8 = AddAIGoal(REP, "Defend", 10, "woodr") 
I'm almost 100% sure these refer to the wood barricades and the sea wall. Have to figure out how I'd adapt this though to Space Assault, plus nothing of this nature is in the 2 space campaign LUA's...Could use some help adapting it. :(

EDIT4: Added the conquest LUA to my _Diet Dr. Pepper LUA, along with the above code (but replaced the objects with the names of my defense mainframes) no luck...

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 4:13 pm
by Oceans14
I honestly don't think AI goals or objective scripts have anything to do with repairs. That said, they're always good to use. I'm interested in this myself now, so when I'm off work I'll run a few tests and report back.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 4:37 pm
by Ascertes
Oceans14 wrote:I honestly don't think AI goals or objective scripts have anything to do with repairs. That said, they're always good to use. I'm interested in this myself now, so when I'm off work I'll run a few tests and report back.
Thank you very much :mrgreen: Always good to have 2 heads instead of 1 working things out :)

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 7:44 pm
by Oceans14
Got it. Here's what I did:

Code: Select all

1) Set my prop's classlabel to "armedbuilding".  In the odf for several space conquest props (poke around in BF2_ModTools\space_template\Worlds\@#$\odf) it is actually noted "was armedbuilding.  needs to be armed in order to regen health/shields".  So they actually tell you how to get ai to repair stuff, just not very clearly.  Anyway...  

2) Set prop to team 1 in ZE, since I wanted to see the clone engineer repair the prop once damaged.  

3) Save, munge, play.  The engineer began to repair the prop immediately after I put a few shots into it.  It's worth noting that in subsequent rounds of gameplay the engineers would ignore the prop when engaged in heavy combat.  Also, because the prop was set to team 1, team 2 sporadically shot at it.  (If desirable, ai goals could be used so that the enemy team (or your team, whatever) focuses more directly on destroying the prop.)
Proof:
Hidden/Spoiler:
Image

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 8:16 pm
by Ascertes
Oceans14 wrote:Got it. Here's what I did:

Code: Select all

1) Set my prop's classlabel to "armedbuilding".  In the odf for several space conquest props (poke around in BF2_ModTools\space_template\Worlds\@#$\odf) it is actually noted "was armedbuilding.  needs to be armed in order to regen health/shields".  So they actually tell you how to get ai to repair stuff, just not very clearly.  Anyway...  

2) Set prop to team 1 in ZE, since I wanted to see the clone engineer repair the prop once damaged.  

3) Save, munge, play.  The engineer began to repair the prop immediately after I put a few shots into it.  It's worth noting that in subsequent rounds of gameplay the engineers would ignore the prop when engaged in heavy combat.  Also, because the prop was set to team 1, team 2 sporadically shot at it.  (If desirable, ai goals could be used so that the enemy team (or your team, whatever) focuses more directly on destroying the prop.)
Proof:
Hidden/Spoiler:
Image
Well, that doesn't explain though why the AI in space won't repair the hardpoints. The auto defense mainframe's ClassLabel is "armedbuilding", yet the AI refuse to touch it in regular gameplay.

I'm going to add engineers to my map just to see what they do.

EDIT: Nope, stock engineers won't repair the mainframes.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 8:42 pm
by Oceans14
Well hang on. A hardpoint is a node on a model that effects and odfs and even unit models can be attached to. AI will never repair hardpoints because they don't know what a hardpoint is. They'll repair props (which I know is what you meant, but I wanted to clarify the terminology). And no, tbh that doesn't explain why they won't repair armedbuildings in space. From what I can tell, their attention isn't fantastic and they'll only repair something if they sort of stumble across it. Since that's the case, you could use the defend goal in combination with hint nodes and pathing to keep some units close to your prop. That way when it takes damage they should already be in the vicinity to set about making repairs.

Also I might point out that if all else fails, you can set a prop to regenerate its health over a period of time with the AddHealth and MaxHealth odf lines.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 9:04 pm
by Ascertes
Oceans14 wrote:Well hang on. A hardpoint is a node on a model that effects and odfs and even unit models can be attached to. AI will never repair hardpoints because they don't know what a hardpoint is. They'll repair props (which I know is what you meant, but I wanted to clarify the terminology). And no, tbh that doesn't explain why they won't repair armedbuildings in space. From what I can tell, their attention isn't fantastic and they'll only repair something if they sort of stumble across it. Since that's the case, you could use the defend goal in combination with hint nodes and pathing to keep some units close to your prop. That way when it takes damage they should already be in the vicinity to set about making repairs.

Also I might point out that if all else fails, you can set a prop to regenerate its health over a period of time with the AddHealth and MaxHealth odf lines.
You'll have to explain to me what the defend goal is, but I'll try out the hintnodes. And how would pathing tie into this, because the paths I have go right next to the mainframe.

Re: Making AI Repair Hardpoints?

Posted: Sat Sep 17, 2016 9:25 pm
by AQT
AI will repair stuff if their UnitType is "pilot" and if one of their goals is "Conquest." This is similar to how AI will use snipe hint nodes if their UnitType is "sniper" and if one of their goals is "Conquest."