Jump to content
  • 0

Maintain Object only Owner?


Cryten

Question

Would it be possible to use only the Owner Maintain? You could use this to make indestructible objects -> Breakable objects. If you have the script "Indestructible Bases"

 

There is the script "Deconstruct Buildables," but that's only until reboot or until the death of the player. But if you MAINTAIN used, the object is destructable again. so this idea

 .

of course the plotpole should work ....

 

??

 

possibly because who has an idea?

 

like ....    if (_tobe_removed_total == _removed_total and _isOwnerOfObj) then {

/*
	DayZ Base Building Maintenance
	Made for DayZ Epoch please ask permission to use/edit/distrubute email [email protected].
*/
private ["_location","_dir","_classname","_missing","_text","_proceed","_num_removed","_object","_missingQty","_itemIn","_countIn","_qty","_removed","_removed_total","_tobe_removed_total","_objectID","_objectUID","_temp_removed_array","_textMissing","_requirements","_obj","_upgrade","_objectCharacterID"];

if(TradeInprogress) exitWith { cutText ["Upgrade already in progress." , "PLAIN DOWN"]; };
TradeInprogress = true;

player removeAction s_player_maint_build;
s_player_maint_build = 1;

// get cursortarget from addaction
_obj = _this select 3;

// Find objectID
_objectID 	= _obj getVariable ["ObjectID","0"];

// Find objectUID
_objectUID	= _obj getVariable ["ObjectUID","0"];

if(_objectID == "0" && _objectUID == "0") exitWith {TradeInprogress = false; s_player_maint_build = -1; cutText ["Not setup yet.", "PLAIN DOWN"];};

// Get classname
_classname = typeOf _obj;

// Find display name
_text = getText (configFile >> "CfgVehicles" >> _classname >> "displayName");

// Find next maintain
_upgrade = getArray (configFile >> "CfgVehicles" >> _classname >> "maintainBuilding");

if ((count _upgrade) > 0) then {
	_requirements = _upgrade;
} else {
	_requirements = [["PartGeneric",1]];
};

_missingQty = 0;
_missing = "";

_proceed = true;
{
	_itemIn = _x select 0;
	_countIn = _x select 1;
	_qty = { (_x == _itemIn) || (configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn) } count magazines player;
	if(_qty < _countIn) exitWith { _missing = _itemIn; _missingQty = (_countIn - _qty); _proceed = false; };
} forEach _requirements;

if (_proceed) then {

	player playActionNow "Medic";
	[player,20,true,(getPosATL player)] spawn player_alertZombies;

	_temp_removed_array = [];
	_removed_total = 0;
	_tobe_removed_total = 0;
	
	{
		_removed = 0;
		_itemIn = _x select 0;
		_countIn = _x select 1;
		// diag_log format["Recipe Finish: %1 %2", _itemIn,_countIn];
		_tobe_removed_total = _tobe_removed_total + _countIn;

		{					
			if( (_removed < _countIn) && ((_x == _itemIn) || configName(inheritsFrom(configFile >> "cfgMagazines" >> _x)) == _itemIn)) then {
				_num_removed = ([player,_x] call BIS_fnc_invRemove);
				_removed = _removed + _num_removed;
				_removed_total = _removed_total + _num_removed;
				if(_num_removed >= 1) then {
					_temp_removed_array set [count _temp_removed_array,_x];
				};
			};
	
		} forEach magazines player;

	} forEach _requirements;

	// all parts removed proceed
	if (_tobe_removed_total == _removed_total) then {
		
		// Get position
		_location	= _obj getVariable["OEMPos",(getposATL _obj)];

		// Get direction
		_dir = getDir _obj;

		// Find CharacterID
		_objectCharacterID 	= _obj getVariable ["CharacterID","0"];
		
		// Create new object 
		_object = createVehicle [_classname, [0,0,0], [], 0, "CAN_COLLIDE"];

		// Set direction
		_object setDir _dir;

		// Set location
		_object setPosATL _location;

		PVDZE_obj_Swap = [_objectCharacterID,_object,[_dir,_location],_classname,_obj,_objectID,_objectUID];
		publicVariableServer "PVDZE_obj_Swap";

		cutText [format["Item is now Destroyable %1.",_text], "PLAIN DOWN", 5];

		player reveal _object;
		
	} else {
	
		{player addMagazine _x;} forEach _temp_removed_array;
		cutText [format["Missing Parts after first check Item: %1 / %2",_removed_total,_tobe_removed_total], "PLAIN DOWN"];
	
	};
} else {
	_textMissing = getText(configFile >> "CfgMagazines" >> _missing >> "displayName");
	cutText [format["Missing %1 more of %2",_missingQty, _textMissing], "PLAIN DOWN"];
};


TradeInprogress = false;
s_player_maint_build = -1;
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The key to making an object indestructible is by changing the HandleDamage eventHandler:

_object addEventHandler ["HandleDamage", {false}];

If you apply that in the right place you will have an indestructible object (wall floor etc.). That can be removed at any time with removeEventhandler.

 

One issue I have read about since 1.0.2.4 is that, with indestructible bases, you may lose the ability to maintain, presumably as the objects now need at minimum percentage of damage to allow maintenance.

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...