Home   Help Search Login Register  

Author Topic: Simulated mechanic  (Read 1436 times)

0 Members and 1 Guest are viewing this topic.

Offline Captain

  • Members
  • *
Simulated mechanic
« on: 10 Jun 2007, 06:22:14 »
I have this vehicle repair script I found somewhere, however there was no readme included in the zip so I don't know who to give credit to. Anyway, this is the script...

Code: [Select]
F_Repair =
{
_vec = (vehicle player);
_type = typeOf vehicle player;
if(getDammage _vec > 0 or fuel _vec < 0.98 and not (_vec isKindOf "Man")) then
{
_inrepairzone = ((_vec in list RZoneA) or (_vec in list RZoneB) or (_vec in list RZoneC) or (_vec in list RZoneD));
if(_inrepairzone and _vec != player and speed _vec > -2 and speed _vec < 2 and position _vec select 2 < 2.0 and (local _vec)) then
{
titleText ["Servicing", "PLAIN DOWN",0.3];
for [{_loop2=0}, {_loop2<1}, {_loop2=_loop2}] do
{
    sleep 0.200;        
    if (getDammage _vec > 0) then {_vec setDammage ((getDammage _vec)-0.0125);};
    if (Fuel _vec < 1) then {_vec setFuel ((Fuel _vec)+0.0125);};
    if (getDammage _vec == 0 and Fuel _vec == 1) then {_loop2=1;};
    if(_vec != vehicle player or speed _vec < -2 or speed _vec > 2 or position _vec select 2 > 2.0) then {_loop2=1;titleText [localize "EVO_015", "PLAIN DOWN",0.3];};
};
_vec setVehicleAmmo 1;
};
};
};


for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
[] call F_Repair;
sleep 1.011;
};

...and it works perfectly for how it was designed. The script is activated by any (damaged) vehicle that drives into a trigger zone, in my case a 10x5m trigger in front of a fuel station in a base. what I would like however, is to have an AI approach the vehicle where ever it parks in that area and do the medic animation (or if there is a more suitable anim I'm unaware of) in a loop until repairs are complete then returns to where he started the mission next to the garage. I would also like the script to take longer to repair vehicle than the current version. like a vehicle that starts repair at .8 damage may take 5 minutes or so to repair fully.
« Last Edit: 10 Jun 2007, 06:27:23 by Captain »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Simulated mechanic
« Reply #1 on: 11 Jun 2007, 03:56:51 »
I leave it as an exercise for you to find a better animation, and to make the repairman face the truck without fail.

Script now must be given the name of the repairman and the name of the trigger. If repairman dies then you are out of luck.
« Last Edit: 12 Jun 2007, 17:11:48 by Mr.Peanut »
urp!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Simulated mechanic
« Reply #2 on: 12 Jun 2007, 16:38:01 »
I Split this topic and moved it here because it is now in the realm of MP editing.

Edit: small change in mechanic code to make unit face truck using lookAt command. Re-download please.
« Last Edit: 12 Jun 2007, 17:06:24 by Mr.Peanut »
urp!