Home   Help Search Login Register  

Author Topic: How to make a script count units?  (Read 1640 times)

0 Members and 1 Guest are viewing this topic.

Offline Rytuklis

  • Members
  • *
How to make a script count units?
« on: 15 Apr 2013, 17:28:21 »
What is the easiest way to do the following?

I got two endings - one is when a squad manages to retreat with majority of its units still alive, and another one when it is nearly wiped out and only few members of the side have survived. These endings are determined by the count of alive resistance units during the debriefing. How do i do that? thank you

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: How to make a script count units?
« Reply #1 on: 15 Apr 2013, 17:55:02 »
There are quite a few ways to do it.

What I would do (there may be an easier way to do it), is something like this:

Code: [Select]
;start of script, run near end of mission
;apgrp is the name of the player's group
;let's say there are 8 loons in the players group

{alive _x} count units apgrp == 8: goto "End1"
{alive _x} count units apgrp == 7: goto "End2"
{alive _x} count units apgrp == 6: goto "End3"

...and so on

#End1
<insert commands here>
end1=true
exit

'End1', 'End2' and 'End3' are all sections placed within a script. You can put whatever you want in each section. You can have a camera sequence for example, which ends with the corresponding 'end#', which is followed by the debriefing screen.

There are loads of different ways to do what you ask, but that's probably what I would do  :) You can do all of this with triggers as well, if you don't want to use scripts.

It's been awhile since I last touched the editor, so syntax is not guaranteed.

Hope this helps
Gruntage
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Rytuklis

  • Members
  • *
Re: How to make a script count units?
« Reply #2 on: 17 Apr 2013, 16:49:43 »
How do i define/name a group?

Offline Gruntage

  • Missions Depot
  • Administrator
  • *****
  • How do I get outta this chickensh*t outfit?
Re: How to make a script count units?
« Reply #3 on: 17 Apr 2013, 17:21:17 »
Code: [Select]
nameofgroup = group this
Put that in the init field of the group leader. Replace 'nameofgroup' with whatever name you want.
"But one thing I can tell you from not just OFP but life in general:  criticism is directly proportional to quality. The more criticism a mission receives, the better the outcome" - macguba

Offline Rytuklis

  • Members
  • *
Re: How to make a script count units?
« Reply #4 on: 21 Apr 2013, 16:35:45 »
Thanks. Was very busy lately, will try it out some time soon and report back if any problems occur.