Home   Help Search Login Register  

Author Topic: Infantry cutting wire fences?  (Read 4139 times)

0 Members and 1 Guest are viewing this topic.

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Infantry cutting wire fences?
« on: 06 Apr 2008, 23:12:45 »
Hi all!

I am planning a defence mission in Corazol where I want to simulate the cutting of a wire fence.
Right now, tanks can go sometimes over it, while infantry rushes through as if the fence is not present. What I want to achieve is to have any OPFOR infantry to stop at the wire, performing the medic's healing animation, and upon surviving doing so for 10 seconds, the fence would be deletevehicle'd, eg. cut away. And then the rest of the OPFOR infantry would charge forward unaffected.

Note that I want to do it with every of several waves of infantry hitting the wire, not just with some soldiers that could perform this animation within a certain distance of said fence.
I tried {_x  playmove "AinvPknlMstpSlayWrflDnon_medic"} foreach thislist inside a trigger, but it only affects the first soldier to enter that trigger (and yes, it is set to "repeatedly"). The others are just standing there at their hold waypont, doing nothing.

Help on this subject would be very much appreciated!

Offline schuler

  • Contributing Member
  • **
Re: Infantry cutting wire fences?
« Reply #1 on: 07 Apr 2008, 03:35:40 »
iam crap at scripting but could you add a setDammage to nearest object and then delete addAction ?
i know this is not an answer to you question but might be of some help.
Semper Fi

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Infantry cutting wire fences?
« Reply #2 on: 07 Apr 2008, 11:36:30 »
Your issue with triggers is a common misunderstanding (Just realised I made this mistake myself only last week...oops!). In a trigger's condition, the value of "this" is true if someone is in the trigger zone and is false if there is no-one in the zone; "this" is the default condition, but you can choose another one. The trigger is activated when the condition, whatever that is, changes from false to true and the trigger is deactivated when the condition changes from true to false. Triggers do not activate repeatedly while the condition is true (e.g. in your case, when more soldiers enter the zone after the first one has activated it). A repeating trigger will continually activate and deactivate throughout a mission, but a single-use trigger will only activate then deactivate once.

To continuously perform code on the people/objects within a trigger zone, you need to set up a separate script which looks at the current list of objects within the trigger, which is kept up to date for you by the trigger (the trigger has been given the var-name of "myTrigger" in the editor):
Code: [Select]
while { wireNotCut } do
{
    {
         // Do stuff to _x.
    } forEach (list myTrigger);

    sleep 1;
};

EDIT: The full solution to your question is actually quite involved so I didn't complete it for you, but remember that you don't want soldiers to be told to do the medic animation if they are already doing it (add the soldier object to an array or add a variable to the soldier so you know which ones are already busy). Good luck!
« Last Edit: 07 Apr 2008, 11:41:53 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Loyalguard

  • Former Staff
  • ****
Re: Infantry cutting wire fences?
« Reply #3 on: 07 Apr 2008, 12:19:25 »
Regarding the wirecutting portion, as discussed in this thread: Wirecutters, there is some difficulty finding and specifying the section of fence to cut unless you find the exact object IDs in the editor and put this into the script and then setDamage them.  I have recently come across a possible solution to being able to "cut" any wire fence without knowing the object ID in advance but I need some more time to work on it if you are interested.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Infantry cutting wire fences?
« Reply #4 on: 07 Apr 2008, 12:34:45 »
LoyalGuard, you are assuming that the fences are pre-placed on the map (problematic, as you point out) and not added manually in the editor (no problems) :whistle:
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #5 on: 07 Apr 2008, 12:35:10 »
Hi schuler!

Just checked, the fence has no damage model, so setdamage 1 makes no sense. I am already capable of sending single soldiers to the fence, performing said animation and upon doing that provided that this soldier survives for an X amount of time, I use deletevehicle on the fence.

What I have are 2 triggers. The first one has soldier1 distance fence < 5 in it's "Condition" field and soldier1 playmove "AinvPknlMstpSlayWrflDnon_medic" in it's "On Activation" field.
The second one features a condition of soldier1 distance fence < 5 AND alive soldier1 and on activation it reads deletevehicle fence. I don't want to add the names of maybe 20 soldiers to that triggers...

