Jump to content

Boerstil

Member
  • Content Count

    25
  • Joined

  • Last visited

  • Medals

Everything posted by Boerstil

  1. array<IEntity> allChildren = new array<IEntity>(); IEntity specificChild; IEntity child = GetChildren(); while (child) { if (condition) { specificChild = child; } allChildren.Insert(child); child = child.GetSibling(); }; I think this should work, this will give you an Array of all children and a specific child. I can't test it Right Now
  2. Hello! I'm really new to enforce scripting and need some help. I've started to build a functionslibrary for my mission. My question is how do I load the functions so i can use them in triggers and onGamestart etc. ? I've made a scriptfile called BOR_Tools.c with a class called BOR_Tools wich holds functions for spawning vehicles, groups and waypoints. How do i get my functions into the functionlibrary so i can use them? Thanks in advance
  3. Boerstil

    Load functionlibrary

    My bad. I put the files in the wrong sub-scene... 😕 Thanks for the fast reply.
  4. Boerstil

    Run once simulation script

    if (!isServer) exitWith {}; blacklistArray = []; bor_actDist = 2000; [] spawn { private "_unit"; for "_i" from 0 to 1 step 0 do { { _unit = _x; if !(_unit in blacklistArray) then { if (({isPlayer _x AND (_x distance _unit) < bor_actDist} count playableUnits) != 0) then { _unit enableSimulationGlobal True; _unit enableAI "ALL"; _unit hideObjectGlobal False; } else { _unit enableSimulationGlobal false; _unit disableAI "ALL"; _unit hideObjectGlobal true; }; }; } forEach (AllUnits + Vehicles); sleep 5; }; };
  5. I'll share my ai taxi/takeoff script /* Author: Boerstil Description: - Function for aircraft to taxi to catapult then takeoff. Exucution: - Call the function via code/script [_plane,["Catapult1","Catapult2","Catapult3","Catapult4"],_carrier] call BIS_fnc_AircraftCatapultLaunch; Parameter(s): 0: plane/object 1: array of possible catapults 2: carrier/object 3: posWorld of plane (optional) Returns: nothing */ bor_fnc_CarrierTakeOff = { scopeName "takeOff"; _veh = param [0,objNull,[objNull]]; _catapults = param [1,["Catapult1","Catapult2"],[[]]]; _carrier = param [2,objNull,[objNull]]; _pos = param [3,(getPosWorld _veh),[[]]]; private _dir = getDir _veh; private _height = _pos select 2; private _catapult = selectRandom _catapults; private _partClass = ""; if ((_catapult == "Catapult1") || (_catapult == "Catapult2")) then { _partClass = "Land_Carrier_01_hull_04_F"; } else { _partClass = "Land_Carrier_01_hull_07_F"; }; private _carrierObjects = _carrier nearObjects [_partClass , 200]; private _part = _carrierObjects param [0, objNull]; private _configPath = configfile >> "CfgVehicles" >> _partClass >> "Catapults" >> _catapult; private _animations = getArray (_configPath >> "animations"); private _memPoint = getText (_configPath >> "memoryPoint"); private _dirOffset = getNumber (_configPath >> "dirOffset"); private _posCatapult = _part modelToWorld (_part selectionPosition _memPoint); _posCatapult set [2, _height]; private _dirCatapult = (getDir _part - _dirOffset - 180) % 360; private _configPlane = configFile >> "CfgVehicles" >> typeOf _veh; private _velocityLaunch = getNumber (_configPlane >> "CarrierOpsCompatability" >> "LaunchVelocity") max 210; private _velocityIncrease = getNumber (_configPlane >> "CarrierOpsCompatability" >> "LaunchVelocityIncrease") max 75; private _accelerationStep = getNumber (_configPlane >> "CarrierOpsCompatability" >> "LaunchAccelerationStep") max 0.025; private _launchBar = getText (_configPlane >> "CarrierOpsCompatability" >> "LaunchBarMemoryPoint"); if (true) then { waitUntil { if (!alive (driver _veh)) exitWith {breakto "takeOff";true}; !(_carrier getVariable ["landing",false]) && (_part animationPhase (_animations select 0) < 2) }; _veh setFuel 1; _veh engineOn True; _veh setPosWorld _pos; sleep 5; waitUntil { if (!alive (driver _veh)) exitWith {breakto "takeOff";true}; isEngineOn _veh }; while {(_veh distance _pos) < 15} do { _veh setAirplaneThrottle 0.3; _veh setDir _dir; _veh setVelocity [(sin _dir * (25 / 3.6)),(cos _dir * (25 / 3.6)),(velocity _veh select 2)]; if ((_veh distance _posCatapult) < 15) exitWith {_veh setVelocity [0,0,0];}; if (!alive (driver _veh)) exitWith {breakto "takeOff"}; sleep 0.02 }; while {!((getDir _veh) > ((_veh getDir _posCatapult) - 3) && (getDir _veh) < ((_veh getDir _posCatapult) + 3))} do { _veh setAirplaneThrottle 0.3; if (!alive (driver _veh)) exitWith {breakto "takeOff"}; if ((getDir _veh) < (_veh getDir _posCatapult)) then {_veh setDir ((getDir _veh) + 0.5);_veh setVelocityModelSpace [0, (25 / 3.6), 0];} else {_veh setDir ((getDir _veh) - 0.5);_veh setVelocityModelSpace [0, (25 / 3.6), 0];}; sleep 0.025 }; _veh setVelocity [0,0,0]; private _memoryPos = getPosWorld _veh; _veh setVariable ["memoryPos",_memoryPos]; _veh setVariable ["memoryDir",_dir]; _veh animate ["wing_fold_l", 0]; _veh animate ["wing_fold_r", 0]; _veh animate ["wing_fold_cover_l", 0]; _veh animate ["wing_fold_cover_r", 0]; while {(_veh distance _posCatapult) >= 1} do { waitUntil {(_part animationPhase (_animations select 0) < 1)}; _veh setAirplaneThrottle 0.3; _veh setDir (_veh getDir _posCatapult); _veh setVelocity [(sin (_veh getdir _posCatapult) * (25 / 3.6)),(cos (_veh getdir _posCatapult) * (25 / 3.6)),(velocity _veh select 2)]; if (!alive (driver _veh)) exitWith {breakto "takeOff"}; sleep 0.025 }; _veh setPosWorld _posCatapult; _veh setDir _dirCatapult; _veh setBehaviour "AWARE"; _jetPark = [ (str _veh) + "_parked", "onEachFrame", { (_this select 0) setAirplaneThrottle 0.3; (_this select 0) setVelocity [0, 0, 0]; (_this select 0) setPosWorld (_this select 1); (_this select 0) setDir (_this select 2); },[_veh,_posCatapult,_dirCatapult] ] call BIS_fnc_addStackedEventHandler; [_part, _animations, 10] spawn BIS_fnc_Carrier01AnimateDeflectors; sleep 10; [format ["%1",_jetPark], "onEachFrame"] call BIS_fnc_removeStackedEventHandler; _jetPark2 = [ (str _veh) + "_parked", "onEachFrame", { (_this select 0) setAirplaneThrottle 1; (_this select 0) setVelocity [0, 0, 0]; (_this select 0) setPosWorld (_this select 1); (_this select 0) setDir (_this select 2); },[_veh,_posCatapult,_dirCatapult] ] call BIS_fnc_addStackedEventHandler; sleep 5; [format ["%1",_jetPark2], "onEachFrame"] call BIS_fnc_removeStackedEventHandler; _veh allowDamage false; _veh setAirplaneThrottle 1; _veh setPosWorld _posCatapult; _veh setDir _dirCatapult; private _velocity = 0; private _timeStart = time; private _timeDelta = 0; while { speed _veh < _velocityLaunch && {isEngineOn _veh && {((getPos _veh) param [2,0]) < 1}} } do { if (!alive (driver _veh)) exitWith {breakto "takeOff"}; _veh setDir _dirCatapult; _veh setAirplaneThrottle 1; _timeDelta = time - _timeStart; _velocity = _velocityIncrease * _timeDelta; _veh setVelocity [sin _dirCatapult * _velocity,cos _dirCatapult * _velocity,velocity _veh select 2]; sleep _accelerationStep; }; [_part, _animations, 10] spawn BIS_fnc_Carrier01AnimateDeflectors; private _t = time + 1; waitUntil { if (!alive (driver _veh)) exitWith {breakto "takeOff";true}; _velocity = velocity _veh; _velocity set [2,2]; _veh setVelocity _velocity; time > _t }; [_part, _animations, 0] spawn { sleep 6; _this spawn BIS_fnc_Carrier01AnimateDeflectors; }; sleep 5; _veh allowDamage True; _veh setFuel ((_veh getVariable ["savedFuel",1]) - (1 - (fuel _veh))); driver _veh action ["LandGearUp", driver _veh]; }; }
  6. Boerstil

    Replace all mags with tracer mags

    Used this a couple of years ago, should still work. Works only for vanilla magazines. _unit = param [0,objNull]; private _pWeap = primaryWeapon _unit; private _magarray = primaryWeaponMagazine _unit; private _magtype = _magarray select 0; if (isNil "_magtype") exitWith {}; if (_magtype isEqualTo "30Rnd_65x39_caseless_mag") then {_tracermag = "30Rnd_65x39_caseless_mag_Tracer"}; // Blufor if (_magtype isEqualTo "100Rnd_65x39_caseless_mag") then {_tracermag = "100Rnd_65x39_caseless_mag_Tracer"}; // Blufor if (_magtype isEqualTo "150Rnd_556x45_Drum_Mag_F") then {_tracermag = "150Rnd_556x45_Drum_Mag_Tracer_F"}; // Blufor if (_magtype isEqualTo "30Rnd_65x39_caseless_green") then {_tracermag = "30Rnd_65x39_caseless_green_mag_Tracer"}; // Opfor if (_magtype isEqualTo "150Rnd_762x51_Box") then {_tracermag = "150Rnd_762x51_Box_Tracer"}; // Opfor if (_magtype isEqualTo "150Rnd_762x54_Box") then {_tracermag = "150Rnd_762x54_Box_Tracer"}; // Opfor if (_magtype isEqualTo "30Rnd_580x42_Mag_F") then {_tracermag = "30Rnd_580x42_Mag_Tracer_F"}; // Opfor if (_magtype isEqualTo "100Rnd_580x42_Mag_F") then {_tracermag = "100Rnd_580x42_Mag_Tracer_F"}; // Opfor if (_magtype isEqualTo "200Rnd_65x39_cased_Box") then {_tracermag = "200Rnd_65x39_cased_Box_Tracer"}; //Indep if (_magtype isEqualTo "30Rnd_762x39_Mag_F") then {_tracermag = "30Rnd_762x39_Mag_Tracer_F"}; //Indep if (_magtype isEqualTo "30Rnd_545x39_Mag_F") then {_tracermag = "30Rnd_545x39_Mag_Tracer_F"}; //Indep if (_magtype isEqualTo "20Rnd_650x39_Cased_Mag_F") then {_tracermag = "20Rnd_650x39_Cased_Mag_F"}; //Indep if (_magtype isEqualTo "30Rnd_556x45_Stanag") then { if (side _unit == west) then {_tracermag = "30Rnd_556x45_Stanag_Tracer_Red"}; // Blufor if (side _unit == independent) then {_tracermag = "30Rnd_556x45_Stanag_Tracer_Yellow"}; // Indep if (side _unit == east) then {_tracermag = "30Rnd_556x45_Stanag_Tracer_Green"}; // Opfor }; if (_magtype isEqualTo "30Rnd_9x21_Mag") then { if (side _unit == west) then {_tracermag = "30Rnd_9x21_Red_Mag"}; // Blufor if (side _unit == independent) then {_tracermag = "30Rnd_9x21_Yellow_Mag"}; // Indep if (side _unit == east) then {_tracermag = "30Rnd_9x21_Green_Mag"}; // Opfor }; if (_magtype isEqualTo "16Rnd_9x21_Mag") then { if (side _unit == west) then {_tracermag = "16Rnd_9x21_red_Mag"}; // Blufor if (side _unit == independent) then {_tracermag = "16Rnd_9x21_green_Mag"}; // Indep if (side _unit == east) then {_tracermag = "16Rnd_9x21_yellow_Mag"}; // Opfor }; if (_magtype isEqualTo "30Rnd_45ACP_Mag_SMG_01") then { if (side _unit == west) then {_tracermag = "30Rnd_45ACP_Mag_SMG_01_Tracer_Red"}; // Blufor if (side _unit == independent) then {_tracermag = "30Rnd_45ACP_Mag_SMG_01_Tracer_Yellow"}; // Indep if (side _unit == east) then {_tracermag = "30Rnd_45ACP_Mag_SMG_01_Tracer_Green"}; // Opfor }; if (_magtype isEqualTo "30Rnd_9x21_Mag_SMG_02") then { if (side _unit == west) then {_tracermag = "30Rnd_9x21_Mag_SMG_02_Tracer_Red"}; // Blufor if (side _unit == independent) then {_tracermag = "30Rnd_9x21_Mag_SMG_02_Tracer_Yellow"}; // Indep if (side _unit == east) then {_tracermag = "30Rnd_9x21_Mag_SMG_02_Tracer_Green"}; // Opfor }; if (_magtype isEqualTo "200Rnd_556x45_Box_F") then { if (side _unit == west) then {_tracermag = "200Rnd_556x45_Box_Red_F"}; // Blufor if (side _unit == independent) then {_tracermag = "200Rnd_556x45_Box_Tracer_F"}; // Indep if (side _unit == east) then {_tracermag = "200Rnd_556x45_Box_Tracer_Red_F"}; // Opfor }; _magcount = {_x == _magtype} count magazines _unit; _unit removeMagazines _magtype; _unit removePrimaryWeaponItem _magtype; _unit addMagazines [_tracermag, _magcount]; _unit addPrimaryWeaponItem _tracermag; };
  7. Does anyone know-how tog show the progressbar on The client being revived,? Like the ingame revive?
  8. If I understand you right. This should help: if (isServer) then { [o4, "Confirm Identity", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", {}, {}, {confirmed = 1}, {}, [], 5, 0, true, false] remoteExec ["BIS_fnc_holdActionAdd",[0,-2] select isDedicated,true]; };
  9. Not tested: { _x animate ['ramp', 1]; } forEach thislist
  10. https://community.bistudio.com/wiki/BIS_fnc_codePerformance
  11. Boerstil

    Jets DLC Official Feedback

    this animate ["wing_fold_l", 1]; this animate ["wing_fold_r", 1];
  12. Someone was requesting this function in dev-branch forum. So I'll share my script for it. It basically does what it sounds like. Use function where unit is local. loadout = [unit] call bor_fnc_getVehicleLoadout; [unit ,loadout] call bor_fnc_setVehicleLoadout; Parameters: unit: Object loadout: Array from getVehicleLoadout bor_fnc_getVehicleLoadout = { if (!local (_this select 0)) exitWith {}; params ["_veh"]; private _magArray = []; private _wepArray = []; private _itemArray = []; private _bpArray = []; { private ["_mag"]; _mag = [ (((getMagazineCargo _veh) select 0) select _forEachIndex) , (((getMagazineCargo _veh) select 1) select _forEachIndex) ]; _magArray pushBack _mag; } forEach ((getMagazineCargo _veh) select 0); { private ["_mag"]; _wep = [ (((getWeaponCargo _veh) select 0) select _forEachIndex) , (((getWeaponCargo _veh) select 1) select _forEachIndex) ]; _wepArray pushBack _wep; } forEach ((getWeaponCargo _veh) select 0); { private ["_item"]; _item = [ (((getItemCargo _veh) select 0) select _forEachIndex) , (((getItemCargo _veh) select 1) select _forEachIndex) ]; _itemArray pushBack _item; } forEach ((getItemCargo _veh) select 0); { private ["_bp"]; _bp = [ (((getBackpackCargo _veh) select 0) select _forEachIndex) , (((getBackpackCargo _veh) select 1) select _forEachIndex) ]; _bpArray pushBack _bp; } forEach ((getBackpackCargo _veh) select 0); _loadout = [ _magArray, _wepArray, _itemArray, _bpArray ]; _loadout }; bor_fnc_setVehicleLoadout = { if (!local (_this select 0)) exitWith {}; params ["_veh","_loadout"]; private _magArray = (_loadout select 0); private _wepArray = (_loadout select 1); private _itemArray = (_loadout select 2); private _bpArray = (_loadout select 3); clearWeaponCargoGlobal _veh; clearMagazineCargoGlobal _veh; clearItemCargoGlobal _veh; clearBackpackCargoGlobal _veh; { _veh addMagazineCargoGlobal _x; } forEach _magArray; { _veh addWeaponCargoGlobal _x; } forEach _wepArray; { _veh addItemCargoGlobal _x; } forEach _itemArray; { _veh addBackpackCargoGlobal _x; } forEach _bpArray; };
  13. I use this if (!isServer) exitWith {}; [] spawn { blacklistArray = []; private "_unit"; while {True} do { { _unit = _x; if !((_unit isKindOf "Air") || ((vehicle _unit) isKindOf "Air")) then { if (({isPlayer _x AND (_x distance _unit) < viewDistance} count playableUnits) != 0) then { _unit enableSimulationGlobal True; _unit enableAI "ALL"; _unit hideObjectGlobal False; } else { _unit enableSimulationGlobal false; _unit disableAI "ALL"; _unit hideObjectGlobal true; }; }; } forEach ((AllUnits + Vehicles) - blacklistArray); sleep 5; }; };
  14. Boerstil

    Task description with variables

    use format https://community.bistudio.com/wiki/format ex. ["task", format ["We need MEDEVAC at %1",_nearestCity], "MEDEVAC", "MEDEVAC", getPos _wounded, "created"]
  15. waitUntil {!isNull player}; waitUntil {local player}; waitUntil {alive player}; Had the same issue. this fixed it for me.
  16. maybe this will work? _rad is your placement radius { _rad = 1000; _pos = getPos _x; _newX = (_pos select 0) + (sin 360) * (random _rad); _newY = (_pos select 1) + (cos 360) * (random _rad); _newPos = [_newX, _newY, 0]; _x setPos _newPos; } forEach [a,b];
  17. Feel free to comment critisism and suggestions in this thread. Description: In my missions you will get objectives randomly around the map. The main objective is to take control of areas defended by either Opfor or Independent. There is a 50/50 chance to spawn a side mission in the area that needs to be completed before you can complete the main mission. The mission is succeded when the objectives are done. The mission is failed if you run out of respawntickets. Features: 1-16 Players. Random Startlocation. Different Objectives in random locations. Random Time / Date. Dynamic Weather. Choose between Mx and Spar Weapon systems. Supplydrop and Helicopter Transport is Avalible in the Supportmenu. Uses "End Game Revive System". Quick Guide: You got two helicopters to your disposal. The squadleader assigns a objective in the taskmenu and a landingzone will be created in the vicinity of choosen objective. All squadmembers in the base must be in the helo for liftoff. You can call for extraction in the Supportmenu. You can call for SupplyDrop or VehicleDrop. Extraction and supplydrop is not avalible if the helicopters is busy. Download: Altis Tanoa Stratis Chernarus Takistan Zargabad Kunduz Thanks to Bohemia Interactive for an awsome game. Styrfart for bugtesting. Bearnose for bugtesting. Sorry for spelling / grammar mistakes since english isn't my main language.
  18. I have a problem with setPos in my mission. I have a Mainbase created with a script and moves the playable units there with the initPlayerLocal.sqf. The Player is moved to a random chair inside the hq. It works most of the time, but sometimes the player is standing where he is placed in the editor. Here is my InitPlayerLocal: And here is a bit of the hq creation script: _briefchair18 = createVehicle ["Land_CampingChair_V2_F",_hqPos, [], 0, "NONE"]; _briefchair18 setDir ((getDir _hq) -180); _briefchair18 setPos (_hq modelToWorld [4,-0.4,-3.2]); Chairs pushBack _briefchair18; _chairArray = []; { private ["_position"]; _position = getPosATL _x; _chairArray pushBack _position; } forEach Chairs; missionNamespace setVariable ["Chair_Positions", _chairArray, true]; publicVariable "Chair_Positions"; The first 18 chairs is created the same way as the last one.
  19. Boerstil

    Paradropping an arsenal

    cargo = "B_supplyCrate_F" createVehicle getpos thistrigger;cargo setPos [getPos thistrigger select 0, getPos thistrigger select 1, 400];[objnull, cargo] call BIS_fnc_curatorobjectedited; ["AmmoboxInit",[cargo,true,{true}]] spawn BIS_fnc_arsenal;
  20. I'm working on a Artillery script. I want the artillery to fire if someone on the same side has spotted a playableUnit. This is what I've got so far. Is there a more efficient way to do this? if (!isServer) exitWith {}; private ["_veh","_side","_ammo"]; _veh = _this select 0; _side = side _veh; _ammo = getArtilleryAmmo [_veh] select 0; _veh setVariable ["Target",nil]; [_veh,_side,_ammo] spawn { params ["_veh","_side","_ammo"]; private ["_spotter","_targetPos"]; while {true} do { { if ((side _x) == _side) then { _spotter = _x; }; { if ((_spotter knowsAbout _x) > 1.5) then { _targetPos = ((_spotter targetKnowledge _x) select 6); hint format ["%1 has ben spotted at %2",(name _x),_targetPos]; _veh setVariable ["Target",_targetPos]; }, { _veh setVariable ["Target",nil]; }; } forEach playableUnits; } forEach AllUnits; sleep 5; }; }; [_veh,_side,_ammo] spawn { params ["_veh","_side","_ammo"]; private ["_spotter","_targetPos"]; while {true} do { if (!isNil {_veh getVariable "Target"}) then { if((_veh getVariable "Target") inRangeOfArtillery [[_veh], _ammo]) then { hint format ["%1 Is Ready To Fire At %2",(name _veh),(_veh getVariable "Target")]; sleep 60; }; }; sleep 5; }; };
  21. I use this waitUntil {local _unit}; waitUntil {!isNull _unit};
  22. _mkr = "MarkerName"; _pos = getMarkerpos _mkr; _rad = getMarkerSize _mkr; _spawnPos = [_pos, 1, (_rad select 0), 2, 0, 30, 0, [],[_pos],[]] call BIS_fnc_findSafePos; _enemygrp = [_spawnPos, East,(configFile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad"),[],[],[],[],[],180] call BIS_fnc_spawnGroup; Not tested but should work.
  23. https://community.bistudio.com/wiki/BIS_fnc_addRespawnPosition [<target>,<position>] call BIS_fnc_addRespawnPosition; If you want to respawn on squadleader for group1 use this: _leaderRespawn = [group1, leader group1] call BIS_fnc_addRespawnPosition; The Respawnposition will be disabled while the unit is dead.
×