Jump to content
Sign in to follow this  
Nasder9

player state check with First-Aid Modules in use.

Recommended Posts

Here's what I am trying to do...

I'm using the First Aid module(s), so death is seldom instant.

I want to use a trigger to activate once the player is down, not dead. The trigger runs a script to check how many teammates are alive. If you're alone the script will activate a trigger that ends the mission as lost.

Based on experience I can lose my entire group and get hit, then I lay there for quite some time before I die, unless I end the mission using the menu. I want to remove this by checking the numbers of units in my group. If I am alone, I got no friendlies to save me so death is inevitable, I want the mission to end by itself after a set period of time.

I got a few issues though.

I can't seem to figure out how to make the trigger activate when I'm down. I thought that the "CanStand" check would work, but this triggered once I actually died, or got damage to my legs it seems. So this doesn't work (even though you can only crawl when wounded enough for the first aid module to kick in fully). I can't figure out how to check this and therefor can not activate the trigger as I want.

An other issue is the "Foreach" command. It counts the known group members. So you can have dead group members and use the command, it will then include the dead group members which are not yet known as dead. Even though I am sure I am the only one alive, tried with triggers to kill my entire team except me while I was far away, then activated a test script to count my group members. I still got all counted, until my player did an automatic status check and figured out everyone was dead.

Any help in this is appriciated by me, and probably a few others out there aswell.

Share this post


Link to post
Share on other sites

I solved this problem using trial and error. Hooray!

Trigger activated by

LifeState Player == "UNCONSCIOUS"

And is executed with the line, pLgrp1 is the group name of Player group.

_xyz = [pLgrp1] execVM "CountGroup.sqf"

And then I use this code to check number of group members and check them against the numbers unconscious in the group to make sure that there is someone still able to give you first aid.

This code is not the best I think, I'm switching from sqs, and this if the first script I do in sqf, but it does the trick at least. But could probably be cleaner and more optimized. (the forum layout creates a new line for long comments)

CountGroup.sqf

_grp1 = _this select 0;
_nmbr = 0;
_hnmbr = 0;

// Counts the group members
{
 _nmbr = _nmbr + 1;

} forEach units _grp1;

// Checks if you're alone in the group.
if (_nmbr == 1)
then {
 // States that you're alone and activates the trigger "Triggertest"
 hint "You are all alone";
 Triggertest = true;
 }
Else {
 {
 // Checks the lifestate of each groupmember, Alive, Unconscious or Dead.
 _state = LifeState _x;
 // if Unconscious, add 1 to hurt-pile per unit unconscious.
 If (_state == "UNCONSCIOUS")
      Then {
       _hnmbr = _hnmbr +1;
      	}
      } forEach units _grp1;
 // Checks if the number hurt in the group are larger or equal to the number of group members.
 If ( _hnmbr >= _nmbr)	 
  Then {
	// Tells you that there is no one in a state to heal you.
	triggerTest = true;
	hint "No one can save you..."
	}
	Else {
		// If False, states that you're not alone. and hints you how many group members you have and how many of them are wounded
		hint format ["You are not alone, you got %1 group members, and %2 are badly wounded", _nmbr, _hnmbr]
		}
 }
exit

How can this script be optimized, if possible? Can this check be done in a better way?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×