From a3a91d4f45b22fd487ecbc954ad979be5d03efdd Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:38:09 +0300 Subject: init --- Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf | 128 ++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf (limited to 'Server/Missions/M_PLAYERS_Attack_Air') diff --git a/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf b/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf new file mode 100644 index 0000000..d874c2e --- /dev/null +++ b/Server/Missions/M_PLAYERS_Attack_Air/m_init.sqf @@ -0,0 +1,128 @@ +/* Players Attack Script (Hybrid) */ +Private ["_boundaries","_chopper","_group","_jipHandler","_list","_pilot","_players","_ran","_ranDir","_runFor","_ranPos","_target","_targets","_turrets","_uniqueIndex","_uniqueLabel","_vehicle"]; + +_uniqueLabel = _this select 0; +_uniqueIndex = _this select 1; +_runFor = _this select 2; + +//--- Retrieve the players on a side. +_players = []; +_list = Format ["WFBE_%1TEAMS",_runFor] Call GetNamespace; +{ + if !(isNil '_x') then { + if (side _x == _runFor) then { + if (isPlayer(leader _x) && alive(leader _x)) then {_players = _players + [leader _x]}; + }; + }; +} forEach _list; + +//--- Ensure that the team already has a town. +if (count _players == 0) exitWith { + [Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; +}; + +//--- Radio the designated team that a new mission is available. +['NewMissionAvailable','',_runFor] Spawn SideMessage; + +//--- Define the chopper spawn position. +_boundaries = "WFBE_BOUNDARIESXY" Call GetNamespace; + +_ranPos = []; +_ranDir = []; + +_bd = 'WFBE_BOUNDARIESXY' Call GetNamespace; +if !(isNil '_bd') then { + _ranPos = [ + [0+random(200),0+random(200),400+random(200)], + [0+random(200),_bd-random(200),400+random(200)], + [_bd-random(200),_bd-random(200),400+random(200)], + [_bd-random(200),0+random(200),400+random(200)] + ]; + _ranDir = [45,145,225,315]; +} else { + _ranPos = [[0+random(200),0+random(200),400+random(200)],[10000+random(200),0+random(200),400+random(200)]]; + _ranDir = [45,315]; +}; + +_ran = round(random((count _ranPos)-1)); + +//--- This script use PMC units. +_chopper = "Ka60_PMC"; +_group = createGroup resistance; +_vehicle = createVehicle [_chopper,(_ranPos select _ran), [], (_ranDir select _ran), "FLY"]; +_vehicle addEventHandler ['Killed',{[_this select 0,_this select 1,resistance] Spawn UnitKilled}]; + +//--- Man the chopper. +_pilot = ["Soldier_Pilot_PMC",_group,[0,0,0],resistance] Call CreateMan; +_pilot moveInDriver _vehicle; +_pilot = ["Soldier_Pilot_PMC",_group,[0,0,0],resistance] Call CreateMan; +_pilot moveInGunner _vehicle; + +//--- Man the extra turrets. +_config = configFile >> "CfgVehicles" >> _chopper >> "Turrets"; +_turrets = [_config] call BIS_fnc_returnVehicleTurrets; +if (count _turrets > 0) then {[_turrets, [], _vehicle, "Soldier_Pilot_PMC", _group] call SpawnTurrets}; + +//--- Warn the client. +WFBE_M_PLAYERS_Attack_Air = [_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_vehicle,_uniqueLabel,_uniqueIndex]]; +publicVariable 'WFBE_M_PLAYERS_Attack_Air'; +if (isHostedServer || local player) then {[_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_vehicle,_uniqueLabel,_uniqueIndex]] Spawn HandlePVF}; +_jipHandler = [_vehicle,_uniqueLabel,_uniqueIndex] Spawn { + Private ['_chopper','_oldPlayerList','_runFor','_uniqueLabel','_uniqueIndex','_update']; + _chopper = _this select 0; + _uniqueLabel = _this select 1; + _uniqueIndex = _this select 1; + + while {true} do { + _oldPlayerList = playableUnits; + sleep 15; + _update = false; + { + if !(_x in _oldPlayerList) then {_update = true}; + } forEach playableUnits; + + if (_update) then { + WFBE_M_PLAYERS_Attack_Air = [_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_chopper,_uniqueLabel,_uniqueIndex]]; + publicVariable 'WFBE_M_PLAYERS_Attack_Air'; + if (isHostedServer || local player) then {[_runFor,'CLTFNCM_PLAYERS_ATTACK_AIR',[_chopper,_uniqueLabel,_uniqueIndex]] Spawn HandlePVF}; + }; + }; +}; + +//--- Move the chopper toward the target. +while {true} do { + sleep 20; + + _players = []; + { + if !(isNil '_x') then { + if (side _x == _runFor) then { + if (isPlayer(leader _x) && alive(leader _x)) then {_players = _players + [leader _x]}; + }; + }; + } forEach _list; + + if (count _players == 0 || !alive _vehicle || !alive(driver _vehicle) || !canMove _vehicle) exitWith {}; + + _targets = [_vehicle, _players] Call SortByDistance; + _target = _targets select 0; + { + if (vehicle _x == _x && !((vehicle _x) isKindOf "Air")) exitWith {_target = _x}; + } forEach _targets; + + if !(someAmmo _vehicle) then {[_vehicle,resistance] Call RearmVehicle}; + + _vehicle doMove (getPos _target); + {_group reveal _x} forEach (vehicle _target nearEntities 200); +}; + +if (alive _vehicle || count _players == 0) then {_vehicle setDammage 1}; +{if (alive _x || count _players == 0) then {_x setDammage 1}} forEach (units _group); + +//--- Kill the spawned thread if it still runs. +if !(scriptDone _jipHandler) then {terminate _jipHandler}; + +//--- Wait for the client to end up his sync. +sleep 35; + +[Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor],((Format['_WFBE_M_RUNNINGMISSIONS_%1',_runFor]) Call GetNamespace) - 1, true] Call SetNamespace; \ No newline at end of file -- cgit v1.3.1