Home   Help Search Login Register  

Author Topic: help: count triggers for empty vehicles, and spawn a squad  (Read 1791 times)

0 Members and 1 Guest are viewing this topic.

Offline smoke52

  • Members
  • *
basic overview:
inserted by boat, sneak in and light up some target with a laser designator, retreat to extraction (stuff happens...mission continues for a little longer)

what i need help on is making it so when the player destroys 8-10 tanks the objective is complete. these tanks are empty and named tank1- tank10 at the moment...when the player destroys 1 tank an alarm goes off and a bunch of guys try getting in the tanks and take off. im asking on the flashpoint forums too and a guy said to "set a trigger and a publicvariable for each piece and then 1 trigger that checks all the variables to complete the objectives"

im new to scripting still so if you can give me an example of what to write i would appreciate it very much! thank you

EDIT
well after some thorough searching i found the answer!! but a new question arose...

i have it when 1 tank blows up it sets off 6 squads of guys to try and get in the tanks then take off to a trigger area that ends the mission. i want it so if two or more tanks escape the player loses, but if the squads dont get in tanks they still run to the trigger ending the mission.

how can i make it so it will only trigger if they are in tanks?
« Last Edit: 09 May 2007, 19:32:06 by smoke52 »

Offline smoke52

  • Members
  • *
Re: help: count triggers for empty vehicles
« Reply #1 on: 09 May 2007, 18:19:53 »
delete me
« Last Edit: 09 May 2007, 19:31:52 by smoke52 »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #2 on: 09 May 2007, 18:56:39 »
1) Add the following to your init.sqf
Code: [Select]
tanklist = [tank1, tank2, tank3, tank4, tank5, tank6, tank7, tank8, tank9, tank10];
2)Add trigger set to anybody and repeatedly. In its OnActivation:
Code: [Select]
({_x in tanklist} count thislist) >= 2
3)Note that this trigger will fire no matter who is in the tanks. To make it only fire for one particular side(east):
Code: [Select]
({(_x in tanklist) && (side driver _x == EAST)} count thislist) >= 2
Might need an extra parenthesis in the side driver part. I can never remember.

 :no:Please do not double post on this forum. Instead use the Modify button to add to your previous post. Help keep our forums beautiful! :yes:
« Last Edit: 09 May 2007, 18:59:22 by Mr.Peanut »
urp!

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #3 on: 09 May 2007, 18:57:06 »
smoke52, please do not double post.
If you have something to add and your post is the last (or the only) one in a thread, you can edit your post using the 'modify' button, instead of replying to yourself.
« Last Edit: 09 May 2007, 18:58:10 by bedges »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #4 on: 09 May 2007, 19:08:26 »
Use Mr Peanut system if you have a clear idea of which tanks may be involved (their names), if not, you may use something like this:

Code: [Select]
//fleeingcheck.sqf
_fleeingpos = _this select 0;
_fleeingradius = _this select 1;

fleeingsuccess = false;
_numfleeing = 0;
_tanks = [];
while {_numfleeing < 2} do
{
   _tanks= _fleeingpos nearObjects ["Tank",_fleeingradius];
   if (count _tanks > 0) then
   {
      _numfleeing = {((count crew _x) > 0) && (side _x == east)} count _tanks;
   };
};
fleeingsuccess = true;

You may run fleeingcheck.sqf from your init.sqs file this way:
Code: [Select]
;init.sqs
[getMarkerPos "mk_fleeingcenter", 1000]execVM"fleeingcheck.sqf"

Then you may use global var fleeingsuccess in your trigger to check if enough tanks did reach the fleeing area.

Offline bedges

  • Administrator
  • *****
    • OFPEC The Editing Center
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #5 on: 09 May 2007, 19:14:54 »
and lest we forget, welcome to the forum!

Offline smoke52

  • Members
  • *
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #6 on: 09 May 2007, 19:31:30 »
ok sorry for the double post...i have a habit of not reading the forum rules, but i think i will go do that now  :cool2:

and thank you for the replies, that did the trick!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: help: count triggers for empty vehicles, and spawn a squad
« Reply #7 on: 10 May 2007, 00:36:03 »
If you are using Mandoble's code you might want to insert a small pause in the outer loop i.e. sleep 2;
urp!