OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Rytuklis on 15 Apr 2013, 17:28:21

Title: How to make a script count units?
Post by: Rytuklis 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
Title: Re: How to make a script count units?
Post by: Gruntage 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
Title: Re: How to make a script count units?
Post by: Rytuklis on 17 Apr 2013, 16:49:43
How do i define/name a group?
Title: Re: How to make a script count units?
Post by: Gruntage 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.
Title: Re: How to make a script count units?
Post by: Rytuklis 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.