OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Serial Killer on 28 Oct 2005, 00:33:46
-
How can I check casualties on the team by a script or trigger, and how can I show it to the player when trigger activates?
Also, how do I show player how many enemies are left in a certain area?
-
At the start of the mission:
GrpSize = {alive _x} count units Grpname
Later:
Casualties = GrpSize - {alive _x} count units Grpname
Show the player:
hint format ["casualties = %1",Casualties]
Enemies in an area.
Trigger condition west (or East) depending on who is the enemy. Give the trigger an name.
Run a script that contains:
hint format ["Enemies in the area = %1",count list triggername]
Not tested but you get the idea?
-
one of the easier questions ;)
well, two actually. i shall answer the second first. make a trigger, covering the whole map, activated by east, 'on activation' =
all_east = thislist
then place markers at the centres of the areas you wish to check. then, in a script, use something like this
in_area = {(_x distance getmarkerpos "marker_name") <=200} count all_east
that will give a total of the number of east loons within 200 metres of the marker given.
the first question, reporting on the status of a squad, is a simple matter of combining getdammage (http://www.ofpec.com/editors/comref.php?letter=G#getDammage) and canstand (http://www.ofpec.com/editors/comref.php?letter=C#canStand). those two commands will give the general health of the unit. if you also wish to check the unit's ammo status, use magazines (http://www.ofpec.com/editors/comref.php?letter=M#magazines).
then you just need to loop it through the number of units in the squad, wrap that up in a hint and ping it back at the player.
simple ;)
-
the first question, reporting on the status of a squad, is a simple matter of combining getdammage (http://www.ofpec.com/editors/comref.php?letter=G#getDammage) and canstand (http://www.ofpec.com/editors/comref.php?letter=C#canStand). those two commands will give the general health of the unit. if you also wish to check the unit's ammo status, use magazines (http://www.ofpec.com/editors/comref.php?letter=M#magazines).
then you just need to loop it through the number of units in the squad, wrap that up in a hint and ping it back at the player.
simple ;)
Not for me. :-\ Could you write an example script for me, please?
-
Excuse me, but is my post invisible?
-
m'kay...
*bedges cracks his knuckles and warms his typing fingers*
call the script using [group_name] exec "status_check.sqs"
copy/paste the following and save it as "status_check.sqs"
;report on status of given group
_squad = _this select 0
_units = units _squad
_howmany = count _units
_i = 0
_perc = "%"
#loop
_dam = getdammage (_units select _i)
_dam = _dam * 100
?canstand (_units select _i) : _also = "and can stand."
?not (canstand (_units select _i) ): _also = "and cannot stand."
hint format ["Unit %1 (%2) is %3%4 wounded, %5",_i,name (_units select _i), _dam,_perc,_also]
~2
_i = _i + 1
?not (_i==_howmany):goto "loop"
exit
alright? get the idea? see if you can add magazines to that... ;)
-
Yes TH, it seems all your posts are invisible....hmmm......what am I talking about, what posts. :-\
Planck
-
I feel like I am talking to myself. I wouldn't mind but I only had a few minutes in my hotel this morning between getting up and going to my meetings - I will spend my time differently in future.
-
nownow... if someone chooses to sidestep your excellent advice, that's their loss. noobies around here may very well not recognise your skills, but those of us in the know hold you in appropriately high esteem, have no fear.
i think the fact that you're on the staff speaks for itself, mmm? 8)
*bedges cracks himself on the back of the head*
now keep it on topic!
-
Thanks bedges. Now I got the idea, and I also learned a few new things. :P
@THobson
Sorry. I DID use your advice first, but bedges' advice seemed to be more... advanced...