Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HALO #324

Merged
merged 18 commits into from
Jun 20, 2018
Merged

HALO #324

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// [player,3] spawn Achilles_fnc_chute;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

params ["_unit", "_delay"];
params ["_unit", ["_delay", 0, [0]]];

sleep _delay;

Expand All @@ -38,23 +38,24 @@ if (!isPlayer _unit) then
private _item_cargo = getItemCargo _container;

removeBackpack _unit;
waitUntil {sleep 1; !alive _unit || getPos _unit select 2 < 150};
waitUntil {sleep 0.1; !alive _unit || getPos _unit select 2 < 120};
private _chuteClass = ["b_parachute", _backpackClass] select (getText (configfile >> "CfgVehicles" >> _backpackClass >> "backpackSimulation") isEqualTo "ParachuteSteerable");
_unit addBackpack _chuteClass;
_unit action ["openParachute"];
_unit addBackpack _backpackClass;
clearAllItemsFromBackpack _unit;
_container = backpackContainer _unit;
{_container addWeaponCargo [_x, (_weapon_cargo select 1) select _forEachIndex]} forEach (_weapon_cargo select 0);
{_container addMagazineCargo [_x, (_magazine_cargo select 1) select _forEachIndex]} forEach (_magazine_cargo select 0);
{_container addItemCargo [_x, (_item_cargo select 1) select _forEachIndex]} forEach (_item_cargo select 0);
} else
{
waitUntil {sleep 1; !alive _unit || getPos _unit select 2 < 150};
waitUntil {sleep 0.1; !alive _unit || getPos _unit select 2 < 120};
_unit addBackpack "b_parachute";
_unit action ["openParachute"];
};
// prevent AI to be killed by fall damage
waitUntil {isTouchingGround _unit or (!alive _unit)};
waitUntil {sleep 0.1; isTouchingGround _unit or (!alive _unit)};
_unit removeEventHandler ["HandleDamage",_id];

} else
Expand Down Expand Up @@ -87,6 +88,7 @@ if (!isPlayer _unit) then
waitUntil {isTouchingGround _unit or (getPos _unit select 2) < 1 or (!alive _unit)};
deleteVehicle _packHolder;
_unit addBackpack _backpack_class;
clearAllItemsFromBackpack _unit;
_container = backpackContainer _unit;
{_container addWeaponCargo [_x, (_weapon_cargo select 1) select _forEachIndex]} forEach (_weapon_cargo select 0);
{_container addMagazineCargo [_x, (_magazine_cargo select 1) select _forEachIndex]} forEach (_magazine_cargo select 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
Returns:
BOOL
*/
params [["_group", grpNull, [grpNull]], ["_end_pos", [], [[]], 3], ["_target", objNull, [objNull]]];
params [["_group", grpNull, [grpNull]], ["_endPos", [], [[]], 3], ["_target", objNull, [objNull]]];

//////////////////////////////////////
// executed on second script call
Expand All @@ -31,8 +31,8 @@ if (isNil "Achilles_var_eject_init_done") then
publicVariableServer "Achilles_fnc_eject_passengers";
Achilles_var_eject_init_done = true;
};
private _wp_index = currentwaypoint _group;
private _wp = [_group,_wp_index];
private _wpIndex = currentwaypoint _group;
private _wp = [_group,_wpIndex];
_wp setwaypointdescription localize "STR_AMAE_PARADROP";
_wp setWaypointName localize "STR_AMAE_PARADROP";

Expand All @@ -54,50 +54,74 @@ private _vehsType = "";
// Kex: prevent pilot from being stupid
_group allowFleeing 0;

