OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: GW on 07 May 2010, 08:30:37

Title: Script to know about number of enemy.
Post by: GW on 07 May 2010, 08:30:37
I always get stuck in missions,so iam intresting in know about a script for get info about west or east units which still alive.
Title: Re: Script to know about number of enemy.
Post by: RKurtzDmitriyev on 07 May 2010, 14:16:41
This should be moved to editing and scripting -- general. This board is for people to submit scripts for download at OFPEC.

Anyway, the way I would do this would be to place a trigger with conditions of "EAST--PRESENT" (assuming that east is the enemy, otherwise use west or resistance). The trigger radius must cover all possible enemy units. Give the trigger a name (like "alleast"). Now execute the following code to give you a hint about how many enemies are left:

Code: [Select]
hint format ["There are %1 enemies left",count (list alleast)]

Where alleast is the name you gave to your trigger.

Look up the commands in the COMREF to see what they do.

Does it work for you? :cool2:
Title: Re: Script to know about number of enemy.
Post by: h- on 07 May 2010, 14:26:14
Moved to the correct board, carry on.. :)
Title: Re: Script to know about number of enemy.
Post by: GW on 08 May 2010, 10:27:13
Script work once .I want to use it as a radio again and again,
Title: Re: Script to know about number of enemy.
Post by: bedges on 08 May 2010, 12:10:36
Check the attached missionette.
Title: Re: Script to know about number of enemy.
Post by: GW on 09 May 2010, 11:48:09
Getting number is not worth as i learn.I want to use it to know about how much member of enemy squad are alive.like squad A  member how much alive and squad B member how much.
Title: Re: Script to know about number of enemy.
Post by: bedges on 09 May 2010, 12:06:36
From your first post:

Quote
... iam intresting in know about a script for get info about west or east units which still alive.

That's what you got. From your second post:

Quote
... I want to use it as a radio again and again

That's what you got.

If you don't explain your problem clearly and fully, you cannot expect to get the help you need. Also, some "please" and "thankyou" wouldn't go amiss.  :dry:
Title: Re: Script to know about number of enemy.
Post by: RKurtzDmitriyev on 09 May 2010, 13:29:34
Quote
If you don't explain your problem clearly and fully, you cannot expect to get the help you need. Also, some "please" and "thankyou" wouldn't go amiss.  :dry:

I second this.

Anyway, assuming that I understand your question correctly, what you want is the count command combined with "alive _x" .

Code: [Select]
"alive _x" count (units someGroup)
will return (that is, result in) the number of alive soldiers in a group called someGroup. Use the format command again, just like before, to put the results of this calculation into a hint or other text command.
Title: Re: Script to know about number of enemy.
Post by: GW on 09 May 2010, 19:52:52
First i tried all enemy alive script,but it did't work well.as in missions enemy always in groups,so information about how much in a group is very useful.
Can anyone help please.
Title: Re: Script to know about number of enemy.
Post by: bedges on 09 May 2010, 19:57:54
As RKurtzDmitriyev has already said:

Code: [Select]
"alive _x" count (units someGroup)
will return (that is, result in) the number of alive soldiers in a group called someGroup. Use the format command (http://www.ofpec.com/COMREF/index.php?action=details&id=141&game=OFP) again, just like before, to put the results of this calculation into a hint or other text command.
Title: Re: Script to know about number of enemy.
Post by: GW on 11 May 2010, 03:21:53
a demo mission will be very useful with 3 to 4 enemy squad,help
Title: Re: Script to know about number of enemy.
Post by: bedges on 11 May 2010, 08:46:51
The answers are already here.

You have a demo mission in which a radio action can be triggered repeatedly to report how many East units are still alive on the map.
You have the code to determine how many units in a group (of any side) are still alive.

Code: [Select]
{alive _x} count (units groupName)
Open the demo mission. Add some named groups. Look at the On Activation field of the radio trigger. Modify the code in the trigger using the code above.

In the beginning, everyone must put forth effort in order to learn editing. Don't expect the answers to be simply handed to you.
Title: Re: Script to know about number of enemy.
Post by: RKurtzDmitriyev on 11 May 2010, 14:37:03
Riffleman, it sounds like you could benefit greatly from learning basic OFP scripting. It isn't too difficult. This tutorial is how I got started:

http://www.ofpec.com/ed_depot/index.php?action=details&id=42&game=OFP

The scripting exercises probably will make no sense at first. Type in the example scripts by hand, and tinker with them to find out how they work. There's no magic or supernatural powers required to write scripts in OFP's little scripting language. Also, the COMREFs (dictionaries of commands) at OFPEC and the Bohemia Interactive wiki are indispensable.

You could easily answer for yourself most of your questions in this thread if you just had some more experience with scripting. From looking at your Patrolling Party mission, I see you've already gotten off to a good start. So give it a try. :clap: