Merge pull request #13 from Bjanski/HaloParachute

Halo parachute
This commit is contained in:
Jan Babor 2016-04-27 01:51:28 +02:00
commit e8363ebd9b
11 changed files with 322 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#Examples
Below I provide with some examples of how to use HaloParachute
##Chang settings
Customize settings to allow different scenarios.
* Allow vehicle ejection
```sqf
ExAd_ACTION_EJECT_HEIGHT = 0;
```
* Enable safeMode - makes the parachute auto pull itself when reaching ExAd_ACTION_PARACHUTE_HEIGHT
```sqf
ExAd_HALOPARACHUTE_SAFE_MODE = true;
```

View File

@ -0,0 +1,22 @@
# Installation
* Remember for this plugin to work you first need to install [Core](https://github.com/Bjanski/ExAd/blob/Core/docs/core/installation.md)
## Client
1. Place the folder "HaloParachute" into "mpmissions\exile.<MAP>\ExAd\"
2. Goto "mpmissions\exile.<MAP>\ExAd\CfgFunctions" and uncomment
From
```cpp
//#include "HaloParachute\CfgFunctions.cpp"
```
To
```cpp
#include "HaloParachute\CfgFunctions.cpp"
```
3. Now you can go into "mpmissions\exile.<MAP>\ExAd\HaloParachute\customize.sqf" and change to desirable settings.
## Server
No installation needed.

View File

@ -0,0 +1,30 @@
/*
CfgFunctions.cpp
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
class HaloParachute
{
file = "ExAdClient\HaloParachute\Functions";
class canDetachParachute {};
class ejectPlayer {};
class parachutesafemode {};
class pullParachute {};
class showEject {};
class showParachute {};
class customize {file = "ExAdClient\HaloParachute\postInit.sqf"; postInit = 1;};
};

View File

@ -0,0 +1,19 @@
/*
fn_showDetachParachute.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
((getPos player) select 2 > ExAd_ACTION_PARACHUTE_HEIGHT && vehicle player isKindOf "Steerable_Parachute_F")

View File

@ -0,0 +1,39 @@
/*
fn_ejectPayer.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
private ["_vehicleObj", "_push", "_vecDir"];
_vehicleObj = vehicle player;
if (_vehicleObj == player) exitWith {false};
moveOut player;
_push = if (_vehicleObj isKindOf "Plane") then {
player setDir getDir _vehicleObj;
((vectorUp _vehicleObj) vectorMultiply 40)
} else {
_vecDir = (getPosASL player) vectorDiff (getPosASL _vehicleObj);
(_vecDir vectorMultiply (5 / vectorMagnitude _vecDir))
};
player setVelocity ((velocity player) vectorAdd _push);
if(ExAd_HALOPARACHUTE_SAFE_MODE)then{
ExAd_PARACHUTE_SAFE_THREAD = [0.1, ExAd_fnc_parachuteSafeMode, [], true] call ExileClient_system_thread_addtask;
};
true

View File

@ -0,0 +1,21 @@
/*
fn_parachuteSafeMode.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
if((getPosATL player) select 2 <= ExAd_ACTION_PARACHUTE_HEIGHT)then{
call ExAd_fnc_pullParachute;
};

View File

@ -0,0 +1,40 @@
/*
fn_pullParachute.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
private ["_parachuteObject"];
waitUntil {sleep 0.1; {player distance _x < 10 max (sizeOf typeOf _x)} count (player nearEntities ["Helicopter_Base_F", 20]) == 0};
if (!alive player || vehicle player != player) exitWith {};
_parachuteObject = createVehicle ["Steerable_Parachute_F", getPosATL player, [], 0, "CAN_COLLIDE"];
_parachuteObject setDir getDir player;
_parachuteObject disableCollisionWith player;
player action ["GetinDriver", _parachuteObject];
player switchmove "";
player switchmove "HaloFreeFall_non";
player setVelocity [(sin (getDir player)) * 50, (cos (getDir player)) * 50, -5];
ExileJobParachuteFix = [0.25, ExileClient_object_player_parachuteFix, [], true] call ExileClient_system_thread_addtask;
if(ExAd_HALOPARACHUTE_SAFE_MODE)then{
[ExAd_PARACHUTE_SAFE_THREAD] call ExileClient_system_thread_removeTask;
};
true

View File

@ -0,0 +1,27 @@
/*
fn_showEject.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
if(vehicle player == player)exitWith{false};
_condition = false;
if((getPos player) select 2 > ExAd_ACTION_EJECT_HEIGHT)then{
_role = assignedVehicleRole player;
_condition = if(count _role > 0)then{if(_role select 0 == "cargo")then{false}else{true}}else{true}
};
_condition

View File

@ -0,0 +1,34 @@
/*
fn_showParachute.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
if(vehicle player != player)exitWith{false};
_condition = false;
if((getPos player) select 2 > ExAd_ACTION_PARACHUTE_HEIGHT)then{
_states = [
"ladderriflestatic",
"ladderrifledownloop",
"ladderrifleuploop",
"laddercivilstatic",
"laddercivildownloop",
"ladderciviluploop"
];
_condition = !((animationState player) in _states);
};
_condition

View File

@ -0,0 +1,23 @@
/*
customize.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
ExAd_HALOPARACHUTE_SAFE_MODE = false; //BOOLEAN - Force pull parachute when player reaches ExAd_ACTION_PARACHUTE_HEIGHT if they ejected from vehicle
ExAd_HALOPARACHUTE_DETACH_PARACHUTE_MODE = false; //BOOLEAN - Allows player to detach himself from parachute
ExAd_ACTION_PARACHUTE_HEIGHT = 10; //SCALAR - What is the minimum altitude a player can pull a parachute. |RECOMMENDED 30 meters when safe_mode activated
ExAd_ACTION_EJECT_HEIGHT = 100; //SCALAR - What is the minimum altitude a player can Halo/Eject from a vehicle.

View File

@ -0,0 +1,51 @@
/*
postInit.sqf
Copyright 2016 Jan Babor
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
execVM "ExAdClient\HaloParachute\customize.sqf";
[] spawn {
while {true} do {
waitUntil{!isNil "ExileClientLoadedIn"};
UISleep 0.1;
waitUntil{ExileClientLoadedIn};
UISleep 0.1;
waitUntil{alive player};
ExAd_ACTION_PARACHUTE = player addaction [format["<t color='#E48A36'><img image='\a3\ui_f\data\gui\cfg\CommunicationMenu\supplydrop_ca.paa' />%1</t>", localize "STR_ExAd_HALOPARACHUTE_ACTIONS_PARACHUTE"], {call ExAd_fnc_pullParachute}, [], 6, true, true, "", "call ExAd_fnc_showParachute"];
ExAd_ACTION_EJECT = player addaction [format["<t color='#E48A36'><img image='\a3\ui_f\data\gui\cfg\CommunicationMenu\supplydrop_ca.paa' />%1</t>", localize "STR_ExAd_HALOPARACHUTE_ACTIONS_HALO"], {call ExAd_fnc_ejectPlayer}, [], 6, false, true, "", "call ExAd_fnc_showEject;"];
if(ExAd_HALOPARACHUTE_DETACH_PARACHUTE_MODE)then{
ExAd_ACTION_PARACHUTE_DETACH = (findDisplay 46) displayAddEventHandler ["KeyDown",{
if(call ExAd_fnc_canDetachParachute)then{
if(_this select 1 == 45 && _this select 2 && _this select 4)then{
call ExAd_fnc_ejectPlayer
}
}
}];
};
waitUntil{!alive player};
player removeAction ExAd_ACTION_PARACHUTE;
player removeAction ExAd_ACTION_EJECT;
if(ExAd_HALOPARACHUTE_DETACH_PARACHUTE_MODE)then{
(findDisplay 46) displayRemoveEventHandler ["KeyDown", ExAd_ACTION_PARACHUTE_DETACH];
};
};
};