Jump to content
  • 0

Chainsaw Vs Cinder


Jim90

Question

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

Link to comment
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/

Link to comment
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;
};

 

Link to comment
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

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