Home   Help Search Login Register  

Author Topic: Add, fix, refuel and re-arm other vehicle action to driver (ACCEPTED)  (Read 4334 times)

0 Members and 1 Guest are viewing this topic.

Offline norrin

  • Tutorial Writer
  • **
ADD FIX, REFUEL and REARM ACTION SCRIPT

© norrin, MAY 2009 (updated 080509)

Thanks to both Mandoble and Spooner for their advice and suggestions

Description:
Gives the driver of a vehicle the option to fix, refuel and re-arm adjacent vehicles.  When an action is initiated a timer appears.  Current timings are 30 secs repair, 15 seconds for both re-arm and refuel.  If the driver leaves the vehicle or changes to another vehicle position the action is cancelled.  Only one action can be performed at a time.

This is another script that was suggested by one of my clan members (thanks soldierX). No doubt someone has something similar already built into their own missions but once again I checked the ArmAholic and OFP script databases and couldn't see anything similar so I ended up writing my own.

To implement:

1. Copy the Norrn_SF_supportVcl folder to your mission directory

2. To the vehicle you would like to add the ability to fix, refuel and rearm other vehicles put this in their init line in the editor:

nul = [this] execVM "Norrn_SF_supportVcl\init_repairer.sqf"
 

3. To all friendly vehicles add this in their init line in the editor:

this setVariable ["Norrn_vcl_mags", (magazines this)];

4. If you wish to use a hint rather than titlecut for script messages you can define the message type used in the scripts by modifying line 15 of the add_actions.sqf in the script folder :
Code: [Select]
// Define hint type for NORRN ADD FIX, REFUEL & REARM ACTION SCRIPT
NORRN_supportVcl_hint = 0; // 0 - hint, 1 - titleCut (default 1)
Added 070509

Other notes:

* Players must enter the vehicle as the driver to get the fix, refuel and rearm options, if they move to another postion within the vehicle the options will disappear and the current action will be cancelled.  If they then return to the drivers seat the options will reappear.

* The vehicle to be repaired, rearmed or refuelled must be the closest vehicle to the support vehicle.

* Only one action can be taken at a time.

* The vehicle must be stationary and the engine off for the options to appear.

* If the vehicle being repaired, rearmed or refuelled moves more than 15 metres away the action is cancelled.  

OFPEC DOWNLOAD
« Last Edit: 10 Aug 2009, 17:11:16 by hoz »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Add, fix, refuel and re-arm other vehicle action to driver
« Reply #1 on: 12 Feb 2009, 00:02:11 »
Fine script  :good:
You now might add a parameter there to choose between titleText or hint, as in some mission having unplanned hints might be an issue, ie some instruction given via hint are lost forever as hitting H will show the last repairing message instead of the mission instructions one.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Add, fix, refuel and re-arm other vehicle action to driver
« Reply #2 on: 05 May 2009, 18:02:56 »
Does this work for static Mguns as well?
Xbox Rocks

Offline norrin

  • Tutorial Writer
  • **
Re: Add, fix, refuel and re-arm other vehicle action to driver
« Reply #3 on: 07 May 2009, 03:24:06 »
Finally, after some reminding from hoz, I've got round to adding the option of using either titleCut or hint for script messages.  See the first post for the new script and details on how to change the type of script messages (section 4).

@hoz - just checked and it seems to also work for static MGs.  Just make sure you put
Code: [Select]
this setVariable ["Norrn_vcl_mags", (magazines this)]; in the MG's init line in the editor.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Add, fix, refuel and re-arm other vehicle action to driver
« Reply #4 on: 07 May 2009, 03:59:18 »
Not used this script, but to make this script easier to maintain, it would be best if the init lines, that the mission-maker has to use, were not containing code, but rather just scripts

Code: (repair vehicle init) [Select]
[this] execVM "Norrn_SF_supportVcl\init_repairer.sqf"

Code: (Norrn_SF_supportVcl\init_repairer.sqf) [Select]
private "_vehicle";
_vehicle = _this select 0;

_vehicle addEventHandler ["GETIN",
{
  _vehicle = _this select 0;
  _position = _this select 1;
  _crewman = _this select 2;

  if (_position == "driver") then
  {
    nul = [_vehicle, _crewman] execVM "Norrn_SF_supportVcl\add_actions.sqf"
  };
}];

// And then, if you want to change this code or add more initialisation, you don't need to change what you asked the mission-maker to put in the init...

Might also want to do something similar for the repairable vehicle (it is relatively simple, but you still might want to do more init later on).

This is a general suggestion for anyone creating a script for public use: Always keep code away from the user, so you can change it easily and to lessen the change of the user introducing an error. Just ask the mission maker to call/execVM your script with one or more parameters in an array (which also allows you to add more parameters later, as long as you default them, without having to ask the user to change all their init lines).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline norrin

  • Tutorial Writer
  • **
Re: Add, fix, refuel and re-arm other vehicle action to driver
« Reply #5 on: 08 May 2009, 02:21:19 »
Following on from Spooner's timely advice I've now changed the script to reflect his suggestions

So place this in the repair vehicles init line rather than the previous code:
nul = [this] execVM "Norrn_SF_supportVcl\init_repairer.sqf"

NB: 1st post updated with version 04

Offline ZachHox

  • Members
  • *
Hi Norrin,

How can I make this sciprt so that even if outside a vehicle I can repair it? With "if distance > 5" for example to denote the distance.

I've been working on something of my own, doesn't work yet. I'll post it if you want.

And "if damage > 0.4 time = 5sec", "if damage > 0.7 time = 10sec", "if damage > 10 or full time = 20sec". That is just so it won't always take 20 seconds to repair the vehicle. Or does it already do that or is it like a countdown timer so it doesn't matter how much damage it has it will always take, in the current case 30sec?

Course I wanna add it to a person or player so in his init line. To create a repair unit or real engineer actually. :D
However most of all I would prefer to put it in the init.sqf file, simply because I may have more inits for the same unit/person.

So would like this do it;
Code: [Select]
{[this] execVM "Norrn_SF_supportVcl\init_repairer.sqf"} foreach [Player1, Player2, Player3, Player4....]
I can' download the it yet because the downloads are still down, but I surely will. Just to discuss it already. :D


Thanks.