_vehsType = typeOf (_vehsGroup select 0);
_vehsGroup params ["_firstVeh"];
_vehsType = typeOf _firstVeh;
private _radius = 0;
private _vector = [];
// displace effective target position for flyby
private _start_pos = position leader _group;
private _startPos = position leader _group;
if (_vehsType isKindOf "Helicopter") then
{
_vector = _end_pos vectorDiff _start_pos;
_vector = _endPos vectorDiff _startPos;
_vector set [2,0];
_vector = vectorNormalized _vector;
_vector = _vector vectorMultiply 1000;
_radius = 1200;
_radius = 1000;
} else
{
_vector = [0,0,0];
_radius = 100;
_radius = 0;
};
private _wp_pos = _end_pos vectorAdd _vector;
private _wpPos = _endPos vectorAdd _vector;

[_vehsGroup,_wp_pos,_radius] spawn
// adjust distance for deployment according to crew count and velocity
private _speed = getNumber (configfile >> "CfgVehicles" >> _vehsType >> "maxSpeed");
private _coefName = ["normalSpeedForwardCoef", "limitedSpeedCoef"] select (speedMode _group == "LIMITED");
_speed = _speed * getNumber (configfile >> "CfgVehicles" >> _vehsType >> _coefName);

// every second a unit ejects. We want the middle unit right above the location
private _crew = crew _firstVeh;
private _passengerCount = {(assignedVehicleRole _x) select 0 == "CARGO"} count _crew;
_radius = _radius + _passengerCount/2 * _speed/3.6;

// account for speed displacement
if (getPos _firstVeh select 2 > 150) then
{
// fitted function for HALO
_radius = _radius + 4.2e-4 * _speed^3 * (1 - 1/(1 + (75/_speed)^2.2));
}
else
{
// fitted function for HAHO
_radius = _radius + 0.338 * _speed;
};

[_vehsGroup,_wpPos,_radius] spawn
{
params ["_vehsGroup", "_wpPos", "_radius"];
private _vehsRdy = false;
waituntil
{
params ["_vehsGroup","_wp_pos","_radius"];
private "_veh";
private _vehsRdy = false;
private _aliveCount = 0;
{
_veh = _x;
if ((position _veh) distance2D _wp_pos < _radius and !_vehsRdy) then
private _veh = _x;
_aliveCount = _aliveCount + 1;
if ((position _veh) distance2D _wpPos < _radius) exitWith
{
[_vehsGroup] call Achilles_fnc_eject_passengers;
_vehsRdy = true;
};
} forEach (_vehsGroup select {alive _x});

if (_aliveCount == 0) then {_vehsRdy = true};
sleep 1;
_vehsRdy;
};
};

_group setVariable ["Achilles_var_paradrop",true];

[_group,_wp_index,_wp_pos] spawn
[_group,_wpIndex,_wpPos] spawn
{
params ["_group","_wp_index","_wp_pos"];
_group addWaypoint [_wp_pos, 100, _wp_index];
params ["_group","_wpIndex","_wpPos"];
_group addWaypoint [_wpPos, 100, _wpIndex];
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
params[["_playersToTeleport", [objNull]], ["_teleportLocation", [0,0,0]], ["_showTeleportMessage", true], ["_includeVehicles", true]];
params
[
["_playersToTeleport", [objNull]],
["_teleportLocation", [0,0,0]],
["_showTeleportMessage", true],
["_additionalOption", 0]
];

// Show some text to the players that are going to be teleported.
if (_showTeleportMessage) then
Expand All @@ -9,19 +15,29 @@ if (_showTeleportMessage) then
[[], {if (player in Ares_playersToShowMessageTo) then { titleText [localize "STR_AMAE_YOU_ARE_BEING_TELEPORTED", "BLACK", 1]; sleep 1; titleFadeOut 2}}] remoteExec ["spawn", -2];
};

private _includeVehicles = (_additionalOption == 1);
private _doHALO = (_additionalOption == 2);

if (_doHALO) then
{
_teleportLocation set [2, 3000];
};

