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 9 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 < 100};
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 < 100};
_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 @@ -54,7 +54,8 @@ 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
Expand All @@ -65,30 +66,51 @@ if (_vehsType isKindOf "Helicopter") then
_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;

// 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing

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,_wp_pos,_radius] spawn
{
params ["_vehsGroup", "_wp_pos", "_radius"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

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 _wp_pos < _radius) exitWith
{
[_vehsGroup] call Achilles_fnc_eject_passengers;
_vehsRdy = true;
};
} forEach (_vehsGroup select {alive _x});

if (_aliveCount == 0) then {_vehsRdy = true};
sleep 1;
_vehsRdy;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
params[["_playersToTeleport", [objNull]], ["_teleportLocation", [0,0,0]], ["_showTeleportMessage", true], ["_includeVehicles", true]];
params[["_playersToTeleport", [objNull]], ["_teleportLocation", [0,0,0]], ["_showTeleportMessage", true], ["_additionalOption", 0]];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make it into multiple lines so it can be read


// Show some text to the players that are going to be teleported.
if (_showTeleportMessage) then
Expand All @@ -9,19 +9,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
Original file line number Diff line number Diff line change
Expand Up @@ -162,46 +162,15 @@ private _rpSize = 20; // TODO make this a dialog parameters?
private _lzLogic = [_spawn_position, _allLzLogics, _lzdz_algorithm] call Achilles_fnc_logicSelector;
private _lzPos = position _lzLogic;

// Adjust spawn position for HALO
if (_lzdz_type isEqualTo 3) then {_spawn_position set [2, 3000]};

// create the transport vehicle
private _vehicleInfo = [_spawn_position, _spawn_position getDir _lzPos, _vehicle_type, _side] call BIS_fnc_spawnVehicle;
_vehicleInfo params ["_vehicle", "_", "_vehicleGroup"];
private _vehicleUnloadWp = _vehicleGroup addWaypoint [_lzPos, _lzSize];
if (_vehicle isKindOf "Air" and (_dialogResult select 6 > 0)) then
{
_vehicleUnloadWp setWaypointType "SCRIPTED";
private _script = ["\achilles\functions_f_achilles\scripts\fn_wpParadrop.sqf", "\achilles\functions_f_achilles\scripts\fn_wpFastrope.sqf"] select (_dialogResult select 6 == 1);
_vehicleUnloadWp setWaypointScript _script;
} else
{
_vehicleUnloadWp setWaypointType "TR UNLOAD";
};

// Make the driver full skill. This makes him less likely to do dumb things
// when they take contact.
(driver (vehicle (leader _vehicleGroup))) setSkill 1;

if (_vehicle_type isKindOf "Air") then
{
// Special settings for helicopters. Otherwise they tend to run away instead of land
// if the LZ is hot.
{
_x allowFleeing 0; // Especially for helos... They're very cowardly.
} forEach (crew (vehicle (leader _vehicleGroup)));
_vehicleUnloadWp setWaypointTimeout [0,0,0];
}
else
{
_vehicleUnloadWp setWaypointTimeout [5,10,20]; // Give the units some time to get away from truck
};
_vehicleInfo params ["_vehicle", "", "_vehicleGroup"];

// Generate the waypoints for after the transport drops off the troops.
if (_vehicle_behaviour == 0) then
{
// RTB and despawn.
private _vehicleReturnWp = _vehicleGroup addWaypoint [_spawn_position, 0];
_vehicleReturnWp setWaypointTimeout [2,2,2]; // Let the unit stop before being despawned.
_vehicleReturnWp setWaypointStatements ["true", "deleteVehicle (vehicle this); {deleteVehicle _x} foreach thisList;"];
};
// Adjust altitude for HALO
if (_lzdz_type isEqualTo 3) then {_vehicle flyInHeight 3000};

// Add vehicle to curator
[[_vehicle]] call Ares_fnc_AddUnitsToCurator;
Expand Down Expand Up @@ -248,7 +217,7 @@ _infantry_group addWaypoint [_rpPos, _rpSize];

// Load the units into the vehicle.
{
_x moveInCargo (vehicle (leader _vehicleGroup));
_x moveInCargo _vehicle;
} forEach _infantry_list;

// Add infantry to curator
Expand All @@ -260,6 +229,47 @@ if (_vehicle getVariable ["Achilles_var_noFastrope", false]) exitWith
{deleteVehicle _x} forEach _infantry_list;
};

