heres a system i am working on for a private mod
its unfinished, has some bugs but gives you a general idea to get a decent mp system up and running
MISSION EDITORPlace the following line in the init field of your repair unit
this addaction ["Assess Damage","repair.sqs"]
INIT.sqstx_Repairing = []
tx_RepairOFF = []
tx_RepairON = []
REPAIR.sqsgoto "INIT"
#DECISION
~2
if ((_u in tx_RepairOFF)||(_time >60))then{goto "Abort"}
if !(_U in tx_RepairON)then{goto "DECISION"}
_weps = (nearestobject[_pos,"weaponholder"])
#REPAIR
~1
_count = _count + 1
if (_u in tx_RepairOFF)then{goto "Abort"}
if(_u distance _obj > 8)then{_u groupchat "Repair terminated.....Reason: too far away"; goto "ABORT"}
if(_count == 5)then{_u playmove "CrouchToWeapon"}else{if(_count == 10)then{_u playmove "CombatReloadMortarEnd"; _count = 0}}
_dam = getdammage _obj
_obj setdammage (_dam -_rpower)
if((_u distance _weps)>1.5)then{_u setpos (getpos _weps)}
if!(vehicle _u == _u)then{hint format["Repair aborted.....Reason: %1 in a vehicle",name _u]; goto "ABORT"}
if (getdammage _obj == 0)then{_u groupchat "Repair Sucessful"}else{goto "REPAIR"}
#ABORT
_u domove _pos
tx_repairing = tx_repairing - [_u]
tx_repairON = tx_repairON - [_u]
tx_repairOFF = tx_repairOFF - [_u]
{_u removeaction _x} foreach[_W0,_w1]
~4
_u groupchat format ["Repair terminated on %1..... Reporting %2 damage remaining",(typeof _obj),(getdammage _obj)]
_u action ["take weapon",nearestobject([_pos,"secondaryweaponholder"]),0,0,_secw]
~4
_u action ["take weapon",nearestobject([_pos,"weaponholder"]),0,0,_prim]
exit
#INIT
_u = _this select 0
if(_U in tx_repairing)then{hint "Mechanic is already repairing a vehicle";exit}
if!(vehicle _u == _u)then{hint format["%1 Repairs not possible when in a vehicle",name _u]; exit}
_dist = 5
_height = 1.8
;; following is amount of repair per loop
_rpower = 0.00071
~ 0.1
_obj = (nearestobject[(getpos _u select 0)+sin(getdir _u)*_dist,(getpos _u select 1)+cos (getdir _u)*_dist,_height])
_count = 0
if(_obj in zm_units)then{exit}
if(_u distance _obj > 6)then{_u groupchat "Get closer to assess the damage"; exit}
_dam = getdammage _obj
if(_dam ==0)then{_u groupchat format["This %1 appears to be ok",typeof _obj]; exit}
if(_dam ==1)then{_u groupchat format["This %1 is beyond repair",typeof _obj]; exit}
tx_repairing = tx_repairing + [_u]
_rep = _dam/_rpower
;;_rep = _dam * 1200
_prim = primaryweapon _u
_u action ["Drop Weapon",_u,0,0,_prim]
_secw = secondaryweapon _u
_u action ["Drop Weapon",_u,0,0,_secw]
_pos = getpos _u
_u playmove "CrouchToWeapon"
_u groupchat format ["Assessing Damage on %1", typeof _obj]
_r = 3 + (random 7)
~ _r
;;_rep = (_dam * 1200)-_r
_rep = _rep -_r
_mins = _rep /60
_secs = mins mod 1
_mins = _mins - (_mins mod 1)
_u groupchat format["This %1 has %2 damage............................It will take approx %3 to %4 mins to fix",(typeof _obj),_dam,_mins,(_mins + 1)]
_w0 =_u addaction ["Abort Repair","repairOFF.sqs"]
_w1 =_u addaction ["Repair Vehicle","repairON.sqs"]
goto "DECISION"
exit
repairOFF.sqs_u = _this select 0
_action = _this select 2
tx_RepairOFF = tx_RepairOFF + [_u]
_U removeaction _action
exit
repairON.sqs_u = _this select 0
_action = _this select 2
tx_RepairON = tx_RepairON + [_u]
_U removeaction _action
exit
_______NOTES_______zm_units is an array of all units on the map
This system works for ai or players.
You can access the ai through your normal radio commands
Stage 11) The unit puts down his primary and secondary weapon
2) The unit then assesses the damage and reports back via the group chat an estimated time of repair
3) A new set of actions are then added to the unit, whether to repair or abort
4) If abort repair is selected, the unit picks up his weapons and awaits further orders
5)If repair is selected then the unit loops through a series of animations, repairing at a speed of 0.00071 per second loop
This gives a repair time for an almost fully destroyed vehicle of approx 23 minutes
A fully damaged vehicle will, not be repaired
Ammo crates and other static objects that are not fully destroyed can be repaired
Make sure you define an array of units otherwise your vehicle mechanic will repair those too
As i stated previously, this is a development script for a system in a mod, it isnt even halfway through the development stage, so expect some bugs, cant remember what they were, havent worked on it for several weeks now.
The repair unit is intended to be a "vehicle mechanic" class driving a recovery vehicle, his vehicle has the abiliuty to recover an overturned vehicle
So as a driver/vehicle configuration, the system under development is designed as a parralell option to the "Instant Repair" of the BIS vehicle, as well as fixing some mp system bugs caused by the bis repair vehicle
Intended to make the mission commander decide whether to
a) leave a guard while the recovery mechanic repairs the vehicle
or
b) abandon the vehicle complately
The slow repair speed, has been found during our testing to be the optimised speed, not too fast and not too slow