Move some addActions to config UserActions

Should improve client FPS while still allowing conditions and scripts to
be customized.

Some special vehicles like MV22, UH1Y, etc. have UserActions overwritten
in their configs, so please let me know if you find any others that do
not get the option to repair or salvage because UserActions is
overwritten in their config. I think I got them all.

Vanilla commits:

a8c4238c0c

350d73abe1
This commit is contained in:
ebaydayz
2016-11-20 19:47:10 -05:00
parent ef1ad261e2
commit 3aad4b61e9
34 changed files with 320 additions and 259 deletions

View File

@@ -1,17 +1,21 @@
private ["_item","_type","_hasHarvested","_config","_knifeArray","_PlayerNear","_isListed","_activeKnife","_text","_dis","_sfx","_sharpnessRemaining","_qty","_chance","_string"];
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_29" call dayz_rollingMessages;};
private ["_item","_type","_hasHarvested","_knifeArray","_PlayerNear","_isListed","_activeKnife","_text","_dis","_sfx","_sharpnessRemaining","_qty","_chance","_string","_isZombie","_humanity"];
_isZombie = _this isKindOf "zZombie_base";
if (dayz_actionInProgress) exitWith {
if (_isZombie) then {
localize "str_epoch_player_31" call dayz_rollingMessages;
} else {
localize "str_epoch_player_29" call dayz_rollingMessages;
};
};
dayz_actionInProgress = true;
_item = _this select 3;
_item = _this;
_type = typeOf _item;
_hasHarvested = _item getVariable["meatHarvested",false];
_config = configFile >> "CfgSurvival" >> "Meat" >> _type;
_knifeArray = [];
player removeAction s_player_butcher;
s_player_butcher = -1;
_PlayerNear = {isPlayer _x} count ((getPosATL _item) nearEntities ["CAManBase", 10]) > 1;
if (_PlayerNear) exitWith {localize "str_pickup_limit_5" call dayz_rollingMessages; dayz_actionInProgress = false;};
@@ -22,8 +26,14 @@ if (_PlayerNear) exitWith {localize "str_pickup_limit_5" call dayz_rollingMessag
};
} count Dayz_Gutting;
if ((count _knifeArray) < 1) exitWith { localize "str_cannotgut" call dayz_rollingMessages; dayz_actionInProgress = false; };
if ((count _knifeArray) < 1) exitWith {
if (_isZombie) then {
format[localize "str_missing_to_do_this",localize "STR_EQUIP_NAME_4"] call dayz_rollingMessages;
} else {
localize "str_cannotgut" call dayz_rollingMessages;
};
dayz_actionInProgress = false;
};
if ((count _knifeArray > 0) and !_hasHarvested) then {
private "_qty";
@@ -32,7 +42,7 @@ if ((count _knifeArray > 0) and !_hasHarvested) then {
_activeKnife = _knifeArray call BIS_fnc_selectRandom;
//Get Animal Type
_isListed = isClass _config;
_isListed = isClass (configFile >> "CfgSurvival" >> "Meat" >> _type);
_text = getText (configFile >> "CfgVehicles" >> _type >> "displayName");
player playActionNow "Medic";
@@ -46,7 +56,7 @@ if ((count _knifeArray > 0) and !_hasHarvested) then {
_item setVariable ["meatHarvested",true,true];
_qty = if (_isListed) then {getNumber (_config >> "yield")} else {2};
_qty = if (_isListed) then {getNumber (configFile >> "CfgSurvival" >> "Meat" >> _type >> "yield")} else {2};
if (_activeKnife == "ItemKnifeBlunt") then { _qty = round(_qty / 2); };
if (local _item) then {
@@ -83,7 +93,15 @@ if ((count _knifeArray > 0) and !_hasHarvested) then {
};
uiSleep 6;
_string = format[localize "str_success_gutted_animal",_text,_qty];
if (_isZombie) then {
// Reduce humanity for gutting zeds
_humanity = player getVariable ["humanity",0];
_humanity = _humanity - 10;
player setVariable ["humanity",_humanity,true];
_string = format[localize "str_success_gutted_zombie",_text]; //%1 has been gutted, zombie parts are now on the carcass
} else {
_string = format[localize "str_success_gutted_animal",_text,_qty];
};
closeDialog 0;
uiSleep 0.02;
_string call dayz_rollingMessages;

View File

@@ -1,83 +0,0 @@
private ["_item","_type","_hasHarvested","_config","_knifeArray","_playerNear","_isListed","_activeKnife","_text","_sharpnessRemaining","_qty","_chance","_string"];
if (dayz_actionInProgress) exitWith {localize "str_epoch_player_31" call dayz_rollingMessages;};
dayz_actionInProgress = true;
_item = _this select 3;
_type = typeOf _item;
_hasHarvested = _item getVariable ["meatHarvested",false];
//_config = configFile >> "CfgSurvival" >> "Meat" >> _type;
_knifeArray = [];
player removeAction s_player_butcher;
s_player_butcher = -1;
_playerNear = {isPlayer _x} count ((getPosATL _item) nearEntities ["CAManBase", 10]) > 1;
if (_playerNear) exitWith {localize "str_pickup_limit_5" call dayz_rollingMessages; dayz_actionInProgress = false;};
//Count how many active tools the player has
{
if (_x in items player) then {_knifeArray set [count _knifeArray, _x];};
} count Dayz_Gutting;
if ((count _knifeArray) < 1) exitWith {format[localize "str_missing_to_do_this",localize "STR_EQUIP_NAME_4"] call dayz_rollingMessages; dayz_actionInProgress = false; };
if ((count _knifeArray > 0) && !_hasHarvested) then {
private "_qty";
//Select random can from array
_activeKnife = _knifeArray call BIS_fnc_selectRandom;
//Get Zombie Type
//_isListed = isClass _config;
_text = getText (configFile >> "CfgVehicles" >> _type >> "displayName");
player playActionNow "Medic";
[player,"gut",0,false,10] call dayz_zombieSpeak;
[player,10,true,(getPosATL player)] call player_alertZombies;
["Working",0,[20,40,15,0]] call dayz_NutritionSystem; // Added Nutrition-Factor for work
_item setVariable ["meatHarvested",true,true];
_qty = 2; //not used for gutting zombies
if (_activeKnife == "ItemKnifeBlunt") then { _qty = round(_qty / 2); };
if (local _item) then {
[_item,_qty] spawn local_gutObjectZ; //leave as spawn (sleeping in loops will work but can freeze the script)
} else {
PVDZE_plr_GutBodyZ = [_item,_qty];
publicVariable "PVDZE_plr_GutBodyZ";
};
if (dayz_knifeDulling) then {
_sharpnessRemaining = getText (configFile >> "cfgWeapons" >> _activeKnife >> "sharpnessRemaining");
switch _activeKnife do {
case "ItemKnife" : {
//_chance = getNumber (configFile >> "cfgWeapons" >> _activeKnife >> "chance");
if ([0.2] call fn_chance) then {
player removeWeapon _activeKnife;
player addWeapon _sharpnessRemaining;
//systemChat (localize "str_info_bluntknife");
localize "str_info_bluntknife" call dayz_rollingMessages;
};
};
case "ItemKnifeBlunt" : {
//do nothing
};
default {
player removeWeapon _activeKnife;
player addWeapon _sharpnessRemaining;
};
};
};
// Reduce humanity for gutting zeds
_humanity = player getVariable ["humanity",0];
_humanity = _humanity - 10;
player setVariable ["humanity",_humanity,true];
uiSleep 6;
_string = format[localize "str_success_gutted_zombie",_text]; //%1 has been gutted, zombie parts are now on the carcass
closeDialog 0;
uiSleep 0.02;
_string call dayz_rollingMessages;
};
dayz_actionInProgress = false;

View File

@@ -1,8 +1,5 @@
private ["_dir","_nearPlayers","_object","_speed","_vel"];
_object = _this select 3;
player removeAction s_player_pushPlane;
s_player_pushPlane = -1;
_object = _this;
if (!local _object) exitWith {
localize "str_actions_pilot_seat" call dayz_rollingMessages;

View File

@@ -4,9 +4,6 @@ _item = _this select 3;
disableSerialization;
player removeAction s_player_butcher;
s_player_butcher = 1;
if !(alive _item) then {
_rnd = (round(random 4)) + 1;
@@ -94,5 +91,3 @@ if !(alive _item) then {
format[localize "str_player_consumed",getText(configFile >> "CfgVehicles" >> _animalType >> "displayName")] call dayz_rollingMessages;
player switchmove "";
};
s_player_butcher = -1;

View File

@@ -1,3 +1,2 @@
{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
s_player_repair_crtl = -1;
dayz_myCursorTarget = objNull;

View File

@@ -1,6 +1,6 @@
private ["_part","_cancel","_color","_string","_handle","_damage","_cmpt","_vehicle","_hitpoints","_damagePercent","_configVeh"];
_vehicle = _this select 3;
_vehicle = _this;
{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
dayz_myCursorTarget = _vehicle;
@@ -39,5 +39,4 @@ if (count _hitpoints > 0) then {
// Localized in A2OA\Expansion\dta\languagecore
_cancel = dayz_myCursorTarget addAction [localize "str_action_cancel_action", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false];
s_player_repairActions set [count s_player_repairActions,_cancel];
s_player_repair_crtl = 1;
};

View File

@@ -19,7 +19,6 @@ _namePart = getText(configFile >> "cfgMagazines" >> _part >> "displayName");
{_vehicle removeAction _x} count s_player_repairActions;
s_player_repairActions = [];
s_player_repair_crtl = 1;
if (_hasToolbox) then {
player playActionNow "Medic";
@@ -94,7 +93,6 @@ if (_hasToolbox) then {
};
dayz_myCursorTarget = objNull;
s_player_repair_crtl = -1;
dayz_salvageInProgress = false;
//adding melee mags back if needed

View File

@@ -1,7 +1,7 @@
private ["_part","_color","_vehicle","_PlayerNear","_hitpoints","_isATV","_is6WheelType","_HasNoGlassKind",
"_6WheelTypeArray","_NoGlassArray","_NoExtraWheelsArray","_RemovedPartsArray","_damage","_cmpt","_configVeh","_damagePercent","_string","_handle","_cancel","_type"];
_vehicle = _this select 3;
_vehicle = _this;
{dayz_myCursorTarget removeAction _x} count s_player_repairActions;s_player_repairActions = [];
_PlayerNear = {isPlayer _x} count ((getPosATL _vehicle) nearEntities ["CAManBase", 10]) > 1;
@@ -73,5 +73,4 @@ if (count _hitpoints > 0 ) then {
// Localized in A2OA\Expansion\dta\languagecore
_cancel = dayz_myCursorTarget addAction [localize "str_action_cancel_action", "\z\addons\dayz_code\actions\repair_cancel.sqf","repair", 0, true, false];
s_player_repairActions set [count s_player_repairActions,_cancel];
s_player_repair_crtl = 1;
};

View File

@@ -1,6 +1,6 @@
private["_body","_name","_method","_methodStr","_message","_killingBlow"];
_body = _this select 3;
_body = _this;
_name = _body getVariable["bodyName","unknown"];
_method = _body getVariable["deathType","unknown"];
_methodStr = localize format ["str_death_%1",_method];

View File

@@ -0,0 +1,22 @@
#define CAN_DO (!r_drag_sqf && !r_player_unconscious && getNumber (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState player) >> "onLadder") != 1)
#define HAS_TOOLBOX ("ItemToolbox" in items player)
#define IN_VEHICLE (vehicle player != player)
#define IS_ALIVE (damage _object < 1)
#define IS_BIKE (_object isKindOf "Bicycle")
#define IS_PZOMBIE (player isKindOf "PZombie_VB")
private ["_action","_object","_show"];
_action = _this select 0;
_object = _this select 1;
_show = switch _action do {
case "Butcher": {!IS_ALIVE && !IN_VEHICLE && CAN_DO && !(_object getVariable["meatHarvested",false]) && !IS_PZOMBIE};
case "PushPlane": {IS_ALIVE && !IN_VEHICLE && CAN_DO && count crew _object == 0 && !isEngineOn _object && !IS_PZOMBIE};
case "Repair": {IS_ALIVE && !IN_VEHICLE && CAN_DO && _object != dayz_myCursorTarget && HAS_TOOLBOX};
case "Salvage": {IS_ALIVE && !IN_VEHICLE && CAN_DO && _object != dayz_myCursorTarget && HAS_TOOLBOX && !IS_BIKE && (DZE_salvageLocked or !locked _object)};
case "StudyBody": {!IS_ALIVE && !IN_VEHICLE && !(_object isKindOf "zZombie_base")};
default {false};
};
_show