Home   Help Search Login Register  

Author Topic: Infantry cutting wire fences?  (Read 4145 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