// create a waypoint for deploying the units
private _vehicleUnloadWp = _vehicleGroup addWaypoint [_lzPos, _lzSize];
if (_vehicle isKindOf "Air" and (_lzdz_type > 0)) then
{
_vehicleUnloadWp setWaypointType "SCRIPTED";
private _script = ["\achilles\functions_f_achilles\scripts\fn_wpParadrop.sqf", "\achilles\functions_f_achilles\scripts\fn_wpFastrope.sqf"] select (_lzdz_type isEqualTo 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multiple lines

_vehicleUnloadWp setWaypointScript _script;
} else
{
_vehicleUnloadWp setWaypointType "TR UNLOAD";
};

// Make the driver full skill. This makes him less likely to do dumb things
// when they take contact.
(driver _vehicle) setSkill 1;

if (_vehicle_type isKindOf "Air") then
{
// Special settings for helicopters. Otherwise they tend to run away instead of land
// if the LZ is hot.
{
_x allowFleeing 0; // Especially for helos... They're very cowardly.
} forEach (crew _vehicle);
// armed aircrafts are unreliable when they are not CARELESS
_vehicleGroup setBehaviour "CARELESS";
_vehicleUnloadWp setWaypointTimeout [0,0,0];
}
else
{
_vehicleUnloadWp setWaypointTimeout [5,10,20]; // Give the units some time to get away from truck
};

// Generate the waypoints for after the transport drops off the troops.
if (_vehicle_behaviour == 0) then
{
// RTB and despawn.
private _vehicleReturnWp = _vehicleGroup addWaypoint [_spawn_position, 0];
_vehicleReturnWp setWaypointTimeout [2,2,2]; // Let the unit stop before being despawned.
_vehicleReturnWp setWaypointStatements ["true", "deleteVehicle (vehicle this); {deleteVehicle _x} foreach thisList;"];
};

// print a confirmation
[localize "STR_AMAE_REINFORCEMENT_DISPATCHED"] call Ares_fnc_showZeusMessage;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,39 @@ switch (_mode) do
};
case "VEHICLE":
{
if ((_ctrl lbData _comboIndex) isKindOf "Air") then
private _vehicleClass = _ctrl lbData _comboIndex;
if (_vehicleClass isKindOf "Air") then
{
_ctrl = _dialog displayCtrl IDC_COMBO_WP_TYPE;
_ctrl ctrlSetFade 0;
_ctrl ctrlEnable true;
_ctrl ctrlCommit 0;

_ctrl = _dialog displayCtrl IDC_COMBO_WP_TYPE_LABEL;
_ctrl ctrlSetFade 0;
_ctrl ctrlCommit 0;
private _ctrl_wpTypeLabel = _dialog displayCtrl IDC_COMBO_WP_TYPE_LABEL;
_ctrl_wpTypeLabel ctrlSetFade 0;
_ctrl_wpTypeLabel ctrlCommit 0;

private _ctrl_wpType = _dialog displayCtrl IDC_COMBO_WP_TYPE;
_ctrl_wpType ctrlSetFade 0;
_ctrl_wpType ctrlEnable true;
_ctrl_wpType ctrlCommit 0;

// Add/remove HALO option
if (_vehicleClass isKindOf "Plane") then
{
if (lbSize _ctrl_wpType == 3) then {_ctrl_wpType lbAdd localize "STR_AMAE_HALO"};
}
else
{
if (lbSize _ctrl_wpType == 4) then {_ctrl_wpType lbDelete 3};
};

_last_choice = uiNamespace getVariable ["Ares_ChooseDialog_ReturnValue_6", 0];
_last_choice = [0, _last_choice] select (_last_choice isEqualType 0);
_last_choice = [(lbSize _ctrl) - 1, _last_choice] select (_last_choice < lbSize _ctrl);
_ctrl lbSetCurSel _last_choice;
_last_choice = [(lbSize _ctrl_wpType) - 1, _last_choice] select (_last_choice < lbSize _ctrl_wpType);
_ctrl_wpType lbSetCurSel _last_choice;
} else
{
{
_ctrl = _dialog displayCtrl _x;
_ctrl ctrlSetFade 0.8;
_ctrl ctrlEnable false;
_ctrl ctrlCommit 0;
private _ctrl_wpType = _dialog displayCtrl _x;
_ctrl_wpType ctrlSetFade 0.8;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

_ctrl_wpType ctrlEnable false;
_ctrl_wpType ctrlCommit 0;
} forEach [IDC_COMBO_WP_TYPE,IDC_COMBO_WP_TYPE_LABEL];
};
};
Expand Down