mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-21 10:56:29 +03:00
Revert "Revert "Merge branch 'master' of https://github.com/EpochModTeam/DayZ-Epoch""
This reverts commit 109ec5c9a3.
This commit is contained in:
176
SQF/dayz_code/actions/servicePoints/init.sqf
Normal file
176
SQF/dayz_code/actions/servicePoints/init.sqf
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
Vehicle Service Point by Axe Cop
|
||||
Rewritten for single currency, gems, briefcase support and 1.0.7 epoch compatibility by salival - https://github.com/oiad/
|
||||
|
||||
Requires DayZ Epoch 1.0.7
|
||||
|
||||
This version adds support for both single currency and gems (from the epoch 1.0.7 update) as well as the original epoch briefcase currency system.
|
||||
Instead of pricing things like the original way, prices are now done on a "worth" similar to how coins are done. The price value of items are below.
|
||||
|
||||
1 silver = 1 worth
|
||||
1 10oz silver = 10 worth
|
||||
1 gold = 100 worth
|
||||
1 10oz gold = 1,000 worth
|
||||
1 briefcase = 10,000 worth
|
||||
|
||||
Please see dayz_code\configVariables.sqf for the value of gems (DZE_GemWorthArray) and their relevant worth if they are enabled.
|
||||
|
||||
Example config settings for DZE_SP_Refuel_Costs, DZE_SP_Repair_Costs and DZE_SP_Rearm_Costs:
|
||||
|
||||
All 3 sections can either be made free, disabled or a specifc price with the following examples:
|
||||
|
||||
["Air",localize "strwffree"] will make the vehicle config class of "Air" free for the specific action.
|
||||
["Air",localize "str_temp_param_disabled"] will make the vehicle config class of "Air" disabled for the specific action.
|
||||
["Air",2000] will make the vehicle config class of "Air" have a worth of 2000 for the specific action.
|
||||
["Armored_SUV_PMC",2000] will make the specific vehicle have a worth of 2000 for the specific action.
|
||||
["Armored_SUV_PMC",localize "strwffree"] will make the specific vehicle be free for the specific action.
|
||||
["Armored_SUV_PMC",localize "str_temp_param_disabled"] will make the specific vehicle be disabled for the specific action.
|
||||
|
||||
Valid vehicle config classes as an example: "Air", "AllVehicles", "All", "APC", "Bicycle", "Car", "Helicopter", "Land", "Motorcycle", "Plane", "Ship", "Tank"
|
||||
*/
|
||||
|
||||
private ["_folder","_actionTitleFormat","_actionCostsFormat","_message","_messageShown","_lastVehicle","_lastRole","_fnc_removeActions","_fnc_getCostsWep","_fnc_getCostsWep","_fnc_actionTitle","_fnc_isArmed","_fnc_getWeapons","_cycleTime","_servicePoints","_vehicle","_role","_costs","_actionTitle","_weapons","_weaponName"];
|
||||
|
||||
// general settings
|
||||
_folder = "\z\addons\dayz_code\actions\servicePoints\"; // folder where the service point scripts are saved, relative to the mission file
|
||||
_actionTitleFormat = "%1 (%2)"; // text of the vehicle menu, %1 = action name (Refuel, Repair, Rearm), %2 = costs (see format below)
|
||||
_actionCostsFormat = "%2 %1"; // %1 = item name, %2 = item count
|
||||
_message = localize "STR_CL_SP_MESSAGE"; // This is translated from your stringtable.xml in your mission folder root. Set to "" to disable
|
||||
_cycleTime = 5; // Time in sections for how often the action menu will be refreshed and how often it will search for a nearby fuel station (setting this too low can make a lot of lag)
|
||||
|
||||
_lastVehicle = objNull;
|
||||
_lastRole = [];
|
||||
_messageShown = false;
|
||||
|
||||
SP_refuel_action = -1;
|
||||
SP_repair_action = -1;
|
||||
SP_rearm_actions = [];
|
||||
|
||||
_fnc_removeActions = {
|
||||
if (isNull _lastVehicle) exitWith {};
|
||||
_lastVehicle removeAction SP_refuel_action;
|
||||
SP_refuel_action = -1;
|
||||
_lastVehicle removeAction SP_repair_action;
|
||||
SP_repair_action = -1;
|
||||
{
|
||||
_lastVehicle removeAction _x;
|
||||
} forEach SP_rearm_actions;
|
||||
SP_rearm_actions = [];
|
||||
_lastVehicle = objNull;
|
||||
_lastRole = [];
|
||||
};
|
||||
|
||||
_fnc_getCosts = {
|
||||
private ["_getVehicle","_getCosts","_cost","_getTypeName"];
|
||||
_getVehicle = _this select 0;
|
||||
_getCosts = _this select 1;
|
||||
_cost = [];
|
||||
{
|
||||
_getTypeName = _x select 0;
|
||||
if (_getVehicle isKindOf _getTypeName) exitWith {
|
||||
_cost = _x select 1;
|
||||
};
|
||||
} forEach _getCosts;
|
||||
_cost
|
||||
};
|
||||
|
||||
_fnc_getCostsWep = {
|
||||
private ["_weapon","_getCostsWep","_returnCostWep","_typeName"];
|
||||
_weapon = _this select 0;
|
||||
_getCostsWep = _this select 1;
|
||||
_returnCostWep = DZE_SP_Rearm_Defaultcost;
|
||||
{
|
||||
_typeName = _x select 0;
|
||||
if (_weapon == _typeName) exitWith {
|
||||
_returnCostWep = _x select 1;
|
||||
};
|
||||
} forEach _getCostsWep;
|
||||
_returnCostWep
|
||||
};
|
||||
|
||||
_fnc_actionTitle = {
|
||||
private ["_actionName","_actionCosts","_costsText","_return"];
|
||||
_actionName = _this select 0;
|
||||
_actionCosts = _this select 1;
|
||||
if (typeName _actionCosts == "STRING") then {
|
||||
_costsText = _actionCosts;
|
||||
} else {
|
||||
_costsText = if (Z_SingleCurrency) then {format ["%1 %2",[_actionCosts] call BIS_fnc_numberText,CurrencyName]} else {format ["%1",[_actionCosts,true] call z_calcCurrency]};
|
||||
};
|
||||
_return = format [_actionTitleFormat,_actionName,_costsText];
|
||||
_return
|
||||
};
|
||||
|
||||
_fnc_getWeapons = {
|
||||
private ["_gWeaponsVehicle","_gWeaponsRole","_gWeapons","_gWeaponName","_gTurret","_gWeaponsTurret"];
|
||||
_gWeaponsVehicle = _this select 0;
|
||||
_gWeaponsRole = _this select 1;
|
||||
_gWeapons = [];
|
||||
if (count _gWeaponsRole > 1) then {
|
||||
_gTurret = _gWeaponsRole select 1;
|
||||
_gWeaponsTurret = _gWeaponsVehicle weaponsTurret _gTurret;
|
||||
{
|
||||
_gWeaponName = getText (configFile >> "CfgWeapons" >> _x >> "displayName");
|
||||
if !(_gWeaponName in DZE_SP_Rearm_Ignore) then {
|
||||
_gWeapons set [count _gWeapons, [_x,_gWeaponName,_gTurret]];
|
||||
};
|
||||
} forEach _gWeaponsTurret;
|
||||
};
|
||||
_gWeapons
|
||||
};
|
||||
|
||||
while {1==1} do {
|
||||
_vehicle = vehicle player;
|
||||
if (_vehicle != player) then {
|
||||
_servicePoints = (nearestObjects [getPosATL _vehicle,DZE_SP_Classes,DZE_SP_MaxDistance]) - [_vehicle];
|
||||
if (count _servicePoints > 0) then {
|
||||
if (assignedDriver _vehicle == player) then {
|
||||
_role = ["Driver", [-1]];
|
||||
} else {
|
||||
_role = assignedVehicleRole player;
|
||||
};
|
||||
if (((str _role) != (str _lastRole)) || {_vehicle != _lastVehicle}) then {
|
||||
call _fnc_removeActions;
|
||||
};
|
||||
_lastVehicle = _vehicle;
|
||||
_lastRole = _role;
|
||||
if (DZE_SP_Refuel_Enable) then {
|
||||
if (SP_refuel_action < 0) then {
|
||||
_costs = [_vehicle,DZE_SP_Refuel_Costs] call _fnc_getCosts;
|
||||
_actionTitle = [localize "config_depot.sqf8",_costs] call _fnc_actionTitle;
|
||||
SP_refuel_action = _vehicle addAction [_actionTitle,_folder + "servicePointActions.sqf",["refuel",_costs,DZE_SP_Refuel_UpdateInterval,DZE_SP_Refuel_Amount],-1,false,true];
|
||||
};
|
||||
};
|
||||
if (DZE_SP_Repair_Enable) then {
|
||||
if (SP_repair_action < 0) then {
|
||||
_costs = [_vehicle,DZE_SP_Repair_Costs] call _fnc_getCosts;
|
||||
_actionTitle = [localize "config_depot.sqf1",_costs] call _fnc_actionTitle;
|
||||
SP_repair_action = _vehicle addAction [_actionTitle,_folder + "servicePointActions.sqf",["repair",_costs,DZE_SP_Repair_RepairTime],-1,false,true];
|
||||
};
|
||||
};
|
||||
if (DZE_SP_Rearm_Enable) then {
|
||||
if ((count _role > 1) && {count SP_rearm_actions == 0}) then {
|
||||
_weapons = [_vehicle,_role] call _fnc_getWeapons;
|
||||
{
|
||||
_weaponName = _x select 1;
|
||||
_costs = [_weaponName,DZE_SP_Rearm_Costs] call _fnc_getCostsWep;
|
||||
_actionTitle = [format["%1 %2",localize "config_depot.sqf5",_weaponName],_costs] call _fnc_actionTitle;
|
||||
SP_rearm_action = _vehicle addAction [_actionTitle,_folder + "servicePointActions.sqf",["rearm",_costs,DZE_SP_Rearm_MagazineCount,_x],-1,false,true];
|
||||
SP_rearm_actions set [count SP_rearm_actions, SP_rearm_action];
|
||||
} forEach _weapons;
|
||||
};
|
||||
};
|
||||
if (!_messageShown && {_message != ""}) then {
|
||||
_messageShown = true;
|
||||
_vehicle vehicleChat _message;
|
||||
};
|
||||
} else {
|
||||
call _fnc_removeActions;
|
||||
_messageShown = false;
|
||||
};
|
||||
} else {
|
||||
call _fnc_removeActions;
|
||||
_messageShown = false;
|
||||
};
|
||||
uiSleep _cycleTime;
|
||||
};
|
||||
143
SQF/dayz_code/actions/servicePoints/servicePointActions.sqf
Normal file
143
SQF/dayz_code/actions/servicePoints/servicePointActions.sqf
Normal file
@@ -0,0 +1,143 @@
|
||||
// Vehicle Service Point (Rearm) by Axe Cop
|
||||
// Rewritten for single currency, gems, briefcase support and 1.0.7 epoch compatibility by salival - https://github.com/oiad/
|
||||
// Requires DayZ Epoch 1.0.7 for gem support.
|
||||
|
||||
private ["_vehicle","_costs","_fuel","_magazineCount","_weapon","_type","_name","_weaponType","_weaponName","_turret","_magazines","_ammo","_textMissing","_pos","_message","_action","_damage","_selection","_strH","_disabled","_amount","_enoughMoney","_moneyInfo","_wealth","_success","_reason","_cmpt"];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
|
||||
_ammo = "";
|
||||
_reason = "";
|
||||
|
||||
_action = (_this select 3) select 0;
|
||||
|
||||
_type = typeOf _vehicle;
|
||||
_disabled = false;
|
||||
_name = getText(configFile >> "cfgVehicles" >> _type >> "displayName");
|
||||
|
||||
_amount = (_this select 3) select 1;
|
||||
|
||||
if (_action == "rearm") then {
|
||||
_magazineCount = (_this select 3) select 2;
|
||||
_weapon = (_this select 3) select 3;
|
||||
|
||||
_weaponType = _weapon select 0;
|
||||
_weaponName = _weapon select 1;
|
||||
_turret = _weapon select 2;
|
||||
};
|
||||
|
||||
if (typeName _amount == "STRING") then {
|
||||
if (_amount == (localize "str_temp_param_disabled")) then {
|
||||
if (_action == "rearm") then {_reason = format[localize "STR_CL_SP_UNABLE_REARM",_weaponName]; _disabled = true};
|
||||
if (_action == "repair") then {_reason = format[localize "STR_CL_SP_UNABLE_REPAIR",_name]; _disabled = true};
|
||||
if (_action == "refuel") then {_reason = format[localize "STR_CL_SP_UNABLE_REFUEL",_name]; _disabled = true};
|
||||
};
|
||||
if (_amount == (localize "strwffree")) then {_amount = 0};
|
||||
};
|
||||
|
||||
if (_disabled) exitWith {[_reason,1] call dayz_rollingMessages};
|
||||
|
||||
_enoughMoney = false;
|
||||
_moneyInfo = [false, [], [], [], 0];
|
||||
_wealth = player getVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),0];
|
||||
|
||||
if (Z_SingleCurrency) then {
|
||||
_enoughMoney = (_wealth >= _amount);
|
||||
} else {
|
||||
Z_Selling = false;
|
||||
if (Z_AllowTakingMoneyFromVehicle) then {false call Z_checkCloseVehicle};
|
||||
_moneyInfo = _amount call Z_canAfford;
|
||||
_enoughMoney = _moneyInfo select 0;
|
||||
};
|
||||
|
||||
_success = if (Z_SingleCurrency) then {true} else {[player,_amount,_moneyInfo,true,0] call Z_payDefault};
|
||||
|
||||
if (!_success && _enoughMoney) exitWith {systemChat localize "STR_EPOCH_TRADE_GEAR_AND_BAG_FULL"}; // Not enough room in gear or bag to accept change
|
||||
|
||||
if (_enoughMoney) then {
|
||||
_success = if (Z_SingleCurrency) then {_amount <= _wealth} else {[player,_amount,_moneyInfo,false,0] call Z_payDefault};
|
||||
if (_success) then {
|
||||
if (Z_SingleCurrency) then {
|
||||
player setVariable [(["cashMoney","globalMoney"] select Z_persistentMoney),(_wealth - _amount),true];
|
||||
};
|
||||
|
||||
[player,(getPosATL player),50,"refuel"] spawn fnc_alertZombies;
|
||||
_vehicle engineOn false;
|
||||
if (_action == "refuel") then {
|
||||
[format[localize "STR_CL_SP_REFUELING",_name],1] call dayz_rollingMessages;
|
||||
|
||||
while {vehicle player == _vehicle} do {
|
||||
if ([0,0,0] distance (velocity _vehicle) > 1) exitWith {[format[localize "STR_CL_SP_REFUELING_STOPPED",_name],1] call dayz_rollingMessages};
|
||||
_fuel = (fuel _vehicle) + ((_this select 3) select 3);
|
||||
if (_fuel > 0.99) exitWith {
|
||||
_vehicle setFuel 1;
|
||||
[format[localize "STR_CL_SP_REFUEL_OK",_name],1] call dayz_rollingMessages;
|
||||
};
|
||||
_vehicle setFuel _fuel;
|
||||
uiSleep ((_this select 3) select 2);
|
||||
};
|
||||
};
|
||||
if (_action == "repair") then {
|
||||
[player,(getPosATL player),50,"repair"] spawn fnc_alertZombies;
|
||||
|
||||
_hitpoints = _vehicle call vehicle_getHitpoints;
|
||||
_allRepaired = true;
|
||||
{
|
||||
if ((vehicle player != _vehicle) || {[0,0,0] distance (velocity _vehicle) > 1}) exitWith {
|
||||
_allRepaired = false;
|
||||
[format[localize "STR_CL_SP_REPAIRING_STOPPED",_name],1] call dayz_rollingMessages;
|
||||
};
|
||||
_hits = [_vehicle,_x] call object_getHit;
|
||||
_damage = _hits select 0;
|
||||
if (_damage > 0) then {
|
||||
_cmpt = [];
|
||||
{
|
||||
if (_forEachIndex > 2) then {_cmpt set [count _cmpt,_x]};
|
||||
} forEach toArray (_x);
|
||||
_cmpt = toString _cmpt;
|
||||
[format[localize "STR_CL_SP_REPAIRING",_cmpt],1] call dayz_rollingMessages;
|
||||
_selection = getText(configFile >> "cfgVehicles" >> _type >> "HitPoints" >> _x >> "name");
|
||||
_strH = "hit_" + (_selection);
|
||||
_vehicle setHit[_selection,0];
|
||||
_vehicle setVariable [_strH,0,true];
|
||||
uiSleep ((_this select 3) select 2);
|
||||
};
|
||||
} forEach _hitpoints;
|
||||
PVDZ_veh_Save = [_vehicle,"repair",true];
|
||||
publicVariableServer "PVDZ_veh_Save";
|
||||
|
||||
if (_allRepaired) then {
|
||||
_vehicle setDamage 0;
|
||||
_vehicle setVelocity [0,0,1];
|
||||
[format[localize "STR_CL_SP_REPAIR_OK",_name],1] call dayz_rollingMessages;
|
||||
};
|
||||
};
|
||||
|
||||
if (_action == "rearm") then {
|
||||
_magazines = getArray (configFile >> "CfgWeapons" >> _weaponType >> "magazines");
|
||||
_ammo = _magazines select 0;
|
||||
|
||||
if (_weaponType == "CMFlareLauncher") then {
|
||||
_vehicle removeWeaponTurret ["CMFlareLauncher",_turret];
|
||||
for "_i" from 1 to _magazineCount do {_vehicle addMagazineTurret [_ammo,_turret];};
|
||||
_vehicle addWeaponTurret ["CMFlareLauncher",_turret];
|
||||
} else {
|
||||
{_vehicle removeMagazinesTurret [_x,_turret];} forEach _magazines;
|
||||
|
||||
for "_i" from 1 to _magazineCount do {_vehicle addMagazineTurret [_ammo,_turret];};
|
||||
};
|
||||
|
||||
[format[localize "STR_CL_SP_REARMED",_weaponName,_name],1] call dayz_rollingMessages;
|
||||
};
|
||||
call player_forceSave;
|
||||
} else {
|
||||
systemChat localize "STR_EPOCH_TRADE_DEBUG";
|
||||
};
|
||||
} else {
|
||||
_itemText = if (Z_SingleCurrency) then {CurrencyName} else {[_amount,true] call z_calcCurrency};
|
||||
if (Z_SingleCurrency) then {
|
||||
systemChat format[localize "STR_CL_SP_FAIL_COINS",[_amount] call BIS_fnc_numberText,_itemText,_action,_name];
|
||||
} else {
|
||||
systemChat format[localize "STR_CL_SP_FAIL_BRIEFCASES",_itemText,_action,_name];
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user