Jump to content
Sign in to follow this  
logan83

Big Strange Condition...

Recommended Posts

Hi every body... im a newbie in the scripts world and i Need some help with a Structure...

if ((obj0ok and obj1ok and obj2ok and obj3ok) || (obj0ok and obj1ok and obj2ok and obj5ok) || (obj0ok and obj1ok and obj2ok and objxtraok) || (obj0ok and obj1ok and obj4ok and obj3ok) || (obj0ok and obj1ok and obj4ok and obj5ok) || (obj0ok and obj1ok and obj4ok and objxtraok)) then
		{

			sleep 1;
			FINALREGULAR=true;

		}

Whats Wrong? any suggestion to do this type of conditions groups more simply? Thanks a lot

this is the entire script... its a Endings Checker... depending what conditions you active...you have a diferent ending...

  	if (obj0ok and obj1ok and obj2ok and obj3ok and obj4ok and obj5ok and objxtraok) then
{
	sleep 1;
	FINALMUYBUENO=true;

}else{

	if  ((obj0ok and obj1ok and obj3ok and obj4ok and obj5ok and objxtraok) || (obj0ok and obj1ok and obj3ok and obj5ok and objxtraok and obj2ok)) then
	{

		sleep 1;
		FUNALBUENO=true;

	}else{

		if ((obj0ok and obj1ok and obj2ok and obj3ok) || (obj0ok and obj1ok and obj2ok and obj5ok) || (obj0ok and obj1ok and obj2ok and objxtraok) || (obj0ok and obj1ok and obj4ok and obj3ok) || (obj0ok and obj1ok and obj4ok and obj5ok) || (obj0ok and obj1ok and obj4ok and objxtraok)) then
		{

			sleep 1;
			FINALREGULAR=true;

		}else{

			if  ((obj0ok and obj1ok and obj3ok) || (obj0ok and obj1ok and obj5ok) || (obj0ok and obj1ok and objxtraok)) then
			{

				sleep 1;
				FINALMALO=true;

			}else{

				if (obj0ok and obj1ok) then
				{

					Sleep 1;
					FINALMUYMALO=true

				}
				}
			}
		}
   	};

exit

Share this post


Link to post
Share on other sites

Maybe if you said what those variables represent or how they are being defined, it would be easier to suggest a cleaner way of doing it. I am guessing that 'obj#ok' means that an object is alive. If so, you could use a simple script to count the number of living objects from an array. Or are the variables defined by some other condition? You could try something like this:

switch ({_x} count [obj0ok, obj1ok, obj2ok, obj3ok, obj4ok, obj5ok, objxtraok]) do {
   case 2: {
       FINALMUYMALO=true;
   };
   case 3: {
       FINALMALO=true;
   };
   case 4: {
       FINALREGULAR=true;
   };
   case 5: {
       FUNALBUENO=true;
   };
   case 6: {
       FINALMUYBUENO=true;
   };
};

This code will determine how many of the booleans in the array are true and act accordingly. If this is not want you want, try implementing lazy evaluation, as described on this page:

http://community.bistudio.com/wiki/a_%26%26_b

Share this post


Link to post
Share on other sites

Hi mate, lets to see...

the obj#ok are multiple types of Targets accomplished (like go to that position, kill this officer, destroy that vehicle...) and i want to make a script that depending of the type of objetive accomplished, the script run a type of end... some like:

run the FINALMALO only if one of this variables groups are True "obj0ok and obj1ok and obj3ok" or "obj0ok and obj1ok and obj5ok" or "obj0ok and obj1ok and objxtraok"...

And run FINALBUENO only if one of this variable groups are true "obj0ok and obj1ok and obj3ok and obj4ok and obj5ok and objxtraok" or "obj0ok and obj1ok and obj3ok and obj5ok and objxtraok and obj2ok"

the idea its run the end, by type of obj#ok, not by quantity... i tryi t to my way... but it seems to be something wrong in the group of variables...

i can Run FINALMUYBUENO... but no the others...

excuse my English please

Share this post


Link to post
Share on other sites

You may try to acommulate a score when such a Target is accomplished and then rate depending on score ("FINALMUYMALO" if score < 1, "FINALMALO" if score < 2, etc...)

Share this post


Link to post
Share on other sites

I will try you form gammadust but anyway, can tell me whats wrong with this? in a onact field of a trigger does not work

((obj0ok and obj1ok and obj3ok) || (obj0ok and obj1ok and obj5ok) || (obj0ok and obj1ok and objxtraok))

Share this post


Link to post
Share on other sites

Maybe try:

(obj0ok && obj1ok) && (obj3ok || obj5ok || objxtraok)

Also, that would be in the Condition of a trigger, not the onAct.

Share this post


Link to post
Share on other sites

the syntax looks good to me... but it is hard to tell if that will get the results you need.

i don't use much triggers but i would expect "onact" to be were you execute something... and condition where you test for boolean.

@kylania

also suspected that the mix could confuse the interpreter... but just tested it and it works no prob.

Share this post


Link to post
Share on other sites
the syntax looks good to me... but it is hard to tell if that will get the results you need.

i don't use much triggers but i would expect "onact" to be were you execute something... and condition where you test for boolean.

@kylania

also suspected that the mix could confuse the interpreter... but just tested it and it works no prob.

xD im sorry, i refer to the Condition field o course.... :)

---------- Post added at 01:33 ---------- Previous post was at 01:31 ----------

Maybe try:

(obj0ok && obj1ok) && (obj3ok || obj5ok || objxtraok)

Also, that would be in the Condition of a trigger, not the onAct.

Taaaadaaaaaaaa!!! And Works perfectly... thanks mate... :)

Share this post


Link to post
Share on other sites
_score = 0;
if(obj0ok && obj1ok) then {
_score = _score + 1;
if(objxtraok) then {_score = _score + 1);
if(obj3ok) then {_score = _score + 2);
if(obj5ok) then {_score = _score + 4);
if(obj2ok) then {_score = _score + 8);
if(obj4ok) then {_score = _score + 8);
};

if(_score == 1) then {FINALMUYMALO = true;};
if(_score in [2,3,5]) then {FINALMALO = true;};
if(_score in [10,11,13]) then {FINALREGULAR = true;};
if(_score == 16) then {FUNALBUENO = true;};
if(_score == 24) then {FINALMUYBUENO = true;};
sleep 1;

//0&1 = 1

//0&1&3 = 3
//0&1&5 = 5
//0&1&x = 2

//0&1&3 2|4 = 11
//0&1&5 2|4 = 13
//0&1&x 2|4 = 10

//0&1&3&5&x 2|4 = 16

//0&1&2&3&4&5&x = 24

Think that works out right as a scoring system.

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  

×