And yes, the fence is placed manually in the editor.
« Last Edit: 07 Apr 2008, 12:40:14 by mathias_eichinger »

Offline Cheetah

  • Former Staff
  • ****
Re: Infantry cutting wire fences?
« Reply #6 on: 07 Apr 2008, 12:41:22 »
Maybe I should add that from a mission making perspective, it might not be so good to have ALL soldiers start working on the wires.

My idea of the mission is that the player has to prevent the breakthrough of the fence to keep himself and his mates alive. If everyone starts with wirecutting, it is pretty easy for the player to take hem out. But it might be something completely different you're after.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Infantry cutting wire fences?
« Reply #7 on: 07 Apr 2008, 12:43:50 »
Well, I told you the method of looking at what soldiers were currently in the zone, rather than just being notified when the first soldier enters the zone. This is more complex to write, but significantly less cumbersome than having dozens of unnecessary triggers.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #8 on: 07 Apr 2008, 12:49:53 »
@Cheetah

Good point, my idea for the mission is to have infantry come in several waves (groups) where the first one rushes forward to cut the wire, the second one holds the ground behind and provides cover fire ("Open fire, engage at will" should do the trick I think). If the first squad does not make it, the second rushes forward to perform the cutting operation, while the third squad assumes firing positions. I plan to have 3 or 4 waves of infantry, and the cover fire should make it hard to just concentrate on the wire cutting soldiers.
Add in a few tanks that slowly crawl over the obstacle and you have a pretty challenging defence mission - at least in my imagination.

@Spooner:

Thank you very much, I will see if I get the hang of it.
« Last Edit: 07 Apr 2008, 13:44:04 by mathias_eichinger »

Offline Cheetah

  • Former Staff
  • ****
Re: Infantry cutting wire fences?
« Reply #9 on: 07 Apr 2008, 13:17:03 »
That was my imagination too mathias, should make an interesting mission. But, the scripting involves quite a bit of thinking.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #10 on: 15 Apr 2008, 17:03:39 »
After messing around with this problem I am still stuck:

Code: [Select]

while { wireNotCut } do
{
    {
         // Do stuff to _x.
    } forEach (list myTrigger);

    sleep 1;
};

gives me the # sleep1 error.

Any pointers what to do?


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Infantry cutting wire fences?
« Reply #11 on: 15 Apr 2008, 18:59:06 »
You sure you are using SQF? sleep isn't valid in SQS, you see.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #12 on: 15 Apr 2008, 21:07:32 »
Well, I am using .sqs and I got a missing { error once I replaces sleep 1 with ~1 since I found the .sqf fact during a forum search meanwhile.

Or should I just save that thing as .sqf?
« Last Edit: 15 Apr 2008, 21:14:52 by mathias_eichinger »

Offline Rommel92

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #13 on: 15 Apr 2008, 22:17:05 »
Save as .SQF, and make sure its executed like one two. (execVM instead of exec, and if in a global space (ie a trigger) (nil = [blah] execVM "script.sqf")).

 ;)

Offline Darren

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #14 on: 15 Apr 2008, 23:23:40 »
 :scratch: :scratch:
I'm just learning myself, but could this help?

If I understand correctly, the problem is that only a few units cut wire and not all of them...
                                     
I tried something by placing a long trigger across the path of a group of units running over it and on activation of this trigger I entered
{_x  playmove "AinvPknlMstpSlayWrflDnon_medic"} foreach thislist
                                       
The problem with this was, that depending on the formation of the group, only a few units entered the trigger's area and they would be the only ones that executed the animation.                       
The others that entered the area after the trigger was activated, did not execute this command.                   

Once inside the trigger area it will not deactivate it until all units were out.
This means that the late comers will not animate.

In order for me to get everyone to execute the animation I had to execute the playmove foreach member of the group responsible for activating the trigger and not the list of people in the trigger area.
{{_x  playmove "AinvPknlMstpSlayWrflDnon_medic"} foreach units group _x} foreach thislist
This worked, but some were still a distance away.

One could overcome the distance issue if you had a script that got called when trigger activated and passed it the first unit in the trigger area.                                           

///Sample Script///
; - Create a group of soldiers
; - Place an object down and name it Fence in the Editor
; - Set a move waypoint for the group to the object named Fence
; - Create a trigger close enough to detect units in the minumim distance of the "Fence"
; - Trigger's OnActivation: [call {thislist select 0}] exec "CutScript.sqs"

