Jump to content
  • 0

Maintain Area epoch_returnchange


Havoc302

Question

11 answers to this question

Recommended Posts

  • 0

This works for me (with limited testing):

Create a file in your scripts folder called maintain_area.sqf with this code:
 

//Code developed by Axe Cop - Massiv improvments && performance tunes by Skaronator - simplified by Deadeye
private ["_textMissing","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_itemText","_option","_objects_filtered"];

if (DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_ACTIONS_2") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

player removeAction s_player_maintain_area;
s_player_maintain_area = 1;
player removeAction s_player_maintain_area_preview;
s_player_maintain_area_preview = 1;

_target = cursorTarget; // Plastic_Pole_EP1_DZ

_objectClasses = DZE_maintainClasses;
_range = DZE_maintainRange; // set the max range for the maintain area
_objects = nearestObjects [_target, _objectClasses, _range];

//filter to only those that have 10% damage
_objects_filtered = [];
{
    if (damage _x >= DZE_DamageBeforeMaint) then {
        _objects_filtered set [count _objects_filtered, _x];
   };
} count _objects;
_objects = _objects_filtered;

// TODO dynamic requirements based on used building parts?
_count = count _objects;

if (_count == 0) exitWith {
	cutText [format[(localize "STR_EPOCH_ACTIONS_22"), _count], "PLAIN DOWN"];
	DZE_ActionInProgress = false;
	s_player_maintain_area = -1;
	s_player_maintain_area_preview = -1;
};

_requirements = [];
switch true do {
	case (_count <= 10):  {_requirements = ["ItemGoldBar10oz",1]};
	case (_count <= 20):  {_requirements = ["ItemGoldBar10oz",2]};
	case (_count <= 35):  {_requirements = ["ItemGoldBar10oz",3]};
	case (_count <= 50):  {_requirements = ["ItemGoldBar10oz",4]};
	case (_count <= 75):  {_requirements = ["ItemGoldBar10oz",6]};
	case (_count <= 100): {_requirements = ["ItemBriefcase100oz",1]};
	case (_count <= 175): {_requirements = ["ItemBriefcase100oz",2]};
	case (_count <= 250): {_requirements = ["ItemBriefcase100oz",3]};
	case (_count <= 325): {_requirements = ["ItemBriefcase100oz",4]};
	case (_count <= 400): {_requirements = ["ItemBriefcase100oz",5]};
	case (_count <= 475): {_requirements = ["ItemBriefcase100oz",6]};
	case (_count <= 550): {_requirements = ["ItemBriefcase100oz",7]};
	case (_count <= 625): {_requirements = ["ItemBriefcase100oz",8]};
	case (_count > 625):  {_requirements = ["ItemBriefcase100oz",9]};
};

_option = _this select 3;

switch _option do {
	case "maintain": {
		if !([[_requirements],0] call epoch_returnChange) then {
			_textMissing = getText(configFile >> "CfgMagazines" >> _requirements select 0 >> "displayName");
			cutText [format[(localize "STR_EPOCH_ACTIONS_6"), _requirements select 1, _textMissing], "PLAIN DOWN"];
		} else {
			player playActionNow "Medic";
			[player,_range,true,(getPosATL player)] spawn player_alertZombies;
			cutText [format[(localize "STR_EPOCH_ACTIONS_4"), _count], "PLAIN DOWN", 5];
			PVDZE_maintainArea = [player,1,_target];
			publicVariableServer "PVDZE_maintainArea";
		};
	};
	case "preview": {
		//_cost = "";
		_itemText = getText(configFile >> "CfgMagazines" >> _requirements select 0 >> "displayName");
		_cost = str(_requirements select 1) + " of " + _itemText;
		cutText [format[(localize "STR_EPOCH_ACTIONS_7"), _count, _cost], "PLAIN DOWN"];
	};
};

DZE_ActionInProgress = false;
s_player_maintain_area = -1;
s_player_maintain_area_preview = -1;

Then in your fn_selfActions.sqf:
change

s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false];

to

s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "scripts\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "scripts\maintain_area.sqf", "preview", 5, false];

If you put it somewhere other than your scripts folder, change it to match the location.

Link to comment
Share on other sites

  • 0

This works for me (with limited testing):

Create a file in your scripts folder called maintain_area.sqf with this code:

 

//Code developed by Axe Cop - Massiv improvments && performance tunes by Skaronator - simplified by Deadeye
private ["_textMissing","_target","_objectClasses","_range","_objects","_requirements","_count","_cost","_itemText","_option","_objects_filtered"];

if (DZE_ActionInProgress) exitWith { cutText [(localize "STR_EPOCH_ACTIONS_2") , "PLAIN DOWN"]; };
DZE_ActionInProgress = true;

player removeAction s_player_maintain_area;
s_player_maintain_area = 1;
player removeAction s_player_maintain_area_preview;
s_player_maintain_area_preview = 1;

_target = cursorTarget; // Plastic_Pole_EP1_DZ

_objectClasses = DZE_maintainClasses;
_range = DZE_maintainRange; // set the max range for the maintain area
_objects = nearestObjects [_target, _objectClasses, _range];

