Home   Help Search Login Register  

Author Topic: troubles again  (Read 832 times)

0 Members and 1 Guest are viewing this topic.

Offline ONoSixIsDown

  • Members
  • *
troubles again
« 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

Quote
"_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.

Quote
#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?
« Last Edit: 19 Nov 2005, 14:56:49 by OhNoSixIsDown »
CRIMSON REIGN COMMING..... eventually :/

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:troubles again
« Reply #1 on: 19 Nov 2005, 14:58:54 »
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?)

Code: [Select]
#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"

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #2 on: 19 Nov 2005, 15:01:37 »
..............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
CRIMSON REIGN COMMING..... eventually :/

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #3 on: 19 Nov 2005, 15:38:06 »
oh yeah, sorry but i just remember'd that i left something out in my original post... does this script look correct?

Quote
#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
CRIMSON REIGN COMMING..... eventually :/

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:troubles again
« Reply #4 on: 19 Nov 2005, 16:12:53 »
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:


Code: [Select]
#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:

Code: [Select]
@((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

Code: [Select]
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:

Code: [Select]
Obj1Done and not Obj2Done
This will only work correctly if Obj2Done has been initialised.
« Last Edit: 19 Nov 2005, 16:23:11 by THobson »

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #5 on: 19 Nov 2005, 16:55:06 »
ok, i think i got it... thanks...
« Last Edit: 19 Nov 2005, 16:58:41 by OhNoSixIsDown »
CRIMSON REIGN COMMING..... eventually :/

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #6 on: 20 Nov 2005, 03:29:32 »
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

Quote
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
CRIMSON REIGN COMMING..... eventually :/

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:troubles again
« Reply #7 on: 20 Nov 2005, 03:59:04 »
Hmmm.......Try removing:

this;

Unless you need this in which case maybe:

this and obj1Done and obj2Done and obj3Done and obj4Done


Planck
« Last Edit: 20 Nov 2005, 03:59:29 by Planck »
I know a little about a lot, and a lot about a little.

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #8 on: 20 Nov 2005, 04:14:56 »
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
« Last Edit: 20 Nov 2005, 04:16:04 by OhNoSixIsDown »
CRIMSON REIGN COMMING..... eventually :/

Offline Fragorl

  • Coding Team
  • Former Staff
  • ****
Re:troubles again
« Reply #9 on: 20 Nov 2005, 07:05:51 »
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.
« Last Edit: 20 Nov 2005, 07:06:27 by Fragorl »

Offline ONoSixIsDown

  • Members
  • *
Re:troubles again
« Reply #10 on: 20 Nov 2005, 07:25:31 »
allright! now i understand how to make the triggers correctly alot better.  thanks, all works well 8)
CRIMSON REIGN COMMING..... eventually :/