Home   Help Search Login Register  

Author Topic: Alive troops check  (Read 2038 times)

0 Members and 1 Guest are viewing this topic.

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Alive troops check
« on: 14 Jul 2010, 00:45:37 »
I make a mission, where you have to hold your line against numerous enemies. And here 2 questions:

1. I can commence retreat, then all units alive from your platoon joins you and are under your command. When each squad join, player should receive SITREP of alive and killed soldiers. How to do this? Notice fact, that all of these troops (nearly) are single (not in teams etc.), and then join player by "joinsilent" command.
I guess I need a label or something like this for each future squad (called A to E) deleting killed members and reporting number of troops in that squad. But how to do this?

2. This is is easy I guess, but I have never used that before: I want to finish mission, when ALL RESISTANCE side will loose 70% of their strength at the very beginning. There was command connected with that, but I am not pretty sure how to make it working.

Can you help me?

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Alive troops check
« Reply #1 on: 14 Jul 2010, 12:31:57 »
1. If you change joinsilent to join you will get a verbal confirmation from each soldier that joins your squad. It's not a Sitrep per se. But serves the same purpose.

2. Look up the count command in the Comref. The trigger should read something like this (ad hoc code):

count units side guer <= X
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Alive troops check
« Reply #2 on: 14 Jul 2010, 23:05:25 »
count units side guer <= X

Error occurs, though count units guer <= X works probably fine. Probably, because for test purpose i tried to check out this command with hint. With "guer" trigger works, but nothing happens if theoretically I killed enough units.
Like:
Cond: count units guer <= 190 (there are 196-198 units from guer on the map)
Activ: hint "works";

Trigger is west activated (west is in the area)/

What is more, when I replace guer with east or west, I get info "type side, needed object". I dont get it.

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Alive troops check
« Reply #3 on: 14 Jul 2010, 23:42:57 »
Sorry if it was confusing. I'm out of testing possibilities right now and my example wasn't meant as a working code snippet. There's a countside command that may solve your problem. Check this.
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Alive troops check
« Reply #4 on: 15 Jul 2010, 09:21:41 »
2: Make a trigger covering the whole playing area, activated by Resistance/Guer. In the Condition field, write:

Code: [Select]
{alive _x} count units thisList < 60
(supplanting 60 with whatever number corresponds to "less than 70% left"). Then just add whatever lose code you want in the On Activation field.

1: It's easy enough to make a sitrep of LIVING soldiers, but a lot harder to make one which differentiates between living and dead :) I.e., how many casualities. That is, unless each group has exactly as many soldiers - which I doubt. Also, this would obviously not be voiced, unless you get really creative with the voice acting.

Just reporting living (called just before the actual join, so that there is still a 'leader' for the group):
Code: [Select]
(leader joinedgrp) sidechat format ["This is %1, joining you now. Our strength is at %2 men.", joinedgrp, {alive _x} count units joinedgrp];
As to reporting casualities, well. What you'd have to do is initially, at the start of the mission, count the number of soldiers in each group. You could either do this with a global array, or by for instance giving each member of the group a vehiclevariable with the information (each member because you never know who's going to die). After that you simply use the above code to count living members, and grab the amount of original members from the array, and hey presto. Here'd be the vehiclevariable one:

