add files

This commit is contained in:
Schalldampfer 2018-07-27 18:11:32 +09:00
parent e60f8e20c8
commit 2ea850389f
3 changed files with 115 additions and 0 deletions

View File

@ -1 +1,49 @@
# DeployBike4A3E
*Deploy vehicle from dyna menu (Space key menu)
*Pack vehicle from dyna menu while looking at it
*You can define any vehicle to spawn
*The vehicle is spawned server side (not saved in the hive, but theoretically possible)
*No animation like DayZ Epoch's "deploy anything" for now (but theoretically possible with client side modification)
Server side
copy these two files:
epoch_server\compile\deploy_vehicle\Epoch_Deploy_server_PackVehicle.sqf
epoch_server\compile\deploy_vehicle\Epoch_Deploy_server_SpawnVehicle.sqf
Modify those files:
epoch_server\config.cpp Line146~(in class CfgServerFunctions -> class A3E):
class deploy_vehicle {
class Deploy_server_SpawnVehicle {};
class Deploy_server_PackVehicle {};
};
epoch_server\init\server_init.sqf : at bottom (outside any curly brackets)
"Deploy_SpawnVehicle" addPublicVariableEventHandler{(_this select 1) call Epoch_Deploy_server_SpawnVehicle};
"Deploy_PackVehicle" addPublicVariableEventHandler{(_this select 1) call Epoch_Deploy_server_PackVehicle};
Client side
Modify two files:
epoch_config\Configs\CfgActionMenu\CfgActionMenu_self.hpp (at bottom)
class Deploy_deploy
{
condition = "!dyna_inVehicle";
action = "Deploy_SpawnVehicle = [player,'MBK_01_EPOCH']; publicVariableServer 'Deploy_SpawnVehicle';";
icon = "x\addons\a3_epoch_code\Data\UI\buttons\repair.paa";
tooltip = "Deploy Bike";
};
epoch_config\Configs\CfgActionMenu\CfgActionMenu_target.hpp (at bottom)
class Deploy_pack
{
condition = "dyna_isVehicle && ((crew dyna_cursorTarget) isEqualTo [])";
action = "Deploy_PackVehicle = [player,dyna_cursorTarget]; publicVariableServer 'Deploy_PackVehicle';";
icon = "x\addons\a3_epoch_code\Data\UI\buttons\repair.paa";
tooltip = "Pack Vehicle";
};

View File

@ -0,0 +1,18 @@
/*
Author: Schalldampfer
[_player,_vehObj]
*/
private ["_player","_puid","_owner","_vehObj","_vehClass"];
_player = _this select 0;
_puid = getPlayerUID _player;
_owner = owner _player;
_vehObj = _this select 1;
_vehClass = typeOf _vehObj;
if ((_vehObj getVariable ["EPOCH_DeployOwner","-1"]) == _puid) then {//check owner
Deploy_DeployedVehicles = Deploy_DeployedVehicles - [_vehObj];//remove from array
deleteVehicle _vehObj;//remove vehicle
format["You've packed a %1!", _vehClass] remoteExec ["Epoch_message",_player];
};

View File

@ -0,0 +1,49 @@
/*
Author: Schalldampfer
[_player,_vehClass]
*/
private ["_player","_puid","_owner","_position","_vehClass","_vehObj","_isOk"];
_player = _this select 0;
_puid = getPlayerUID _player;
_owner = owner _player;
_position = getPos _player;
_vehClass = _this select 1;
diag_log format["[DeployBike] Try spawning %1 by %2",_vehClass,_player];
_isOk = true;
if(isNil "Deploy_DeployedVehicles") then {Deploy_DeployedVehicles = [];};
//check player haven't spawned one
{
if ((_x getVariable ["EPOCH_DeployOwner","-1"]) == _puid) then { _isOk = false;"You've already deployed a vehicle!" remoteExec ["Epoch_message",_player]; };
} foreach Deploy_DeployedVehicles;
//spawn
if (_isOk) then {
_vehObj = _vehClass createVehicle _position; //create
_vehObj allowDamage false;
//init
_vehObj setVectorUp (surfaceNormal (getPos _vehObj));
_vehObj setVelocity [0,0,.1];
_vehObj call EPOCH_server_setVToken;
//_vehObj call EPOCH_server_vehicleInit;
Deploy_DeployedVehicles set [count Deploy_DeployedVehicles, _vehObj];//add to array
_vehObj setvariable ["EPOCH_DeployOwner",_puid];//set puid as owner
_vehObj addEventHandler ["GetIn", {"WARNING: This vehicle will be deleted at restart!" remoteExec ["Epoch_message",_this select 2];}];//warn when get in
// Normalize vehicle inventory
clearWeaponCargoGlobal _vehObj;
clearMagazineCargoGlobal _vehObj;
clearBackpackCargoGlobal _vehObj;
clearItemCargoGlobal _vehObj;
_vehObj setFuel ((random 1 max 0.1) min 0.9);//fuel
//complete spaning
_vehObj allowDamage true;
format["You've deployed a %1!", _vehClass] remoteExec ["Epoch_message",_player];
};
_vehObj