Jump to content

Schatten

Member
  • Content Count

    772
  • Joined

  • Last visited

  • Medals

Posts posted by Schatten


  1. Seems, this code works:

    while {true} do {
    _nearestVehicles = nearestObjects [player, ["Car", "Tank", "Air"], 1000];
    
    {
    	_vehicle = _x;
    
    	if (({alive _x} count (crew _vehicle)) == 0) then {
    		_unitGroup = createGroup civilian;
    
    		_unit = _unitGroup createUnit ["TK_CIV_Takistani01_EP1", getPos _vehicle, [], 0, "NONE"];
    
    		_unit moveInDriver _vehicle;
    
    		_unit action ["lightOff", _vehicle];
    
    		moveOut _unit;
    
    		deleteVehicle _unit;
    
    		deleteGroup _unitGroup;
    	};
    }
    forEach _nearestVehicles;
    
    sleep 10;
    };


  2. kyopower, save code

    while {true} do {
    _nearestVehicles = nearestObjects [player, ["Car", "Tank", "Air"], 1000];
    
    {
    	_reflectors = configFile >> "CfgVehicles" >> (typeOf _x) >> "Reflectors";
    
    	_reflectorsNumber = count _reflectors;
    
    	for "_i" from 0 to (_reflectorsNumber - 1) do {
    		_reflector = _reflectors select _i;
    
    		_x setHit [getText (_reflector >> "selection"), 1];
    	};
    }
    forEach _nearestVehicles;
    
    sleep 10;
    };

    and launch from init.sqf using

    execVM "scriptName.sqf";

    This script doesn't work properly. For example, it destroys only front lights of HMMWV CROWS (M2).


  3. Is it?

    Function:

    private ["_keystonePos", "_playerPos", "_relativeDir", "_relativePos"];
    
    _relativeDir = [player, _this] call BIS_fnc_relativeDirTo;
    
    _playerPos = getPos player;
    _keystonePos = getPos _this;
    
    _relativePos = [(_playerPos select 0) - (_keystonePos select 0), (_playerPos select 1) - (_keystonePos select 1), (_playerPos select 2) - (_keystonePos select 2)];
    
    [_relativePos, _relativeDir]

    Usage:

    _array = _keystone call functionName;


  4. Try to use this code:

    _nearestVehicles = nearestObjects [player, ["Car", "Tank", "Air"], 1000];
    
    {
    _vehicle = _x;
    
    if (({alive _x} count (crew _vehicle)) == 0) then {
    	_unitGroup = createGroup civilian;
    
    	_unit = "TK_CIV_Takistani01_EP1" createUnit [getPos _vehicle, _unitGroup];
    
    	_unit moveInDriver _vehicle;
    
    	_unit action ["lightOff", _vehicle];
    
    	deleteVehicle _unit;
    
    	deleteGroup _unitGroup;
    };
    }
    forEach _nearestVehicles;


  5. Add this command in init field:

    this execVM "watchForAltitude.sqf";

    watchForAltitude.sqf:

    while {true} do {
    _position = getPosASL _this;
    
    if (!(surfaceIsWater _position)) then {_position = ASLtoATL _position};
    
    _altitude = _position select 2;
    
    if (_altitude <= 3) then {
    	switch (true) do {
    		case (_this isKindOf "B_Heli_Transport_01_F"): {
    			{_this animateDoor _x} forEach [
    				[_doorname, _phase, _now],
    				...
    			];
    		};
    		case (_this isKindOf "B_Heli_Transport_03_base_F"): {
    			{_this animateDoor _x} forEach [
    				[_doorname, _phase, _now],
    				...
    			];
    		};
    	};
    }
    else {
    	switch (true) do {
    		case (_this isKindOf "B_Heli_Transport_01_F"): {
    			{_this animateDoor _x} forEach [
    				[_doorname, _phase, _now],
    				...
    			];
    		};
    		case (_this isKindOf "B_Heli_Transport_03_base_F"): {
    			{_this animateDoor _x} forEach [
    				[_doorname, _phase, _now],
    				...
    			];
    		};
    	};
    };
    
    sleep 0.1;
    };

    _doorname, _phase and _now you need to take from configs of Ghosthawk and Huron (use config viewer).


  6. My version of function to detect whether is object within marker of "ellipse" or "rectangle" type:

    private ["_angle", "_distance", "_markerName", "_markerPosition", "_markerSize", "_markerSizeA", "_markerSizeB", "_object"];
    
    _object = _this select 0;
    _markerName = _this select 1;
    
    _markerPosition = getMarkerPos _markerName;
    _markerSize = getMarkerSize _markerName;
    
    _markerSizeA = _markerSize select 0;
    _markerSizeB = _markerSize select 1;
    
    _angle = ([_markerPosition, _object] call BIS_fnc_dirTo) - (markerDir _markerName);
    
    if (_angle < 0) then {_angle = 360 + _angle};
    
    if ((markerShape _markerName) == "ELLIPSE") then {
    _distance = _markerSizeA * _markerSizeB / (sqrt ((_markerSizeA * (cos _angle)) ^ 2 + (_markerSizeB * (sin _angle)) ^ 2));
    
    _markerSizeA = abs (_distance * (sin _angle));
    _markerSizeB = abs (_distance * (cos _angle));
    };
    
    _distance = [_object, _markerPosition] call BIS_fnc_distance2D;
    
    ((abs (_distance * (sin _angle))) < _markerSizeA) and {(abs (_distance * (cos _angle))) < _markerSizeB}

    Usage:

    isWithinMarker = compile (preprocessFileLineNumbers "isWithinMarker.sqf");
    
    if ([player, "marker1"] call isWithinMarker) then {hint "You are within marker area"};


  7. I'd like all boats to spawn with the same init line (which adds a push back script to the player's menu while in or near the boat).

    One of solutions:

    player addAction ["Something", "script.sqf", nil, 1.5, true, true, "", "((typeOf cursorTarget) in boats) and {(cursorTarget distance player) <= 5}"];
    
    player addAction ["Something", "script.sqf", nil, 1.5, true, true, "", "(typeOf (vehicle player)) in boats"];


  8. By default drivers/pilots (turret path is [-1]) or commanders ([1] or [0,0]) have smoke launcher. So you need to use

    this removeWeaponTurret ["SmokeLauncher", [-1]]

    or

    this removeWeaponTurret ["SmokeLauncher", [1]]

    or

    this removeWeaponTurret ["SmokeLauncher", [0,0]]

    More universal solution:

    {if ("SmokeLauncher" in (this weaponsTurret _x)) exitWith {this removeWeaponTurret ["SmokeLauncher", _x]}} forEach (allTurrets this);

×