Jump to content
Blitzen88

How to apply multiple conditions to WaitUntil...?

Recommended Posts

Greetings everyone,

 

 Im trying to modify Jebus' pilot kill function to include more scenarios.  Here is what I have:

 

_SubjectVehicle = vehicle (_this select 0);

_Vehiclecrew = crew _SubjectVehicle;

WaitUntil {!canMove _SubjectVehicle} OR {{_x in _SubjectVehicle} Count (_Vehiclecrew) == 0} OR {!canFire _SubjectVehicle};

{DeleteVehicle _x} foreach _Vehiclecrew;

_SubjectVehicle setdamage 1;

 

Im trying to tweak this so that a vehicle and its crew are destroyed when the following conditions are met:

 

  1. The vehicle can no longer move
  2. The crew is no longer in the vehicle
  3. The vehicle can no longer fire/shoot its gun
  4. The vehicle crew has been killed (not listed)

 

I can get one these conditions to work but I cant seem to make all of the conditions work...?  Also, does a sleep command need to be added to save performance?

 

Thank you

Share this post


Link to post
Share on other sites

@Blitzen88,

waitUntil {
    sleep 1;

    !(canMove _SubjectVehicle) and {({alive _x} count (crew _SubjectVehicle)) == 0} and {!(canFire _SubjectVehicle)}
};

 

22 minutes ago, Blitzen88 said:

Also, does a sleep command need to be added to save performance?

Yes, it makes sense.

Share this post


Link to post
Share on other sites
1 minute ago, Schatten said:

@Blitzen88,


waitUntil {
    sleep 1;

    !(canMove _SubjectVehicle) and {({alive _x} count (crew _SubjectVehicle)) == 0} and {!(canFire _SubjectVehicle)}
};

 

Yes, it makes sense.

Thank you for the quick response but I think didnt explain clearly - which is my fault.  I want the vehicle to be destroyed when any one of the those conditions are met.  Can I just change the "and's" to "or's"...?

 

Thank you!

Share this post


Link to post
Share on other sites
3 minutes ago, Blitzen88 said:

Can I just change the "and's" to "or's"...?

this

Share this post


Link to post
Share on other sites
13 minutes ago, Blitzen88 said:

Can I just change the "and's" to "or's"...?

Sure.

Share this post


Link to post
Share on other sites
7 hours ago, Schatten said:

Sure.

 

I just tested it with "Ors" and it didnt seem to work.  I dont know what I'm doing wrong

 

WaitUntil {

   Sleep 1;

    !(canMove _SubjectVehicle) or {({alive _x} count (crew _SubjectVehicle)) == 0} or {!(canFire _SubjectVehicle)} or {({_x in _SubjectVehicle} Count (crew _SubjectVehicle)) == 0}

};

EDIT

I dont know what I did but it seems to be working now

 

Thank you for your help!

Share this post


Link to post
Share on other sites

Well, just a quick one (please correct me if I am wrong).

At the initial post your structure was faulty. You wrote (I have edited to make it more clear):

waitUntil {
	!canMove _SubjectVehicle
} OR {
	{_x in _SubjectVehicle} Count (_Vehiclecrew) == 0
} OR {
	!canFire _SubjectVehicle
};

To my knowledge (which is definitely not great) waitUntil is not structured like an if-else. So the way you have it coded, only the first condition would be checked by waitUntil (not sure this wouldn't end up as an error due to a missing ';' after waitUntil). So, what you should had done is what Schatten suggested (also, correctly structured). Reproducing with the same kind of format I used in the above code to make the difference more distinct.

waitUntil {
   Sleep 1;
   !(canMove _SubjectVehicle) or {
		({alive _x} count (crew _SubjectVehicle)) == 0
	} or {
		!(canFire _SubjectVehicle)
	} or {
		({_x in _SubjectVehicle} Count (crew _SubjectVehicle)) == 0
	}
};

Hope I didn't confuse you :scratchchin:.

  • Like 1

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

×