Jump to content

Making Can Openers and Knives useful in Epoch


Grahame

Recommended Posts

With all the vanilla ARMA3 objects that have been added to A3E in 1.0 and beyond, there is a lot of new fun stuff you can do to make the experience more immersive and drive your players mad :ph34r: Here is just one such example, the addition of a requirement for can openers and knives for opening cans of food and gutting animals.

Gutting Animals with a Knife or Hatchet

So, you've just killed an animal in the wild and you want to gut it. At the moment you use your teeth and hands to field dress the animal. The code below adds a little more realism in that it forces you to have a knife or hatchet in order to get the meat and/or pelt from the carcass. 

Note: @Helion4 have you thought how great a hunting knife model would be (hoverboards are a lot more important though!!!)? :wink: 

Change lines 61 to 73 in epoch_code/compile/EPOCH_lootTrash.sqf from:

	if (!isNull _lootAnimalObj) then {

		_cfgItemInteractions = (_cfgObjectInteractions >> (typeOf _lootAnimalObj));
		_interactAttributes = getArray(_cfgItemInteractions >> "interactAttributes");

		_bloodPos = getPosATL _lootAnimalObj;
		_blood = "BloodSplat" createVehicleLocal _bloodPos;
		_blood setPosATL _bloodPos;

		// send
		[_lootAnimalObj, player, Epoch_personalToken] remoteExec ["EPOCH_server_lootAnimal",2];
		_return = true;
	};

to:

	if (!isNull _lootAnimalObj) then {

		if (("ItemKnife" in magazines player) || ("Hatchet" in weapons player) || ("CrudeHatchet" in weapons player)) then {
			_cfgItemInteractions = (_cfgObjectInteractions >> (typeOf _lootAnimalObj));
			_interactAttributes = getArray(_cfgItemInteractions >> "interactAttributes");

			_bloodPos = getPosATL _lootAnimalObj;
			_blood = "BloodSplat" createVehicleLocal _bloodPos;
			_blood setPosATL _bloodPos;

			// send
			[_lootAnimalObj, player, Epoch_personalToken] remoteExec ["EPOCH_server_lootAnimal",2];
		} else {
			["You need a knife or hatchet to gut an animal", 5] call Epoch_message;	
		};
		_return = true;
	};

A nice easy change that makes the gutting of animals a little more immersive and provides a reason for players to find and carry those items on them.

To eat from a can you first have to open it

The following code will add the requirement for a can opener, knife or hatchet (crude or otherwise) in order to open certain canned food items. Depending on which tool you have on you, you will get a different amount of hunger from consuming the can. For example, use a can opener then you get the full benefit, use a knife and you get 80% and if you use a hatchet to open it you just get 50% of the hunger back

Note: This is also a nice example of how you can add new interactions for objects you add to your server.

Add the following at line 415 in epoch_code/compile/EPOCH_consumeItem.sqf:

	case 17: { // Eat Canned Food - check for item to open the can with
		// Reduce attributes based on the type of item, can opener, knife or hatchet
		_attributesModifier = 1;
		_itemFound = false;
		if ('ItemCanOpener' in magazines player) then {
			_attributesModifier = 1;
			_itemFound = true;
		} else {
			if ('ItemKnife' in magazines player) then {
				_attributesModifier = 0.8;		
				_itemFound = true;
			} else {
				if (('Hatchet' in weapons player) || ('CrudeHatchet' in weapons player)) then {
					_attributesModifier = 0.5;		
					_itemFound = true;
				};
			};
		};
		if (_itemFound) then {
			private _removedCan = _item call _removeItem;
			if (_removedCan) then {
				if (_interactReturnOnUse != "") then {
					_interactReturnOnUse call EPOCH_fnc_addItemOverflow;
				};
				{
					_x set [1, ((_x select 1) * _attributesModifier)];
					_output = _x call EPOCH_giveAttributes;
					if (_output != "") then {
						[_output, 5] call Epoch_message_stack;
					};
				} foreach _interactAttributes;
			};
		} else {
			["You need a can opener, knife or hatchet to open the can", 5] call Epoch_message;
		};

Now you have a new interaction that will give you a certain amount of hunger back depending on what tool you use to open the can with. Now you need to make the cans themselves use it. This is done in epoch_config/Configs/CfgItemInteractions.hpp.

First add a new class for cans that requite something to open them. Add this code at line 59:

    class Food_TinCan_Tool_base : Food_base
    {
        interactAction = 17;
        interactReturnOnUse = "ItemEmptyTin";
    };

This gives you a class that cans which will require a can opener, etc. can inherit. So, let's say that a can of meatballs requires a tool to open. To make this so, you would change line 106 from

    class meatballs_epoch : Food_TinCan_base

to

    class meatballs_epoch : Food_TinCan_Tool_base

It's as simple as that. On my server I leave some cans, like sardines, openable without a tool and others requiring one. For those that do not need a tool you do not need to change anything.

Just a little fun and all done mission side.

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