while {!(_playersToTeleport isEqualto [])} do
{
private _unit_to_tp = [_playersToTeleport select 0, vehicle (_playersToTeleport select 0)] select _includeVehicles;

[_unit_to_tp, _teleportLocation, _showTeleportMessage] spawn
[_unit_to_tp, _teleportLocation, _showTeleportMessage, _doHALO] spawn
{
params ["_unit", "_teleportLocation", "_showTeleportMessage"];
params ["_unit", "_teleportLocation", "_showTeleportMessage", "_doHALO"];
if (_showTeleportMessage) then
{
sleep 1;
};

_unit setVehiclePosition [_teleportLocation, [], 0, "FORM"];
_unit setPos [getPos _unit select 0, getPos _unit select 1, _teleportLocation select 2];
if (_doHALO) then {[_unit] call Achilles_fnc_chute};
};

_playersToTeleport = [_playersToTeleport - [_unit_to_tp], _playersToTeleport - crew _unit_to_tp] select _includeVehicles;
Expand Down
13 changes: 13 additions & 0 deletions @AresModAchillesExpansion/addons/language_f/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,13 @@
<Japanese>モード</Japanese>
<Chinesesimp>模式</Chinesesimp>
</Key>
</Key>
<Key ID="STR_ADDITIONAL_OPTION">
<Original>Additional option</Original>
<English>Additional option</English>
<French>Option supplémentaire</French>
<German>Zusatzoption</German>
</Key>
<Key ID="STR_AMAE_ALL_OBJECTS_IN_MISSION">
<Original>All objects in mission</Original>
<English>All objects in mission</English>
Expand Down Expand Up @@ -5168,6 +5175,12 @@
<Japanese>空挺</Japanese>
<Chinesesimp>空投</Chinesesimp>
</Key>
<Key ID="STR_AMAE_HALO">
<Original>HALO</Original>
<English>HALO</English>
<French>HALO</French>
<German>HALO</German>
</Key>
<Key ID="STR_AMAE_WP_SEARCH_BUILDING">
<Original>SEARCH BUILDING</Original>
<English>SEARCH BUILDING</English>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ private _dialogResult = [
[localize "STR_AMAE_MODE",[localize "STR_AMAE_ZEUS", localize "STR_AMAE_ALL",localize "STR_AMAE_SELECTION",localize "STR_AMAE_SIDE", localize "STR_AMAE_PLAYERS", localize "STR_AMAE_GROUP"]],
["", [""]],
[localize "STR_AMAE_SIDE","ALLSIDE"],
[localize "STR_AMAE_INCLUDE_VEHICLES",[localize "STR_AMAE_FALSE",localize "STR_AMAE_TRUE"]]
[localize "STR_ADDITIONAL_OPTION",[localize "STR_AMAE_NONE", localize "STR_AMAE_INCLUDE_VEHICLES", localize "STR_AMAE_HALO"]]
],
"Achilles_fnc_RscDisplayAttributes_selectPlayers"
] call Ares_fnc_ShowChooseDialog;

if (_dialogResult isEqualTo []) exitWith {};

private _playersToTeleport = switch (_dialogResult select 0) do
_dialogResult params ["_mode", "", "_side_index", "_additionalOption"];

private _playersToTeleport = switch (_mode) do
{
case 0:
{
Expand All @@ -41,7 +43,6 @@ private _playersToTeleport = switch (_dialogResult select 0) do
};
case 3:
{
private _side_index = _dialogResult select 2;
if (_side_index == 0) exitWith {[player]};
private _side = [east,west,independent,civilian] select (_side_index - 1);
allPlayers select {(alive _x) and (side _x == _side)};
Expand All @@ -63,10 +64,9 @@ if (_playersToTeleport isEqualTo []) exitWith
["No players in selection!"] call Ares_fnc_ShowZeusMessage;
playSound "FD_Start_F";
};
private _includeVehicles = if ((_dialogResult select 3) == 0) then {false} else {true};

// Call the teleport function.
[_playersToTeleport, _tp_pos, true, _includeVehicles] call Ares_fnc_TeleportPlayers;
[_playersToTeleport, _tp_pos, true, _additionalOption] call Ares_fnc_TeleportPlayers;

[objNull, format["Teleported %1 players to %2", (count _playersToTeleport), _tp_pos]] call bis_fnc_showCuratorFeedbackMessage;

Expand Down
Loading