(start of mission, in e.g. group leader's init field. Untested):

Code: [Select]
{_x setvariable ["SAST_GroupSize", {alive _x} count units (group _x)]} foreach units group this;
(when joining):

Code: [Select]
(leader joinedgrp) sidechat format ["This is %1, joining you now. Our strength is at %2 men. We have had %3 casualities.", joinedgrp, {alive _x} count units joinedgrp, (((leader joinedgrp) getVariable "SAST_GroupSize") - ({alive _x} count units joinedgrp))];

Of course, this line doesn't make any sense if the group hasn't had any casualities, which means you'd have to make an extra check for that and so on and so on. It gives a nice feeling to the mission, of course, but it is a lot of extra work too :)

Hope these instructions make sense - wish you luck!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Alive troops check
« Reply #5 on: 15 Jul 2010, 19:56:49 »
All saved and it seems I understand most, but there are 2 things:

1. {alive _x} count units thisList < 185 with test "hint "works";"
Game returns arror with such a condition. "Type field, needed Object/Group" [translate from my language, maybe in original version that info looks a bit different].
Trigger set as you said, but error occurs :|

2. This is a little more complicated than it looks with squads that join you. You see, I have platton with 37 people in it, where nearly everyone is a SINGLE group. There is no group one, group two etc.
Troops crouch behind sandbags as long as you will not commence retreat, but they are grouped in fire teams. These fireteams (I repeat again) consist of eg. 4 troops who create 4 SEPARATE groups.

Of course, I can first put all those troops info one group led by NCO, report with casualties and join them into player's platoon.

But what if NCO is dead? In "join" command I have to point unit.
Well, I am not good scripter, but while can't write scripts on my own I can read them. I think, that table counting all units from all squads should do this, but I have no idea how to get it working.

Well, I mean something like:
Code: [Select]
alpha = [a1,a2,a3,a4 etc.];
bravo [b1,b2 etc.];
_alpha_count = counts units alpha;
\\ and then eg.
unit sidechat format ["SITREP etc. - %1",_alpha_count];

If I could get that working, troops could be in separate teams and report anyway?

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Alive troops check
« Reply #6 on: 15 Jul 2010, 20:21:10 »
thisList automatically returns the units >_> D'oh, my bad:

Code: [Select]
{alive _x} count thisList < 185
That should work. Sorry.

As to 2: am I understanding correctly that:

You have 37 units that you've placed around in defensive positions. In addition to that, you have 'imaginary' fireteams, which are the ones that you'd want to "report in" as they join you? So, for instance, fireteam 1 has 3 soldiers left, and you'd like them to say stuff like "This is FT 1, we've had x causalities...3 of us left"? Even though they're not 'really' grouped together according to Arma logic?

Well. Hum. I would suggest doing what you suggested, and just making the 'reporting in' work somehow...not sure how. Anyway:

Code: [Select]
_group1= [a1, a2, a3, a4];
_group2= [b1, b2, b3, b4];

_group1alive = {alive _x} count _group1 - (count _group1);
(_group1 select 0) sidechat "bla bla lba";

I'm assuming however that the 37 units are all separate because that's the only way you've found to make them stay behind their sandbags etc? How about instead making the fireteams real groups, but instead using this code in the init field of each:

Code: [Select]
this disableAI "MOVE"; this disableAI "TARGET";
That will make them not move from their positions. Just make sure they're set to "None" (not "In Formation") and they will behave just like if they were alone - or actually better, since they will share target data etc. Now you can instead name groups, and use leader to determine who does the reporting in (if no-one is alive in the group, there is no leader, and thus no reporting in).

Yep. Complicated stuff, sometimes, but it can be done.  :good:

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Alive troops check
« Reply #7 on: 16 Jul 2010, 21:09:24 »
Works fine now.
About {alive _x} count thisList < 185, I also removed units previously, but later accidentally found that vehicles count as 1 enemy, not as eg. 4x crew and I was wodering why condition does not work fine :P

Groups also work fine as table, but bug occurs your method:
Code: [Select]
_group1alive = {alive _x} count _group1 - (count _group1);
I dont get why you subtract _group1 again, but when I removed:
Code: [Select]
_group1alive = {alive _x} count _group1;
Everything works fine ;D

Anyway, thanks to your hints and examples everything works quite fine now, so thank you very much!

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Alive troops check
« Reply #8 on: 04 Aug 2010, 22:43:02 »
One more question. I am using this script you put me here quite often, and one thing put me into concern:
If there is infantry mounter on APC/other vehicles, do they count into thislist? Because I think the are not. I just want to make sure of this.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Alive troops check
« Reply #9 on: 05 Aug 2010, 03:38:55 »
It counts the vehicle as one unit (it does not count all the units in the vehicle). 

I did this simple test.  Start a new mission in the editor:

Place a Blufor soldier, and a Blufor tank (not empty) on the map.

Place a trigger around them for Blufor Present.

In the On Action field of trigger put this code:

hint format ["unit count=%1", count thislist];

Preview the mission, and the hint says:

unit_count=2

If you want a true unit count you would have to write a script that loops through all units returned by thislist, and checks to see if unit is a a vehicle or not. If vehicle, then you need to count the crew of the vehicle.  Add count for each unit in loop to get a total count.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline SaS TrooP

  • Members
  • *
  • n00b always & everywhere
Re: Alive troops check
« Reply #10 on: 05 Aug 2010, 18:22:15 »
Yea, while making exactly the same I found that. Just needed confirmation if I am right. Thanks a lot.