Home   Help Search Login Register  

Author Topic: Situation Report (SITREP) script  (Read 1434 times)

0 Members and 1 Guest are viewing this topic.

Offline Krieg

  • Mission Maker
  • Members
  • *
  • Who dares wins.
Situation Report (SITREP) script
« on: 06 Jan 2010, 11:49:14 »
I am in process of making SITREP script, and I had found a technique that works.
My only problem is that there are a lot of SITREP cases 4 tanks/units can be. So I was about to make 3 possible cases tank can be in. Minor damage (i.e. damage from 0.1 to 0.5), major damage (from 0.5 to 0.9) and destroyed (1). For one tank, this would be easy. But for 4 tanks, well, there are too many cases. I am looking for simpler technique then one shown below.
Code: [Select]
_damage1 = getDammage b
_damage2 = getDammage c
_damage3 = getDammage d
_damage4 = getDammage e

?(_damage1 == 0 && _damage2 == 0 && _damage3 == 0 && _damage4 == 0) : goto "1st"
?(_damage1 > 0 && _damage1 <= 0.5 && _damage2 == 0 && _damage3 == 0 && _damage4 == 0) : goto "2nd"
?(_damage1 > 0.5 && _damage1 <= 0.9 && _damage 2 == 0 && _damage 3 == 0 && _damage4 == 0) : goto "3rd"
?(_damage1 == 1 && _damage2 == 0 && _damage3 == 0 && _damage4 == 0) : goto "4th"

#1st
~1
player sideChat "Red Wolf! Status report!"
~3
leader redwolf sideChat "All 4 tanks are alright. No battle damage at all"

#2nd
~1
player sideChat "Red Wolf! Report status!"
~3
leader redwolf sideChat "All 4 tanks alive. Red Wolf 1 has suffered some damage."

#3rd
~1
player sideChat "Red Wolf! Send SITREP!"
~3
leader redwolf sideChat "Red Wolf 1 has suffered major damage. Rest of the tanks are OK."

#4th
~1
player sideChat "We need SITREP, Red Wolf!"
~3
leader redwolf sideChat "Red Wolf 1 is down. Rest of the tanks are fine.

That technique works. But it takes a lot of time to write the entire script.
So my question is, is there a simpler way to write SITREP script?

Thank you,
Krieg
If you see a light at the end of the tunnel, then it's probably an enemy tank.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Re: Situation Report (SITREP) script
« Reply #1 on: 08 Jan 2010, 00:44:21 »
Wow, Krieg, I strongly suspect there's a better way to do this, but I'm pretty stumped for right now.

If it's any help, in a different thread, dr. seltsam showed me a way to create an array containing only alive units from another array.

Code: [Select]
_u_ar=[p1,p2,p3,p4,p5,p6]
_a_ar=[]
{if (alive _x) then {_a_ar=_a_ar+[_x]}} foreach _u_ar
if (count _a_ar == 0) then {hint "Error"; exit}

You could fill _u_ar with the names of the red wolf units, and change the conditional to something like

Code: [Select]
{if (getdammage _x > 0 && getdammage _x <=0.5) then {_a_ar=_a_ar+[_x]}} foreach _u_ar
Create more arrays for undamaged units, heavily damaged units, and dead units. Now you would have the red wolf units sorted according to their status. Then, you might find some way to use the format command to put this information into sideChat or sideRadio. Unfortunately, I tried to figure out how you'd do that and was stumped. >:(

EDIT: If you sort them into arrays as above, you can definitely generate a sitrep as follows:

