Jump to content
tourist

Wirecutting Script - WIP/code improvement tips needed

Recommended Posts

Hi folks,


 

ever since I play RAVAGE or WW2 missions I wished for a Wirecutter Script. ACE is out of question for me; I don't want to load ACE just for this feature - in fact I've so far almost always found a ready-to-use script or addon solution for all those of the ACE features I actually want to use.  Ever since I found the Sapper Tools in IFA3 and ever since I started to build missions using a combo of HEROS SURVIVE and RAVAGE, I wanted to put all those cool items from HEROS to a good use.  And this mod has a pliers item, so I thought to myself: "Would be mighty cool if these Sapper Tools or pliers could actually, well, DO something to a barbed wire fence!"


 

But since I couldn't find a working wirecutter script, I tried my hand at compiling a few lines of code from the BIS WIKI together.


 

The actual cutting is achieved by the code within


 

wirecutter.sqf

 

{ _x hideObjectGlobal true } foreach (nearestObjects [getPos player,["Land_New_WiredFence_5m_F","Land_I44_Buildings_Barbedwire2","Wire"],2]);"SNIPP SNAPP" HintC ["If I can read that and the fence is still standing, I'll have to add the classname to the array LOL"];


 

 


 

Then I add a set of triggers to the mission:


 

TRIGGER 1

checks if the player has the necessary item for wirecutting in his inventory:


 

CONDITION:

({_x in (items player + magazines player)}count ["herl_o_pliers"]>=1)

 

 

ON ACTIVATION:

 

pliers=true

 

ON DEACTICATION:

 

pliers=false

 

 

TRIGGER 2

 

adds the wirecutting action to the player once he has a set of the required tools in his inventory

 

CONDITION:

pliers


 

ON ACTIVATION:

 

_myaction_2 = player addAction ["Use Wirecutter","scripts\wirecutter.sqf",[],1,false,true] call BIS_fnc_MP;

 

 

ON DEACTICATION:

 

nothing stated

 

 


 

TRIGGER 3

should remove the wirecutting action again once the tools are dropped (this removeAction doesn't work...)

 

CONDITION:

({_x in (items player + magazines player)}count ["herl_o_pliers"]==0)


 

ON ACTIVATION:

 

_myaction_2 = player addAction ["Use Wirecutter","scripts\wirecutter.sqf",[],1,false,true] call BIS_fnc_MP;

 

 

ON DEACTICATION:

 

nothing stated

 

TRIGGER 3 ALTERNATIVE WAY:

should remove the wirecutting action again once the tools are dropped (this removeAction doesn't work as well...)

 

CONDITION:

!pliers


 

ON ACTIVATION:

 

player removeAction _myaction_2;

 

 

ON DEACTICATION:

 

nothing stated

 

 

I have two questions now:

 

  1. How could I achieve that in a „cleaner“ way without triggers who, AFAIK, can put quite the load on a mission's performance if checked repeatedly?
  2. How could I make the wirecutting action disappear once the player doesn't have the pliers item in his inventory anymore?

 

 

 

THX in Advance for any helpful advice!

 

 

  • Like 1

Share this post


Link to post
Share on other sites

> How could I achieve that in a „cleaner“ way without triggers who, AFAIK, can put quite the load on a mission's performance if checked repeatedly?

not really. triggers only have cycle time of 0.5s - only if you have really complex conditions

for MP its more to design them correctly

 

however you could make this a displayAddEventhandler based instead (when people press "use" action) - its less transparent though

 

> How could I make the wirecutting action disappear once the player doesn't have the pliers item in his inventory anymore?

you need to store the actionID in a global variable or setVariable on the player, and removeAction that ID again

Share this post


Link to post
Share on other sites

Hi tourist! 

 

Although not supported anymore, this script still works, and can be built upon by adding in more classnames to the fence types.

http://www.armaholic.com/page.php?id=22374 

 

EDIT:

If the above script interests you I'd recommend changing the original cutting animation in the cut.sqf from this...

	_player playActionNow "PutDown";

to this...

	_player playMove "AinvPknlMstpSnonWnonDnon_medicUp1";

Looks a little better. :f:   

  • Thanks 3

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×