;Set the minimum distance (in meters) from the object/point
;all units in the group have to be
;before animation occurs or event starts

;if I'm not mistaken, one should consider the size and formation of the group
;as each member in the group has to naturally be able to be within this distance.

;Should be 1 second per try
;but I don't know how long it would take per loop before waiting a second
_counterTimesToTry = 10

;The only object I have in my mission is a red cone named Fence
_objectTheFence = Fence

;Set the minimum distance to object/point
_metersMinimumDistToFence = 10

#StartScript
;Are you out of tries?
if (_counterTimesToTry == 0) then {goto "#TriesUp"}

;Get the first unit in trigger area
_unitInArea = _this select 0

;Get the group he belongs to
_groupCloseToArea = group _unitInArea

;Get the array of alive units in this group
_arrayUnits = units _groupCloseToArea

;Check the distance to your fence foreach member in the group
;and count those greater and less than minimum distance
_countUnitsIn = 0
_countUnitsOut = 0

{if(_objectTheFence distance _x > _metersMinimumDistToFence) then {_countUnitsOut = _countUnitsOut + 1} else {_countUnitsIn = _countUnitsIn + 1}} foreach _arrayUnits

;Wait a second
~1

if(_countUnitsOut > 0) then goto "TooFar" else goto "Animate"

#TooFar

;Subtract a try
_counterTimesToTry = _counterTimesToTry - 1

;For frame of reference only:
;Here is a display of how many friendlys are in area and how many out
hint format["\nTotal Units : %3 \n\n====================\n\nIn Area : ......%1\n\nOut of Area : ..%2\n\n", _countUnitsIn, _countUnitsOut, count _arrayUnits]

;Start Again
goto"StartScript"

#Animate
;play your animation
{_x  playmove "AinvPknlMstpSlayWrflDnon_medic"} foreach _arrayUnits

#TriesUp
;You have reached your tries...

;whatever you want to do when your tries or time is up,
;do it here!

;I guess if they are still alive now trying to cut the fence
;then they deserve the next group joining them for backup
;you may want to double your distance minimum here
;as the next group's size formation plays a part here.

#Exit
hint "Script Exiting..."
~2
Exit

Offline Rommel92

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #15 on: 16 Apr 2008, 05:06:01 »
Best for readibility mate, put that in the [ code ] brackets.  ;)

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #16 on: 16 Apr 2008, 11:12:34 »
Wow, thank you very much, Darren!

I need to try it out today, looks like it could solve my problem!


