Merge pull request #56 from Bjanski/Dev

Dev
This commit is contained in:
Jan Babor 2016-07-27 01:22:16 +02:00 committed by GitHub
commit 27b0c0adcf
12 changed files with 474 additions and 5 deletions

View File

@ -0,0 +1 @@
exad_dv

View File

@ -0,0 +1,73 @@
/*
fn_createMarker.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.
*/
params ["_vehObjNetId"];
_vehObj = objectFromNetId _vehObjNetId;
_vehClass = typeOf _vehObj;
_vehPos = getPosATL _vehObj;
moveOut (driver _vehObj);
_vehObj call ExileServer_system_vehicleSaveQueue_removeVehicle;
_vehObj call ExileServer_system_simulationMonitor_removeVehicle;
deleteVehicle _vehObj;
{
if(getText(missionConfigFile >> "CfgXM8" >> _x >> "vehicleClass") == _vehClass)exitWith{
_lootHolder = createVehicle ["LootWeaponHolder", _vehPos, [], 0, "CAN_COLLIDE"];
_lootHolder setDir (random 360);
_lootHolder setPosATL _vehPos;
{
_amount = if(count _x > 1)then{_x select 1}else{1};
if(_amount > 0)then{
_itemClassName = _x select 0;
_cargoType = _itemClassName call ExileClient_util_cargo_getType;
switch (_cargoType) do
{
case 1:
{
if (_itemClassName isEqualTo "Exile_Item_MountainDupe") then
{
_lootHolder addMagazineCargoGlobal [_itemClassName, _amount];
}
else
{
_lootHolder addMagazineCargoGlobal [_itemClassName, _amount];
};
};
case 3:
{
_lootHolder addBackpackCargoGlobal [_itemClassName, _amount];
};
case 2:
{
_lootHolder addWeaponCargoGlobal [_itemClassName, _amount];
};
default
{
_lootHolder addItemCargoGlobal [_itemClassName, _amount];
};
};
};
}forEach getArray(missionConfigFile >> "CfgXM8" >> _x >> "recipe");
};
}forEach ((missionConfigfile >> "CfgXM8") call BIS_fnc_getCfgSubClasses);
true

View File

@ -0,0 +1,64 @@
/*
fn_createMarker.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.
*/
params ["_playerNetId","_configClass","_player","_spawnPos","_spawnDir","_usePositionATL","_vehObj"];
_player = objectFromNetId _playerNetId;
_spawnPos = _player modelToWorld [0,2,0];
_spawnDir = direction _player;
_usePositionATL = true;
_vehicleClass = getText(missionConfigFile >> "CfgXM8" >> _configClass >> "vehicleClass");
_vehObj = [_vehicleClass, _spawnPos, _spawnDir, _usePositionATL] call ExileServer_object_vehicle_createNonPersistentVehicle;
if( getNumber(missionConfigFile >> "CfgXM8" >> _configClass >> "packable") > 0 ) then {
_vehObj setVariable ["ExAd_DV_Packable", true, true];
};
if( getNumber(missionConfigFile >> "CfgXM8" >> _configClass >> "autoCleanUp") > 0 ) then {
[_vehObj] spawn {
private ["_wait","_tick", "_vehObj","_driver"];
_wait = true;
_tick = 0;
_vehObj = [_this,0,objNull] call BIS_fnc_param;
while {_wait} do {
UISleep 1;
if(isNull _vehObj)exitWith{_wait = false};
_driver = driver _vehObj;
if(isNull _driver)then{
_tick = _tick + 1;
}else{
_tick = 0;
};
if(_tick >= ExAd_DV_DESPAWN_IDLE_TIME)exitWith{_wait = false};
};
moveOut (driver _vehObj);
_vehObj call ExileServer_system_vehicleSaveQueue_removeVehicle;
_vehObj call ExileServer_system_simulationMonitor_removeVehicle;
deleteVehicle _vehObj;
};
};
true

View File

@ -0,0 +1 @@
exad_dv

View File

