Jump to content
kagenekosama

Make ai repair vehicles

Recommended Posts

Hey all, so i've been trying to figure this out, i want AI to repair vehicles that are damaged. So far i've tried to set an a squad with a tank and some repair specialists, however it seems like ai don't request their units to repair their tank. 

So it seems i need to set a script to make ai check for current vehicle damage, and then make any possible unit with repair capabilities to do so.

 

If you know of some script like that, or a thread that resolves this problem (So far i cannot find anything like this on google or here) i would be thankful.

 

Cheers 

Share this post


Link to post
Share on other sites

Hey are the AI in your group or a different group. 

 

1.  put a repair truck down with a crew and place a support Waypoint on the vehicle. 

 

2. Place a tank or armored vehicle down with a crew not in your group.

 

3.  Shoot the vehicle causing damage.

Two things should happen 

1. The repair truck with the support Waypoint should move to the damage vehicle. Or  2. The damaged vehicle will drive to the support vehicle. The order will come from the tank commander. This is the way it always worked since OFP days unless they change things with recent updates.

 

Now you have me curious if this still works.

 

Share this post


Link to post
Share on other sites

I personally script everything but if what @avibird 1 says is still true then keep in mind that minimal low caliber weapons might not trigger that if you don't deal enough damage. I think there is a condition feel for in-game waypoints where you could enter something like:

damage this > 0

Not that this matters really for your case as I assume the tank is going to be badly damaged anyway. Another method would be to create a HandleDamage, Hit or Damage EH on the vehicle. If damages badly then one crew member or if Slammer then engineer dismounts from back and starts repair process. You can also create a support truck X away from damaged tank and have it move to tank pos and do a similar thing.

Share this post


Link to post
Share on other sites

Thanks for the  feedback, so far i've tried one solution like the one HazJ mentioned, however i still need the Ai to call a repair everytime one is needed.

Share this post


Link to post
Share on other sites

is this for SP/MP?

 

EDIT:

 

Made very quickly and is purely to start you off and give you some ideas.

repairAvailable = true;
repairCooldown = 600;
repairTruckType = "B_Truck_01_Repair_F";

actRequestRepair = player addAction ["Request repair",
{
	repairAvailable = false;
	player sideChat format ["Requesting repair at grid %1", mapGridPosition player];
	_pos = [player, 250, 500, 25, 0, 0.1, 0, [], []] call BIS_fnc_findSafePos;
	_truck = repairTruckType createVehicle _pos;
	_crew = [_truck, group player] call BIS_fnc_spawnCrew;
	_truck doMove (getPos player);
	_truck action ["Repair", (vehicle player)];
}, [], 0, false, false, "", "repairAvailable"];

It needs a lot of work in terms of features.

- Truck doesn't return / delete

- Cooldown not implemented

- Etc, etc

Thought I'd leave some work for you. :rofl:

Tested in SP only. It will be better to check for all damaged vehicles nearby on truck destination arrival in case player gets out. Was just quick example.

  • Like 1

Share this post


Link to post
Share on other sites

@kagenekosama are you the group leader yes or no and if you are you need to call the repair truck either with the in-game support menu and a support Waypoint attached to a repair trunk or with a script like HAZJ  provided but the in-game support works. You need to say done if and when you want to call it again from the support menu.

 

Just put down a AI group that has nothing to do with You and AI group leader should call to get repairs and if you have a another AI group with a repair truck with a support Waypoint it will come to the damage vehicle. 

 

A second solution if you are the group leader have teamswitch  enable switch out of the leader role of the group and now the AI group leader will call for repairs.  Just what I said above. If you are the group leader then the AI will wait for your orders.

Share this post


Link to post
Share on other sites

Thanks guys, however what i need is a script  that makes AI repair another AI vehicle, it is not for the player. 

Share this post


Link to post
Share on other sites

@kagenekosama - Why not modify what I gave you to suit your needs? I was just testing myself and made some progress. I was going to suggest Damage EH but it multiple times. There are other ways. Too tired atm to mess with it. This is what I did very quickly:

repairAvailable = true;