//filter to only those that have 10% damage
_objects_filtered = [];
{
    if (damage _x >= DZE_DamageBeforeMaint) then {
        _objects_filtered set [count _objects_filtered, _x];
   };
} count _objects;
_objects = _objects_filtered;

// TODO dynamic requirements based on used building parts?
_count = count _objects;

if (_count == 0) exitWith {
	cutText [format[(localize "STR_EPOCH_ACTIONS_22"), _count], "PLAIN DOWN"];
	DZE_ActionInProgress = false;
	s_player_maintain_area = -1;
	s_player_maintain_area_preview = -1;
};

_requirements = [];
switch true do {
	case (_count <= 10):  {_requirements = ["ItemGoldBar10oz",1]};
	case (_count <= 20):  {_requirements = ["ItemGoldBar10oz",2]};
	case (_count <= 35):  {_requirements = ["ItemGoldBar10oz",3]};
	case (_count <= 50):  {_requirements = ["ItemGoldBar10oz",4]};
	case (_count <= 75):  {_requirements = ["ItemGoldBar10oz",6]};
	case (_count <= 100): {_requirements = ["ItemBriefcase100oz",1]};
	case (_count <= 175): {_requirements = ["ItemBriefcase100oz",2]};
	case (_count <= 250): {_requirements = ["ItemBriefcase100oz",3]};
	case (_count <= 325): {_requirements = ["ItemBriefcase100oz",4]};
	case (_count <= 400): {_requirements = ["ItemBriefcase100oz",5]};
	case (_count <= 475): {_requirements = ["ItemBriefcase100oz",6]};
	case (_count <= 550): {_requirements = ["ItemBriefcase100oz",7]};
	case (_count <= 625): {_requirements = ["ItemBriefcase100oz",8]};
	case (_count > 625):  {_requirements = ["ItemBriefcase100oz",9]};
};

_option = _this select 3;

switch _option do {
	case "maintain": {
		if !([[_requirements],0] call epoch_returnChange) then {
			_textMissing = getText(configFile >> "CfgMagazines" >> _requirements select 0 >> "displayName");
			cutText [format[(localize "STR_EPOCH_ACTIONS_6"), _requirements select 1, _textMissing], "PLAIN DOWN"];
		} else {
			player playActionNow "Medic";
			[player,_range,true,(getPosATL player)] spawn player_alertZombies;
			cutText [format[(localize "STR_EPOCH_ACTIONS_4"), _count], "PLAIN DOWN", 5];
			PVDZE_maintainArea = [player,1,_target];
			publicVariableServer "PVDZE_maintainArea";
		};
	};
	case "preview": {
		//_cost = "";
		_itemText = getText(configFile >> "CfgMagazines" >> _requirements select 0 >> "displayName");
		_cost = str(_requirements select 1) + " of " + _itemText;
		cutText [format[(localize "STR_EPOCH_ACTIONS_7"), _count, _cost], "PLAIN DOWN"];
	};
};

DZE_ActionInProgress = false;
s_player_maintain_area = -1;
s_player_maintain_area_preview = -1;

Then in your fn_selfActions.sqf:

change

s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "\z\addons\dayz_code\actions\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "\z\addons\dayz_code\actions\maintain_area.sqf", "preview", 5, false];

to

s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "scripts\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "scripts\maintain_area.sqf", "preview", 5, false];

If you put it somewhere other than your scripts folder, change it to match the location.

Awesome, thanks a bunch, I searched the forums but couldn't find anywhere that had this, I hope it becomes standard with the next version of Epoch.

Link to comment
Share on other sites

  • 0

You mean like this?

 

s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "custom\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "custom\maintain_area.sqf", "preview", 5, false];
Link to comment
Share on other sites

  • 0

Yes, as long as maintain_area.sqf is in your custom folder.

 

The section of your fn_selfActions.sqf should look like this:

	if (_canDo && (speed player <= 1) && (_cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {
		if (s_player_maintain_area < 0) then {
			s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "custom\maintain_area.sqf", "maintain", 5, false];
			s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "custom\maintain_area.sqf", "preview", 5, false];
		};
	} else {
		player removeAction s_player_maintain_area;
		s_player_maintain_area = -1;
		player removeAction s_player_maintain_area_preview;
		s_player_maintain_area_preview = -1;
	};

Sorry, it has worked flawlessly for me.

Link to comment
Share on other sites

  • 0

Yep that's what I have too.

 

 if (_canDo && (speed player <= 1) && (_cursorTarget isKindOf "Plastic_Pole_EP1_DZ")) then {
if (s_player_maintain_area < 0) then {
  s_player_maintain_area = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTAREA"], "custom\maintain_area.sqf", "maintain", 5, false];
s_player_maintain_area_preview = player addAction [format["<t color='#ff0000'>%1</t>",localize "STR_EPOCH_ACTIONS_MAINTPREV"], "custom\maintain_area.sqf", "preview", 5, false];
};
} else {
     player removeAction s_player_maintain_area;
     s_player_maintain_area = -1;
     player removeAction s_player_maintain_area_preview;
     s_player_maintain_area_preview = -1;
};

I'll test it out on my test server again, see if I can get it working.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...