@ -0,0 +1,46 @@
/*
config.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 CfgPatches {
class ExAd_DV {
requiredVersion = 0.1;
requiredAddons[] = {"ExAd_Core"};
};
};
class CfgFunctions {
class ExAdServer {
class DV {
file = "exad_dv\Functions";
class spawnDeployableVehicle {};
class despawnDeployableVehicle {};
};
};
};
class CfgNetworkMessages
{
class spawnDeployableVehicle
{
parameters[] = {"STRING","STRING"};
};
class despawnDeployableVehicle
{
parameters[] = {"STRING"};
};
};

View File

@ -1,6 +1,13 @@
#<img src="logo.png" alt="ExAd" width="200" />
# Changelog:
## 160726 17:15 . v0.7.10
### Fixed
* Apply custom functions to "More" app buttons. (XM8)
### Added
* New App, deploy vehicles (XM8)
## 160720 01:15 . v0.7.9
### Fixed
* Some design flaws in the Apps functions. (XM8)

View File

@ -1,6 +1,13 @@
#VirtualGarage
## Changelog:
## 160726 17:15 . v0.7.10
### Fixed
* Apply custom functions to "More" app buttons.
### Added
* New App, deploy vehicles
## 160720 01:15 . v0.7.9
### Fixed
* Some design flaws in the Apps functions.

View File

@ -0,0 +1,84 @@
#Installation Instructions
* Move "DeployVehicle" into your "mpmissions\Exile.Tanoa\ExAdClient\XM8\Apps\" folder.
* Navigate and open "mpmissions\Exile.Tanoa\config.cpp" insert the classes "PackDeployedVehicle" into appropriate parent classes.
```cpp
class CfgInteractionMenus
{
class Car
{
targetType = 2;
target = "Car";
class Actions
{
class PackDeployedVehicle: ExileAbstractAction
{
title = "Pack Vehicle";
condition = "call ExAd_XM8_DV_fnc_canPack";
action = "call ExAd_XM8_DV_fnc_pack";
};
};
};
class Bikes
{
targetType = 2;
target = "Bicycle";
class Actions
{
class PackDeployedVehicle: ExileAbstractAction
{
title = "Pack Bike";
condition = "call ExAd_XM8_DV_fnc_canPack";
action = "call ExAd_XM8_DV_fnc_pack";
};
};
};
};
```
* Move over and pack exad_dv into "@ExileServer\addons\"
* Add deploy classes into CfgXM8 in "mpmissions\Exile.Tanoa\config.cpp" and add them to the extraApps array; E.g.
```cpp
class CfgXM8
{
extraApps[] = {"ExAd_Bike","ExAd_Quad"};
class ExAd_Bike
{
title = "Deploy Bike";
config = "ExadClient\XM8\Apps\DeployVehicle\config.sqf";
bambiState = 0;
vehicleClass = "Exile_Bike_MountainBike";
recipe[] = {{"Exile_Item_ExtensionCord",-1}};
packable = 1;
autoCleanUp = 1;
quickFunction = "['ExAd_Bike'] call ExAd_XM8_DV_fnc_spawnVehicle";
};
class ExAd_Quad
{
title = "Deploy Quad";
bambiState = 0;
vehicleClass = "Exile_Bike_QuadBike_Fia";
recipe[] = {{"Exile_Item_ExtensionCord",1}};
packable = 1;
quickFunction = "['ExAd_Quad'] call ExAd_XM8_DV_fnc_spawnVehicle";
};
};
```
## How to use
Each class added to the CfgXM8 will represent a vehicle possible to deploy and add commit a "More" button to it.
One of the deploy classes needs to include the config script so all needed functions will be prepared and read to memory.
### Options
* title = "Deploy Bike"; -- Button title
* bambiState = 0; -- Bambistate required || 1 = True / 0 = False
* vehicleClass = "Exile_Bike_MountainBike"; -- CfgVehicles class name of desired vehicle
* recipe[] = {
{"Exile_Item_ExtensionCord",-1}
}; -- items needed to craft vehicle, first class name then amount (-1 means required but will not be taken from inventory)
* packable = 1; -- Deployed vehicle can be pack again || 1 = True / 0 = False
* autoCleanUp = 1; -- Server monitize crafted vehicles and despawn if idle to long. || 1 = True / 0 = False
* quickFunction = "['ExAd_Bike'] call ExAd_XM8_DV_fnc_spawnVehicle"; -- Function that is binded to the button if slide is not neccessary.

View File

@ -0,0 +1,132 @@
ExAd_DV_DESPAWN_IDLE_TIME = 600;
ExAd_XM8_DV_fnc_itemsInCargo = {
params ["_container","_itemArray","_item","_amount","_response"];
_item = toLower (_itemArray select 0);
_amount = _itemArray select 1;
_response = false;
{
if(_item == toLower _x)then{
_amount = _amount - 1;
};
if(_amount <= 0)exitWith{_response = true}
}forEach magazines player;
_response
};
ExAd_XM8_DV_fnc_itemsMissing = {
params["_recipe","_recipeStr"];
_recipeStr = "";
{
private["_amount","_configName","_displayName","_text"];
_amount = if(count _x > 1)then{_x select 1}else{1};
_text = [_x select 0] call ExAd_XM8_DV_fnc_getDisplayName;
_recipeStr = _recipeStr + format["%1x : %2<br />",(if(_amount < 0)then{((-1) * _amount)}else{_amount}), _text];
}forEach _recipe;
_response = format["You need <br />%1",_recipeStr];
_response
};
ExAd_XM8_DV_fnc_getDisplayName = {
params["_class","_configName","_displayName"];
_configName = _class call ExileClient_util_gear_getConfigNameByClassName;
_displayName = getText(configFile >> _configName >> _class >> "displayName");
_text = if(count _displayName > 0)then{_displayName}else{_class};
_text
};
ExAd_XM8_DV_fnc_canPack = {
( ExileClientInteractionObject getVariable["ExAd_DV_Packable", false] )
};
ExAd_XM8_DV_fnc_pack = {
[ExileClientInteractionObject] spawn {
params["_obj"];
disableUserInput true;
player playActionNow "Medic";
uiSleep 3;
["despawnDeployableVehicle", [netId _obj]] call ExAd_fnc_serverDispatch;
uiSleep 1;
["SuccessTitleAndText", ["Vehicle Packed"]] call ExileClient_gui_toaster_addTemplateToast;
disableUserInput false;
};
};
ExAd_XM8_DV_fnc_spawnVehicle = {
params["_slideClass","_bambiState","_delopyRecipe","_vehicleClass"];
try
{
_bambiState = if(isNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState")) then
{
if(getNumber(missionConfigFile >> "CfgXM8" >> _slideClass >> "bambiState") > 0)then{true}else{false}
} else {true};
if(_bambiState && !ExileClientPlayerIsBambi) then { throw "You can only spawn vehicles as a bambi!"};
_delopyRecipe = getArray(missionConfigFile >> "CfgXM8" >> _slideClass >> "recipe");
if(count _delopyRecipe > 0) then
{
{
if(count _x > 1) then
{
_amount = if(_x select 1 == -1)then{1}else{_x select 1};
if!([player, [_x select 0, _amount]] call ExAd_XM8_DV_fnc_itemsInCargo) then
{
throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
};
} else {
if!([player, _x select 0] call ExileClient_util_playerEquipment_contains) then
{
throw ([_delopyRecipe] call ExAd_XM8_DV_fnc_itemsMissing);
}
}
}forEach _delopyRecipe;
{
_count = if(count _x > 1)then{(_x select 1)}else{1};
for "_i" from 1 to _count do {
[player, _x select 0] call ExileClient_util_playerCargo_remove
}
}forEach _delopyRecipe;
};
_vehicleClass = getText(missionConfigFile >> "CfgXM8" >> _slideClass >> "vehicleClass");
if!(isClass(configFile >> "CfgVehicles" >> _vehicleClass ))then { throw "The vehicle class doesn't exist"};
[_slideClass] spawn {
params["_slideClass"];
disableUserInput true;
player playActionNow "Medic";
uiSleep 3;
["spawnDeployableVehicle", [netId player, _slideClass]] call ExAd_fnc_serverDispatch;
uiSleep 1;
["SuccessTitleAndText", ["Vehicle deployed"]] call ExileClient_gui_toaster_addTemplateToast;
ExileClientXM8CurrentSlide = "extraApps";
disableUserInput false;
};
["extraApps", 1] call ExileClient_gui_xm8_slide;
closeDialog 0;
}
catch{
[_exception] spawn {
UISleep 0.5;
["ErrorTitleAndText", ["ExAd - Deploy Vehicle", _this select 0]] call ExileClient_gui_toaster_addTemplateToast;
["extraApps", 1] call ExileClient_gui_xm8_slide;
};
};
};

View File

@ -20,6 +20,7 @@ try
_pos = ctrlPosition _strTxt;
_strTxt ctrlSetPosition [_pos select 0, _pos select 1, _pos select 2, ctrlTextHeight _strTxt];
_strTxt ctrlcommit 0;
([_display,"ExAd_Info","strTxt"] call ExAd_fnc_getAppCtrl) ctrlEnable true;
}
catch
{

View File

@ -53,7 +53,10 @@ _pW = 0.025; _pH = 0.04;
[_display,_slide,([_x,format["AppIcon%1",_count2]] call ExAd_fnc_getNextIDC),[(_pos select 0) + 1.5 * _pW, (_pos select 1) + 0.625 * _pH, 3 * _pW, 3 * _pH],_logo,[1,1,1,1],false,true,""] call ExAd_fnc_createPicture;
_ctrl ctrlSetText getText(missionConfigFile >> "CfgXM8" >> _x >> "title");
_ctrl ctrlSetEventHandler ["ButtonClick", format["['%1', 0] call ExileClient_gui_xm8_slide",_x]];
_function = if(isText(missionConfigFile >> "CfgXM8" >> _x >> "quickFunction"))then{
getText(missionConfigFile >> "CfgXM8" >> _x >> "quickFunction")
} else {format["['%1', 0] call ExileClient_gui_xm8_slide",_x]};
_ctrl ctrlSetEventHandler ["ButtonClick", _function];
_count2 = _count2 + 1;
}forEach _apps;

View File

@ -1,6 +1,6 @@
class CfgXM8
{
extraApps[] = {"ExAd_VG","ExAd_Info","ExAd_CHVD","ExAd_Journal"};
extraApps[] = {"ExAd_VG","ExAd_Info","ExAd_CHVD","ExAd_Journal","ExAd_Bike","ExAd_Quad"};
class ExAd_VG
{
@ -23,13 +23,13 @@ class CfgXM8
class ExAd_CHVD
{
title = "View Distance Settings";
controlID = 50200; //IDC:50200 -> 50250 || These need to be unique and out of range from each other
controlID = 50200; //IDC:50200 -> 50102 || These need to be unique and out of range from each other
config = "ExadClient\XM8\Apps\CHVD\config.sqf";
logo = "ExadClient\XM8\Apps\CHVD\Icon_CHVD.paa";
onLoad = "ExAdClient\XM8\Apps\CHVD\onLoad.sqf";
onOpen = "ExAdClient\XM8\Apps\CHVD\onOpen.sqf";
onClose = "ExAdClient\XM8\Apps\CHVD\onClose.sqf";
};
};
class ExAd_Journal
{
title = "Journal";
@ -39,7 +39,27 @@ class CfgXM8
onLoad = "ExAdClient\XM8\Apps\Journal\onLoad.sqf";
onOpen = "ExAdClient\XM8\Apps\Journal\onOpen.sqf";
onClose = "ExAdClient\XM8\Apps\Journal\onClose.sqf";
};
};
class ExAd_Bike
{
title = "Deploy Bike";
config = "ExadClient\XM8\Apps\DeployVehicle\config.sqf";
bambiState = 0;
vehicleClass = "Exile_Bike_MountainBike";
recipe[] = {{"Exile_Item_ExtensionCord",-1}};
packable = 1;
autoCleanUp = 1;
quickFunction = "['ExAd_Bike'] call ExAd_XM8_DV_fnc_spawnVehicle";
};
class ExAd_Quad
{
title = "Deploy Quad";
bambiState = 0;
vehicleClass = "Exile_Bike_QuadBike_Fia";
recipe[] = {{"Exile_Item_ExtensionCord",1}};
packable = 1;
quickFunction = "['ExAd_Quad'] call ExAd_XM8_DV_fnc_spawnVehicle";
};
};
class CfgExileCustomCode
@ -51,6 +71,36 @@ class CfgExileCustomCode
class CfgInteractionMenus
{
class Car
{
targetType = 2;
target = "Car";
class Actions
{
class PackDeployedVehicle: ExileAbstractAction
{
title = "Pack Vehicle";
condition = "call ExAd_XM8_DV_fnc_canPack";
action = "call ExAd_XM8_DV_fnc_pack";
};
};
};
class Bikes
{
targetType = 2;
target = "Bicycle";
class Actions
{
class PackDeployedVehicle: ExileAbstractAction
{
title = "Pack Bike";
condition = "call ExAd_XM8_DV_fnc_canPack";
action = "call ExAd_XM8_DV_fnc_pack";
};
};
};
class Flag
{
targetType = 2;