{
	_x addEventHandler ["Dammaged",
	{
		params ["_unit", "_hitSelection", "_damage"];
		if (damage (vehicle _unit) < 0.05 || !repairAvailable) exitWith {systemChat "Repair not available";};
		repairAvailable = false;
		systemChat format ["%1 is requesting repair at grid %1", _unit, mapGridPosition _unit];
		_pos = [_unit, 250, 500, 25, 0, 0.1, 0, [], []] call BIS_fnc_findSafePos;
		_truck = "O_Truck_03_repair_F" createVehicle _pos;
		_crew = [_truck, group _unit] call BIS_fnc_spawnCrew;
		_truck doMove (getPos _unit);
		_truck action ["Repair", (vehicle _unit)];
	}];
} forEach allUnits;

Needs a lot of work. When I get chance, I will have another look, when I am more awake. (:

 

EDIT: Probably triggers multiple times as I am adding to each unit and not the tank itself. Will do further testing some other time as said above.

EDIT 2: Still triggers multiple times.

testTank addEventHandler ["Dammaged",
{
	params ["_unit", "_hitSelection", "_damage"];
	if (damage (vehicle _unit) < 0.05 || !repairAvailable) exitWith {systemChat "Repair not available";};
	repairAvailable = false;
	systemChat format ["%1 is requesting repair at grid %1", _unit, mapGridPosition _unit];
	_pos = [_unit, 250, 500, 25, 0, 0.1, 0, [], []] call BIS_fnc_findSafePos;
	_truck = "O_Truck_03_repair_F" createVehicle _pos;
	_crew = [_truck, (createGroup opfor)] call BIS_fnc_spawnCrew;
	_truck doMove (getPos _unit);
	_truck action ["Repair", (vehicle _unit)];
}];

 

Share this post


Link to post
Share on other sites

The in game repair system works just do what I told you.  The game already has a good working repair script built-in for the AI with the support Waypoint put down on a repair vehicle under AI Control. Any AI squad leader will use it. 

 

If you need it multiple times and you're worried about getting destroyed just use one of the half a dozen respawn  Scripts on top of it. 

Share this post


Link to post
Share on other sites
3 hours ago, avibird 1 said:

The in game repair system works just do what I told you.  The game already has a good working repair script built-in for the AI with the support Waypoint put down on a repair vehicle under AI Control. Any AI squad leader will use it. 

 

If you need it multiple times and you're worried about getting destroyed just use one of the half a dozen respawn  Scripts on top of it. 

Are the support waypoints working again?

First time I tested it during alpha it was broken as hell, AI radio spamming repair requests etc, sometime before APEX I believe the support waypoint stopped working at all.

 

Cheers

Share this post


Link to post
Share on other sites

Saw this before but never really read up on it or used it. Will check it out sometime.

Share this post


Link to post
Share on other sites
1 minute ago, HazJ said:

Saw this before but never really read up on it or used it. Will check it out sometime.

 

its kind of a workaround. engineers have logic already to repair vehicles which are under control of their group

 

so temporarily adding the damaged vehicle to their group can plug into that logic

  • Like 1

Share this post


Link to post
Share on other sites

@Grumpy Old Man yes the support Waypoint works both for player and the  AI use on a repair trunk most people really don't know how to use it. The player needs to call done to call the repair trunk to new location. Now using engineers as the crew of the repair trunk that's something to see if it works.  If the trunk takes damage if the crew will  repair the truck.

 

Share this post


Link to post
Share on other sites
3 hours ago, avibird 1 said:

@Grumpy Old Man yes the support Waypoint works both for player and the  AI use on a repair trunk most people really don't know how to use it. The player needs to call done to call the repair trunk to new location. Now using engineers as the crew of the repair trunk that's something to see if it works.  If the trunk takes damage if the crew will  repair the truck.

 

 

they will but they wont dismount just to do that. they'll only fix if they're already dismounted

Share this post


Link to post
Share on other sites

Thanks again for the feedback, i'm also trying to tweak my own script, probably if i use HazJ method with even handlers it will work better. 

Share this post


Link to post
Share on other sites

I wouldn't use Dammaged EH though. You can try but in my few tests, it fired multiple times.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×