Offline Darren

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #17 on: 16 Apr 2008, 23:23:34 »
 :-[     :whistle:      :D
Code: [Select]
; Appologies to all who had to bare witness to my stupidity!
; I did not know how the others got it right!!
;
;Special thanks to Rommel92 and his ability!
;As he has shown me the light!!

Oh, Mathias...
I only thought of it afterwards. I noticed that all units flawlessly executed each "Wire cutting" move to synchronised perfection.  Now...
Either they are the best trained military force in the world, that even under fire, their squad performs each move to military precision.  They would have had my old staff sergent standing with a giant military eraction if he saw that!!
Or they are a team of ex-"syncronised swimmers".  :dunno: :scratch:

Suggestion, once you know the group is in the area (and you have that array available), use a combination of various "wire cutting" animations (I don't know if there are any more) and radomly allocate them to the units in the array.  Also, try and insert a very small random delay (a few milliseconds only) between the execution of the animations.  This should give it a more realistic effect.

As my sample script monitors each unit in the group's distance to the fence, then once any individual unit reaches the minimum distance, the animation for that unit can start and that unit should be removed from the array.  This would ensure that as each unit enters the "Cut Zone" they individually start cutting.  :yes:

Should work  :whistle:
« Last Edit: 16 Apr 2008, 23:44:49 by Darren »

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #18 on: 16 Apr 2008, 23:58:48 »
Hey Darren!

Well, tried out your script and I don't know what I am doing wrong AGAIN; the soldiers in the trigger area perform exactly ONE animation before the script exits. Hell, I might just throw in a shitload of triggers and some single soldiers, as I wanted to avoid in the beginning...


Offline Darren

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #19 on: 17 Apr 2008, 21:39:59 »
Oh, wait... ???

Is the problem not the fact that only one soldier performs the animation (as all soldiers are animating!),
but only one animation is performed??
...and you want them to cut wire for the full 10 seconds?? :dunno:

Offline Rommel92

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #20 on: 17 Apr 2008, 22:18:23 »
Place maybe three triggers in the editor on same POSITION as the wire you wish to cut (with radius of about 3m)
Code: [Select]
BLUFOR - PRESENT
Condition: This
OnActivation: {[_x] spawn {for "_i" from 0 to 2 do{_this select 0 playmove "AinvPknlMstpSlayWrflDnon_medic";sleep 4.5;};deleteVehicle WIRE1;};} ForEach thislist;
Change WIRE1 to name of the wire to be cut, and do a few times along the fence, it'll be cut the second BLUFOR step into the trigger area, with all the guys in that trigger range performing the animation three/four times before deleting the wire.

Code Checked, works beaut. Example Mission Uploaded.
« Last Edit: 17 Apr 2008, 22:29:44 by Rommel92 »

Offline Captain

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #21 on: 18 Apr 2008, 00:13:49 »
Rather than having to name the section of fence can the script be modified to just detect fence objects nearby? I was hoping to make a new wire cutting inventory item and allow it to cut fences that are built into the map.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Infantry cutting wire fences?
« Reply #22 on: 18 Apr 2008, 07:18:09 »
Hey mathias,

I did this sample mission (attached) and I rework the cutter.sqs
Now it's works.

You have not set any condition in the WPs, just drop the way of engineers accross the wires (as you see, you can create multiple wire-blockade levels) and create a trigger to every blockade and call this cutter.sqs.
You can create individual engineer groups, they will work individually. If one group die, the other group can work...

For you I insert a T-72 and I put him WPs with condition. It cause the T-72 stop behind every blockade and wait for the engineers. If engineers destroy the blockade, the tank continue his way.

(My 1.08 ArmA is terrible with bridges, so your mission - and mine too - didn't work in the middle section of Corazol, on the bridge. But I create them in my mission too, and I hope in your 1.11 ArmA, they will work too.)
Fix bayonet!

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Infantry cutting wire fences?
« Reply #23 on: 18 Apr 2008, 07:20:52 »
Now I explain you the cutter.sqs:

Code: [Select]
_engineers = _this select 0
_fences = _this select 1
These lines read the parameters.

Code: [Select]
_maxprogress = 20
This variable determine how fast engineer works. If you change it higher, they will work slowly. I suggest you to change it higher in the real mission.

Code: [Select]
{_x disableAI "MOVE"} foreach units _engineers
This line STOP the engineers (they will cannot move).

Code: [Select]
#loop

{_x playmove "AinvPknlMstpSlayWrflDnon_medic"} foreach units _engineers

~5
The loop started. And engineers play the medic anim. And script wait 5 second for the anim.

Code: [Select]
_progress = _progress + (count units _engineers)
Wire-cutting progress incresed by number of engineers. It means, fewer engineers works slower. And more engineers work faster.

Code: [Select]
?(_progress > _maxprogress) : goto "done"
If progress reach the maximum, it's time to finish the loop and do our final job...

Code: [Select]
?(count units _engineers == 0) : exit
If all engineers are dead, script end to save the CPU.

Code: [Select]
{ deleteVehicle _x} foreach _fences
Delete the fences/roadblocks.

Code: [Select]
~2
{_x enableAI "MOVE"} foreach units _engineers
Wait two second and then engineers can move (can follow their path...).
Fix bayonet!

Offline mathias_eichinger

  • Missions Depot
  • Administrator
  • *****
  • I'm a llama!
Re: Infantry cutting wire fences?
« Reply #24 on: 23 Apr 2008, 16:59:08 »
Hi Rommel and Bardosy!

Both of your methods work, we can consider this problem solved! Thank you very much for your time and effort.

Cheers

Mathias

Offline Captain

  • Members
  • *
Re: Infantry cutting wire fences?
« Reply #25 on: 23 Apr 2008, 23:21:25 »
Rather than having to name the section of fence can the script be modified to just detect fence objects nearby?

 :confused: