OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Wolf on 05 Jul 2003, 06:29:32
-
Hey guys, me again.
I was wondering, is it possible, to detect how many units on each side was killed, and determine who won?
Ex.
Your playing as a West soldier and the mission ends with 26 East killed, and 32 West killed.
Now, since East had fewer casualties your debriefing would be a loss. But if it were reveresed, the debriefing would say you won.
Is it possible at all to do this?
I'm trying to make a mission using an excellent createunit script and the player will be thrown into the fray to do what he can, so if you manage to make a big enough difference, you get a mission accomplished.
Got another question also, is it at all possible to respawn the Player somewhere in an SP mission, or is that only possible in MP.
Thanks.
-
Rather than counting dead bodies of one side, i collect the ratings of the various units in a eastpool and westpool. (After 'reading' somebody's rating set it to 0, of course)
These pools can give you an idea how many enemies units one side has killed. A big advantage is that it doesn't matter exactly what was killed (soldiers, tanks etc).
However, a pool sum can get very high pretty fast - how big can a normal integer variable go in OpF ?
Here is an example code i used to test ratings. To get it to work, save this code as 'init.sqs', make a group grp1 and have other enemy groups (maybe without ammo) going to them with waypoints. A message will tell you how much rating grp1 has collected every second.
Note: grp1 will always have 0 rating, as the sum is collected in _ratings.
_grp = grp1
_ratings = 0
#big_loop
_grparray = units grp1
_grpsize = count units grp1
_xc = 0
#loop
_guy = _grparray select _xc
? (rating _guy > 0): _ratings = _ratings + (rating _guy);
? (rating _guy > 0): _guy addRating (- (rating _guy));
_xc = _xc + 1
?(_xc == _grpsize): goto "exit_loop"
goto "loop"
#exit_loop
hint format ["Group Rating: %1",_ratings]
~1
goto "big_loop"
-
...is it at all possible to respawn the Player somewhere in an SP mission...
Hey wolfy!
nope! :-\ :) sorry, you'd have to loop a "player SetDammage 0" command, I'm afraid.