Jump to content
  • 0
Jim90

Chainsaw Vs Cinder

Question

Has anyone made a script to stop chainsaws from cutting through cinder and metal? Something as simple as the fuel being removed as soon as the chainsaw hits the cinder or metal item should work.

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello,

It's possible to do but requires a bit of fiddling.

Here's how I did it on my test server:

In dayz_server\system\server_monitor.sqf find this code block (https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_server/system/server_monitor.sqf#L315-L317):

                } else {
                    _object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
                };

Add this line after the } else {:

_object addEventHandler ["HandleDamage",{_this call object_handleDamage;}];

So that code block now looks like this:

				} else {
					_object addEventHandler ["HandleDamage",{_this call object_handleDamage;}];
					_object addMPEventHandler ["MPKilled",{_this call vehicle_handleServerKilled;}];
				};

You need a custom compiles.sqf for this, if you use my ZSC or anything else you will have one, if not, see this for an example: https://github.com/oiad/ZSC/blob/master/dayz_code/init/compiles.sqf#L2

You will need to put the following code inside this code block:

if (isServer) then {
	diag_log "Loading custom server compiles";	
};
	object_handleDamage = {
		private ["_damage","_type"];
		
		_damage = _this select 2;
		_type = _this select 4;

		if (_type == "Chainsaw_Swing_Ammo") exitWith {};
		_damage
	};

So it looks like this:

if (isServer) then {
	diag_log "Loading custom server compiles";

	object_handleDamage = {
		private ["_damage","_type"];
		
		_damage = _this select 2;
		_type = _this select 4;

		if (_type == "Chainsaw_Swing_Ammo") exitWith {};
		_damage
	};
};

That will properly disable chainsaws from causing damage to items not in this array: https://github.com/EpochModTeam/DayZ-Epoch/blob/master/SQF/dayz_code/configVariables.sqf#L31

Share this post


Link to post
Share on other sites
  • 0
On 25/4/2017 at 11:13 PM, Jim90 said:

Has anyone made a script to stop chainsaws from cutting through cinder and metal? Something as simple as the fuel being removed as soon as the chainsaw hits the cinder or metal item should work.

this is an old script who set chances to broke the melee weapons when shoots on modular builds

goes into a custom player_harvest.sqf at very bottom.  but you need check if the Modulars objects still have the same id.

you can use it to set a high chance to broke the tools or just remove the chances and leave alone the player removeWeapon..

private ["_item","_iPos","_weapon","_primaryWeapon","_iItem","_removed","_radius","_dropPrimary","_buildableNearby","_breakChance"];
_buildableNearby = false;
_breakChance = 1;
if (_ammo isKindOf "Sledge_Swing_Ammo") then {
    _breakChance = 0.1;
};
if (_ammo isKindOf "Crowbar_Swing_Ammo") then {
    _breakChance = 0.5;
};
if (_ammo isKindOf "Hatchet_Swing_Ammo" or _ammo isKindOf "Machete_Swing_Ammo" or _ammo isKindOf "Sledge_Swing_Ammo" or _ammo isKindOf "Crowbar_Swing_Ammo" or _ammo isKindOf "Fishing_Swing_Ammo") then {
    {
        if ((_x isKindOf "ModularItems") or (_x isKindOf "Land_DZE_WoodDoor_Base") or (_x isKindOf "CinderWallDoor_DZ_Base")) then {
            if (alive _x) then {
                _buildableNearby = true;
            };
        };
    } foreach nearestObjects [getPosATL player, [], 6];
    if(_buildableNearby) then {
        if(random 100 <= _breakChance) then {
            _primaryWeapon = primaryWeapon player;
            cutText ["\n\nYour Melee-Weapon broke while you was trying to destroy this buildable!", "PLAIN DOWN"];
            player removeWeapon _primaryWeapon;
        } else {
            cutText [format["\n\nYour Melee-Weapon has a %1%2 chance to break while using it near buildables!",_breakChance,"%"], "PLAIN DOWN"];
        };
    };
};

original post

http://opendayz.net/threads/release-epoch-breakable-melee-weapons-on-buildables.18178/

Share this post


Link to post
Share on other sites
  • 0

here's what I used to use when people actually played this game, don't remember who made it so no creds

while {true} do {
	_notAllowed =
	[
		'ChainSaw','ChainSawB','ChainSawG','ChainSawP','ChainSawR'
	];
	_noBreaking =
	[
		'CinderWallHalf_DZ','CinderWall_DZ','MetalFloor_DZ'
	];
	
	_cwep = currentWeapon player;
	_typeOfCursorTarget = typeOf cursorTarget;
	if (_cwep in _notAllowed && _typeOfCursorTarget in _noBreaking) then {
		player_fired = {
			deleteVehicle (nearestObject [_this select 0,_this select 4]);
			cutText ['ChainSaw is too blunt to destroy Cinder Walls And Metal Floors!','WHITE IN'];
		};
		player removeAllEventHandlers 'Fired';
		player addEventHandler ['Fired', {_this call player_fired;}];
	};
	sleep 0.1;
};

 

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, Buck0 said:

here's what I used to use when people actually played this game, don't remember who made it so no creds

while {true} do {
	_notAllowed =
	[
		'ChainSaw','ChainSawB','ChainSawG','ChainSawP','ChainSawR'
	];
	_noBreaking =
	[
		'CinderWallHalf_DZ','CinderWall_DZ','MetalFloor_DZ'
	];
	
	_cwep = currentWeapon player;
	_typeOfCursorTarget = typeOf cursorTarget;
	if (_cwep in _notAllowed && _typeOfCursorTarget in _noBreaking) then {
		player_fired = {
			deleteVehicle (nearestObject [_this select 0,_this select 4]);
			cutText ['ChainSaw is too blunt to destroy Cinder Walls And Metal Floors!','WHITE IN'];
		};
		player removeAllEventHandlers 'Fired';
		player addEventHandler ['Fired', {_this call player_fired;}];
	};
	sleep 0.1;
};

 

That's going to be quite an intensive script, the one I linked will only fire when the object is damaged, yours will be constantly running on the client

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...