23 Mai 2024 à 06:45:20

Nouvelles:

Teamspeak 3 OFCRA
IP : ts.ofcra.org
Mot de passe : mineisbiggerthanyours
Discord: https://discord.gg/bWtGS7N


/!\ L'OFCRA RECRUTE /!\


Switch gunner-driver

Démarré par BaBa, 29 Juillet 2012 à 20:04:22

« précédent - suivant »

0 Membres et 1 Invité sur ce sujet

BaBa

Salut à tous!

J'ai un blanc quant au moyen d'activer le switch gunner-driver pour les MBT et VCI. C'est un module ou un script?  :ho:


paquito

Un script du kit MJ avec une ligne d'init à mettre dans le blindé.


Cirav

#2
Switch gunner-driver

Il faut mettre dans l'init du véhicule : nul = this execVM "VehicleSwapRole.sqf";

Et mettre dans le dossier de la mission le fichier VehicleSwapRole.sqf

// VehicleSwapRole.sqf
// -------------------
//
// This script gives back the "swap gunner" functionnality to vehicles that do not
// have it anymore in ACE (Bradleys, Abrams...)
// It adds a "To driver's seat" and a "To gunner's seat" action to the vehicle.
// These actions can be triggered, as in vanilla game, with the SwapGunner key.
//
// Use: in the editor, put the following in the vehicle's init line:
//    nul = this execVM "VehicleSwapRole.sqf";
//
// ---------------------------------------------------------------------------------


if( typeName _this == "ARRAY" ) then  // called by an action
{
_veh = _this select 0;
_caller = _this select 1;
_arg = _this select 3;

switch (_arg) do
{
case "ToDriver":
{
_turret = [];

_cmdTurret = _veh getVariable "CommanderTurret";
if( (count _cmdTurret > 0) and (_caller == _veh turretUnit _cmdTurret) ) then
{
_turret = _cmdTurret;
};

_gunTurret = _veh getVariable "GunnerTurret";
if( (count _gunTurret > 0) and (_caller == _veh turretUnit _gunTurret) ) then
{
_turret = _gunTurret;
};

_pos = getPos _veh;
_pos = [_pos select 0, _pos select 1, -100];

_crew = driver _veh;
_bCrew = not isNull _crew;
if( _bCrew and (not local _crew) ) exitWith { hint "You can switch only with an AI crew!"; };

if( _bCrew ) then { _crew setPos _pos; };
_caller setPos _pos;
sleep 0.01;
_caller moveInDriver _veh;
if( _bCrew and (count _turret > 0) ) then
{
_crew moveInTurret [_veh, _turret];
};

// hint format ["To driver\nfrom turret %1", _turret];
};

case "ToGunner":
{
_turret = _veh getVariable "GunnerTurret";
if( count _turret > 0 ) then
{
_pos = getPos _veh;
_pos = [_pos select 0, _pos select 1, -100];

_crew = _veh turretUnit _turret;
_bCrew = not isNull _crew;
if( _bCrew and (not local _crew) ) exitWith { hint "You can switch only with an AI crew!"; };

if( _bCrew ) then { _crew setPos _pos; };
_caller setPos _pos;
sleep 0.01;
_caller moveInTurret [_veh, _turret];
if( _bCrew ) then { _crew moveInDriver _veh; };
};

// hint format ["To gunner\nin turret %1", _turret];
};
};
}
else  // called for a vehicle initialization
{
_veh = vehicle _this;

_veh addAction ["To driver's seat (sqf)", "VehicleSwapRole.sqf", "ToDriver", 10, false, true, "SwapGunner", "(_this == gunner _target) or (_this == commander _target)"];
_veh addAction ["To gunner's seat (sqf)", "VehicleSwapRole.sqf", "ToGunner", 10, false, true, "SwapGunner", "_this == driver _target"];
// _veh addAction ["To commander's seat (sqf)", "VehicleSwapRole.sqf", "ToCommander", 10, false, true, "SwapGunner", "_this == driver _target"];

_veh setVariable ["GunnerTurret", [], false];
_bGunT = false;

_veh setVariable ["CommanderTurret", [], false];
_bCmdT = false;

_mainTurrets = configFile >> "CfgVehicles" >> (typeof _veh) >> "turrets";
_nmt = count _mainTurrets;

for [{_i = 0}, {_i < _nmt}, {_i = _i + 1}] do
{
_mt = configName (_mainTurrets select _i);

_a = toArray (toUpper _mt);
_a resize 9;
_mt = toString _a;

switch (_mt) do
{
case "MAINTURRE": // "MainTurret"
{
_veh setVariable ["GunnerTurret", [_i], false];
_bGunT = true;
};
case "COMMANDER": // "CommanderOptics" or "CommanderTurret"
{
_veh setVariable ["CommanderTurret", [_i], false];
_bCmdT = true;
};
case "OBSTURRET": // "ObsTurret" (StrykerRV)
{
if( not _bCmdT ) then
{
_veh setVariable ["CommanderTurret", [_i], false];
_bCmdT = true;
};
};
};

_subTurrets = (_mainTurrets select _i) >> "turrets";
_nst = count _subTurrets;

for [{_j = 0}, {_j < _nst}, {_j = _j + 1}] do
{
_st = configName (_subTurrets select _j);

_a = toArray (toUpper _st);
_a resize 9;
_st = toString _a;

if( _st == "COMMANDER" ) then  // "CommanderOptics" or "CommanderTurret"
{
_veh setVariable ["CommanderTurret", [_i,_j], false];
_bCmdT = true;
};
};

if( _bGunT and _bCmdT ) exitWith {};
};

if( (not _bGunT) and _bCmdT ) then
{
_veh setVariable ["GunnerTurret", _veh getVariable "CommanderTurret", false];
_veh setVariable ["CommanderTurret", [], false];
};

/*
_gunT = _veh getVariable "GunnerTurret";
_cmdT = _veh getVariable "CommanderTurret";
_debug = format ["Gunner's Turret = %1\nCommander's Turret = %2", _gunT, _cmdT];
hint _debug;
sleep 3;
hint "";
*/
};


BaBa