OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: ONoSixIsDown on 19 Nov 2005, 14:52:41
-
im haveing trouble with a script that sets an objective to done when three different groups, named grp1,grp2, and grp3, are down to three men or less.
in each groups leader's initi. field i havethis to not only assign the whole squad a name but also keeping them from fleeing
"_x allowfleeing 0" foreach units group this; grpx = group this
**the x in grpx is either 1,2, or 3**
not sure if that is correct...
now this is the script that is supposed to set objective 4 as done when all three groups are down to 3 men or less.
#loop
;sets objective 4 as done when three groups namedgrp1, grp2, and grp3 and down to 3 squad members or less
? (count units mygrp1 <= 3) and (count units mygrp2 <=3) and (count units mygrp3 <=3) : "4" ObjStatus "DONE"; exit
goto "loop"
for some reason, i can't get it to work properly :-\
did i screw up somewhere?
-
I'd do it like this:
In 1 unit from each group, have the init field as this:
"_x allowfleeing 0" foreach units group this; mygrpx = group this
where x is 1, 2, or 3
(I notice it says grpx here but you used mygrpx below, could this be the problem?)
#loop
;sets objective 4 as done when three groups namedgrp1, grp2, and grp3 and down to 3 squad members or less
? (count units mygrp1 <= 3) && (count units mygrp2 <=3) && (count units mygrp3 <=3) : "4" ObjStatus "DONE"; exit
~5
goto "loop"
-
..............i belive homer simpson said it best..... D'OH! duh, probably exactly whats the matter.
hehe
thanks man... i must be to tired to pick up small stuff like that... good eye
-
oh yeah, sorry but i just remember'd that i left something out in my original post... does this script look correct?
#loop
? ("1" objStatus "DONE") && ("2" objStatus "DONE") && ("3" objStatus "DONE") && ("4" objStatus "DONE") : end1
goto "loop"
i want it to end the mission once all objectives are done...
again sorry, but i'm still a learning the script so i need some help
-
1. You would be better with a delay in your loop as Fragorl has in his - or revise the use of the @ command.
2. You cannot check the status of objectives from within a script. What you need to do is check the conditions that change the object status - or use some global variables as follows:
#loop
;sets objective 4 as done when three groups namedgrp1, grp2, and grp3 and down to 3 squad members or less
? (count units mygrp1 <= 3) and (count units mygrp2 <=3) and (count units mygrp3 <=3) : "4" ObjStatus "DONE"; Obj4Done = true;exit
~5
goto "loop"
Bye the way I would do it this way:
@((count units mygrp1 <= 3) and (count units mygrp2 <=3) and (count units mygrp3 <=3))
"4" ObjStatus "DONE"
Obj4Done = true
exit
Do something similar for Obj1Done, Obj2Done etc.
Then have a mission end trigger that has as its condition field
Obj1Done and Obj2Done and Obj3Done and ......
I think people here have probably got bored with me saying the next bit.
When you create global variables like this is is good practice to initialise them at the start of the mission say in init.sqs, as follows:
Obj1Done = false
Obj2Done = false
etc.
This is not always necessary - but sometime it is - so it is good practuce to do it all the time. One example of where it would be necessary is if you want something to happen if one of the objectives has been done and one has not been done eg:
Obj1Done and not Obj2Done
This will only work correctly if Obj2Done has been initialised.
-
ok, i think i got it... thanks...
-
well 99.98% of my first serious mission works correctly except for the trigger i set up to end the mission :-\.
the type is end1
in the conditions field i have
this; obj1Done and obj2Done and obj3Done and obj4Done
the activation field is blank...
whats wrong with it? do i need to put " = true" after "Done"???
again.. sorry for my ubernoobness
-
Hmmm.......Try removing:
this;
Unless you need this in which case maybe:
this and obj1Done and obj2Done and obj3Done and obj4Done
Planck
-
nothing so far has worked. im abouts at wits end and am one step closer to hiring a witch doctor to help....
i've tried removing "this;"... nothin
i've tried this and obj1Done(.....) still nothing
i've tried this; obj1Done = true... nada...
i cant think of any other ways to try... :( :( ??? :-\ :(
is there something i need to put in the "on activation" field
-
Ok a number of things here. Firstly, the expression in the on activation field must evaluate to a boolean, true or false. Having
this; obj1Done and obj2Done and ...
is incorrect and will probably produce an error message. The semicolon indicates a new statement in ofp.
Secondly the single equals = is an assignment operation, and will also lead to errors. The double equals operator == will return you a boolean, but it is redundant to say
obj1Done == true
since this is the same as saying either false == true, or true == true. Which are of course the same as false and true (false is not true and true is true). This sort of thing will also lead to errors; == is used to compare variables only.
I guess the only points would be to check that obj1Done and the other condtions are spelt correctly, and are actually set to true in some case. As for the trigger, as THobson states,
Condition: obj1Done && obj2Done && obj3Done
Timeout or Countdown
Type: end1
Min: mid: max: whatever you like
is correct.
-
allright! now i understand how to make the triggers correctly alot better. thanks, all works well 8)