Home   Help Search Login Register  

Author Topic: Need help with a script that check if a group is dead or fleeing.  (Read 607 times)

0 Members and 1 Guest are viewing this topic.

Offline Crazy_Ivan

  • Members
  • *
Hi I need help with a script that checks if the units in a group is either fleeing or dead.
I have no clue where to start so if someone would point me in the right direction i would be grateful.  
« Last Edit: 15 Oct 2003, 16:52:43 by Crazy_Ivan »
Teamwork is essential; it gives the enemy other people to shoot at.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
#loop
~8
? (not alive loon1) or (fleeing loon1):goto "consequence"
goto "loop"

#consequence
whatever

exit


Syntax not guaranteed .... but its a start.
Plenty of reviewed ArmA missions for you to play

Offline Crazy_Ivan

  • Members
  • *
Thanks for the help. I'll try to modify it so it can be used on a whole group.    
Teamwork is essential; it gives the enemy other people to shoot at.

Offline Crazy_Ivan

  • Members
  • *
tried to modify it but i can get it to work on a whole group

here is the script I'm working on.

;variabels used _u array of units in group, _j nuber of units in group, _i specific unit in group, _dof number of
;units dead ot fleeing  

_grp = loon

; ***************************************
;put units in array
 
 _u = units _grp
 _j = count _u
 _i = 0
 _dof = 0
;checks units status in array
#loop
~2
 ? not alive (_u select _i) or fleeing (_u select _i):goto "count"
 _i=_i+1
goto "loop"

;counting
#count
 _dof = _dof+1
 ?_j=_dof:goto "consequence"

 goto "loop"

#consequence
;debug
 player SideChat "works"


exit

When running this script iget get the error message "? not alive (_u select _i) or fleeing (_u select _i):Error Zero Divisor"
« Last Edit: 15 Oct 2003, 17:58:00 by Crazy_Ivan »
Teamwork is essential; it gives the enemy other people to shoot at.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Just for the avoidance of doubt .... you want the consequence to occur when the whole group is fleeing, right?

Because if that's true, there's probably an easier way to do it.     You can ignore dead members of the group because they are, erm, dead, so try something like

? "fleeing _x2" count units grp1 == counts units grp1: goto "consequence"

Have a go on the forum search function too - this has come up before though I can't remember the answer.

I haven't really looked at your script because I'm not really a scripter, but I think if a line starts with
?
you've got to have
:
later on in the line, followed by whatever you want to happen if the condition is true.
Plenty of reviewed ArmA missions for you to play

Offline Crazy_Ivan

  • Members
  • *
I think i got it to work now thanks for your help :)


_u = units loon
_j = count _u
#loop

?"!alive _x" count _u == _j:goto "dead"
_j = count _u
?"fleeing _x" count _u == _j:goto "flee"
~0.5
goto "loop"
#dead
player sidechat "dead"
exit
#flee
player sidechat "flee"
exit
Teamwork is essential; it gives the enemy other people to shoot at.

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Script? Why not just use a trigger?

Trigger

Radius: 0,0
Condition: none
Condition Field: east countside units group <= "fleeing _x" count units group
OnActivation Field: as required

Be sure to change the east to the side your group is on. I assume east as the Soviets seem to always get painted with the bad guy brush in this game ;D

Just another alternative I thought I'd throw in if you're interested ;)