Code: [Select]
sideChat format ["This is Red Wolf leader here, we have %1 tanks undamaged, %2 tanks slightly damaged, %3 tanks severely damaged, and %4 tanks destroyed. Out.", count _nodamagearray, count _minordamagearray, count _majordamagearray, count _destroyedarray]
It's definitely more elegant programming. On the other hand, it won't tell you exactly which units went down (if that's important), and it won't account for English verb agreement (it may say "we have 1 tanks undamaged"). So if you don't mind Red Wolf sounding like a computer, use the above. :P

EDIT 2: Or even better, I believe the sideChat solution will actually work with simply the following, skipping the "array sorting" step, where redwolf is the name of the Red Wolf group:

Code: [Select]
sideChat format ["This is Red Wolf leader here, we have %1 tanks undamaged, %2 tanks slightly damaged, %3 tanks severely damaged, and %4 tanks destroyed. Out.", "getdammage _x == 0" count units redwolf, "getdammage _x > 0 && getdammage _x <= 0.5" count units redwolf, "getdammage _x > 0.5 && getdammage _x <= 0.9" count units redwolf, "getdammage _x > 0.9" count units redwolf]
« Last Edit: 08 Jan 2010, 01:19:36 by RKurtzDmitriyev »
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline Krieg

  • Mission Maker
  • Members
  • *
  • Who dares wins.
Re: Situation Report (SITREP) script
« Reply #2 on: 08 Jan 2010, 10:21:19 »
Thanks for reply, RKurtzDimitriyev!
So, if I got it correct, script would look something like this:
Code: [Select]
_u_ar=[b,c,d,e]
_nope_ar=[]
_minor_ar=[]
_major_ar=[]
_destroy_ar=[]
{if (getdammage _x ==0) then {_nope_ar=_nope_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0 && getdammage _x <=0.5) then {_minor_ar=_minor_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0.5 && getdammage _x <=0.9) then {_major_ar=_major_ar+[_x]}} foreach _u_ar
{if (getdammage _x ==1) then {_destroy_ar=_major_ar+[_x]}} foreach _u_ar
if (count _a_ar == 0) then {hint "Error"; exit}
leader redwolf sideChat format ["This is Red Wolf, we have %1 tanks undamaged, %2 tanks slightly damaged, %3 tanks severely damaged, and %4 tanks destroyed. Out.", count _nope_ar, count _minor_ar, count _major_ar, count _destroy_ar]

Edit, from what I can see script works perfectly!
Here it is (minor modifications made):
Code: [Select]
closeDialog 1
_u_ar=[b,c,d,e]
_nope_ar=[]
_minor_ar=[]
_major_ar=[]
_destroy_ar=[]
{if (getdammage _x ==0) then {_nope_ar=_nope_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0 && getdammage _x <=0.5) then {_minor_ar=_minor_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0.5 && getdammage _x <=0.9) then {_major_ar=_major_ar+[_x]}} foreach _u_ar
{if (getdammage _x ==1) then {_destroy_ar=_major_ar+[_x]}} foreach _u_ar
if (count _a_ar == 0) then {hint "Error"; exit}
?alive leader redwolf : leader redwolf sideChat format ["This is Red Wolf, we have %1 undamaged tanks, %2 slightly damaged tanks, %3 severely damaged tanks, and %4 tanks destroyed. Out.", count _nope_ar, count _minor_ar, count _major_ar, count _destroy_ar]

Lots of thanks, RKurtzDimitriyev. :good:
« Last Edit: 08 Jan 2010, 10:55:16 by Krieg »
If you see a light at the end of the tunnel, then it's probably an enemy tank.

Offline Semedar

  • Members
  • *
    • Semedars Official Website
Re: Situation Report (SITREP) script
« Reply #3 on: 13 Mar 2010, 05:13:16 »
I've made it to a script format and added a tutorial on how to implement this script as I was trying to find out how to use it for about an hour.. :whistle: Haha

SITREP.sqs

Code: [Select]
;
****************************************************************
; SITREP Script file for Operation Flashpoint
; Created by: RKurtzDmitriyev / Krieg
; Change "Redwolf" to any squad leaders name
; Change Joe, Jon, Jen, Bob to vehicles names
; On Trigger Acc: [] exec "SITREP.sqs"
; Call script from Radio Alpha/Bravo/Ect..
; ****************************************************************

closeDialog 1
_u_ar=[Joe,Jon,Jen,Bob]
_nope_ar=[]
_minor_ar=[]
_major_ar=[]
_destroy_ar=[]
{if (getdammage _x ==0) then {_nope_ar=_nope_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0 && getdammage _x <=0.5) then {_minor_ar=_minor_ar+[_x]}} foreach _u_ar
{if (getdammage _x > 0.5 && getdammage _x <=0.9) then {_major_ar=_major_ar+[_x]}} foreach _u_ar
{if (getdammage _x ==1) then {_destroy_ar=_major_ar+[_x]}} foreach _u_ar
if (count _a_ar == 0) then {hint "Error"; exit}
?alive leader Redwolf : leader Redwolf sideChat format ["This is Red Wolf, we have %1 undamaged tanks, %2 slightly damaged tanks, %3 severely damaged tanks, and %4 tanks destroyed. Out.", count _nope_ar, count _minor_ar, count _major_ar, count _destroy_ar]