Home   Help Search Login Register  

Author Topic: Trigger activation after two objs done  (Read 1964 times)

0 Members and 1 Guest are viewing this topic.

Offline Rdavies

  • Members
  • *
Trigger activation after two objs done
« on: 26 May 2007, 21:55:41 »
Hi, im making a mission where your the leader of a resistance sqaud and training them, but half way through you get called away. What i want to happen is a trigger to be activated after the first two training excercises Obj1 and Obj2 are completed when the player is in the triggers radius. I would also like to know:

How to make it so when a certain number of squadmembers are killed, they retreat, or a trigger is activated as in they are unnassigned from the squad leader and flee.

Multiple choices, how would you make it so, in the context of the mission im making, when you go back to your base, you have the choice of either taking your group of rookie soldiers who are more in number with you, or you have the choice of 2-3 trained resistance fighters.

I have searched through the comref and forums and have come a bit stuck with these elements of the mission, any help would be greatly appreciated

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Trigger activation after two objs done
« Reply #1 on: 27 May 2007, 01:49:40 »
Well, the third part of your question can be handled by THobson's script BecomeLeader, which you will find in the scripts section of the Ed Depot(ED). When the time comes for the player to choose, let him choose by moving to one of two locations, each of which will have a trigger activating the BecomeLeader script for the appropriate units with the condition that the other trigger has not fired. Otherwise you can use the addAction command to add two menu items which offer the player a choice. If you need more specific details on how to do the above, just ask.

As for your second issue: If all the units are in the same group and you are checking to see that only 4 are left alive, then your trigger Condition would be something like:
Code: [Select]
({alive _x} count units myGroupName) < 4And your On Activation:
Code: [Select]
{if (_x != player) then {_x allowFleeing 1 ; [_x] join grpNull}} forEach units myGroupName
Make sure you put the following in the init field of all the units in this group:
Code: [Select]
myGroupName = group this
And last but not least your first issue.  You need to provide a little more detail. Have you already set up triggers to determine that Obj1 and Obj2 have been completed? Let's say you have and that the On Activation for each of these triggers respectively has the following lines:
Code: [Select]
bObj1 = TRUEand
Code: [Select]
bObj2 = TRUE
The next trigger is set to detect side once with the Condition:
Code: [Select]
bObj1 && bObj2 && (player in thisList).
(The parenthesis may not be required but I choose to err on the side of caution).

I am not sure what you want this trigger to do. If it is supposed to trigger the check for lives lost and fleeing, then you can either:
1) Just synchronise it with the trigger that does the alive check
or
2) Combine the conditions i.e. one trigger with detect side once and condition:
Code: [Select]
bObj1 && bObj2 && (player in thisList) &&  (({alive _x} count units myGroupName) < 4)and the On Activation code I gave for fleeing.


« Last Edit: 27 May 2007, 16:51:44 by Mr.Peanut »
urp!

Offline Rdavies

  • Members
  • *
Re: Trigger activation after two objs done
« Reply #2 on: 27 May 2007, 17:40:17 »
Thanks for the advice, i've just tried the objective part and it works fine, im just wondering, after doing more with my mission, is it possible for a trigger to be fired, when two specific units are in an area, i tried using something like this "c in thislist&&L1 in thislist" and the outcome of this is to make a group of civillians join you, it works if its just c in thislist, the name of the truck the civillians are in, but not for C and L1(you.) Besides that though I think if i went into more detail it would help. Basically, you start out waiting for civillians in a truck, when they arrive, they join you(I want it to be so that, the truck, and you have to be in the same trigger area for them to join you.), you go complete two training excercises with them, then get called back to base, as russians have attacked your allies in a town, you have to go help them. I want it to be so that you decide to either take them with you(Rookie civillians), or the resistance fighters(2-3 more expierienced), addaction seems to be the best for this but i've looked in comref and have no idea how to use it, so any help on this would be appreciated. Also, three other things,
1.) To try and add atmosphere to the mission, i've put two resistance fighters at the firing range, and I want it so they fire at two targets, destroy them and walk away. The part I cant seem to get to work, is actually getting them to fire at the targets and destroy them, i've tried dotarget, dofire and commandfire, but always nothing, any ideas?
2.)  How do you get it so that a trigger activates if a player is a certain distance from another unit, as in 1m from unit, which causes text to come etc, as I think this will generally help in making my mission.
3.) I know how to make veichles have no fuel "setfuel 0" But how would I make it so when you got into a veichle, a message would come up e.g. the character "Bugger, no fuel"

Sorry for all the questions, its just I have a lot of ideas in mission making and either cant implement them properly, or very crudely at best, and would like to learn to do these types of things properly, and again, any hepl would be greatly appreciated.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Trigger activation after two objs done
« Reply #3 on: 28 May 2007, 01:40:33 »
Okay,
I might not get to answer all your questions immediately but will do so eventually.

-1)Your trigger condition should be:
Code: [Select]
this && c in thisList && L1 in thisListshould work, but you need to set the trigger for anybody present once, since the civvies are not on your side to start. You need the first this because it refers to the anybody present part of the condition. Make sure all the civvies are lower rank than you. The code to make them join would be something like:
Code: [Select]
{units grpCiv join L1} where I am presuming that you have named your group of civvies grpCiv

 0)I would still be tempted to use a trigger for the player decision. Tell the player to take the civvies and go, or got to such and such position to pick up the vets. Put the vets inside a trigger with side detected once and Condition:
Code: [Select]
this && bObj1 && bObj2 && L1 in thisListwith On Activation:
Code: [Select]
{[_x] join grpNull} forEach units group L1 ; {[_x] join L1} forEach units grpVetswhere grpVets is the group name you have assigned to the vets.

That's it for now. g2g... Keep eyes on this space for later I will answer your other questions.

Edit1:Don't forget that you can not have more than 11 civs join L1 to make group size of 12.
« Last Edit: 28 May 2007, 03:19:01 by Mr.Peanut »
urp!

Offline Rdavies

  • Members
  • *
Re: Trigger activation after two objs done
« Reply #4 on: 28 May 2007, 03:32:57 »
Thanks a lot, the first part worked a treat, they all join me now, and only when the two conditions are met, have yet to try out the multiple choices. Also, after reading other posts regarding Target E, which I was using, I have now changed the targets to empty civillian cars instead which seems to work with the dofire command. I've also managed tofind out that its "Player distance Otherunit<5" for things activating a certain distance from other units, just need help with the third point now.

Also, is there a way to arm an entire squad at once, as to arm your civillian recruits you have to get them to individually get a weapon, which could be a bit annoying, I was thinking of possibly doing a small cutscene and using the addweapon, addmagazine command instead of this, but if there was a way to do it collectively it'd be a lot better.
« Last Edit: 28 May 2007, 03:41:13 by Rdavies »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Trigger activation after two objs done
« Reply #5 on: 28 May 2007, 23:01:13 »
You forgot about your question 3!

3) Add the following to the init field of the truck you want to test for fuel.
Code: [Select]
this add EventHandler ["GETIN",{if ((fuel (_this select 0) < 0.001) && ((_this select 1)=="DRIVER") then {(_this select 2) groupChat "Bugger! There's no fuel in this rustbucket!" ; (_this select 0) removeAllEventHandlers "GETIN"}}]This will mean that the first unit to enter the truck as driver will make this exclamation. Be warned that the "GETIN" eventhandler does not fire if you move to the driver seat from within the truck.

An alternate  way to do this is with a single trigger set to None, with the Condition:
Code: [Select]
not (isNull driver myTruck) && fuel MyTruck < 0.001and On Activation:
Code: [Select]
driver myTruck groupChat "Bugger! There's no fuel in this rustbucket!"
Also, if you order an AI unit in your group into the driver's seat of a vehicle with no fuel he will say "Out of Fuel" automatically. If you want only yhe player to exclaim ther is no fuel then change the condition of the trigger to:
Code: [Select]
(driver myTruck) == player && fuel MyTruck < 0.001
Now I have to take the dog out, but when I am back I will deal with the issue of arming your civvies.

Edit: Back again. Made c ouple corrections to above code so make sure you have latest version.

4) Arming units. This depends how you want it to work. Let's say you want the units to go get magazines and weapons in a way that will look good to the player.

You need a little script called toarms.sqs:
Code: [Select]
; toarms by Mr.Peanut
; Example call
;[myUnit,myCrate,"M16","M16",4] exec "toarms.sqs"
; arguments:
; Unit you want to arm
; The object at which you want the unit to appear to arm
; Weapon type
; Magazine type
; Number of magazines

_unit = _this select 0
_crate = _this select 1
_weapon = _this select 2
_mag = _this select 3
_nmag = _this select 4
_x = getPos _crate select 0
_y = getPos _crate select 1
~(3 + random 5)
_unit doMove [_x + 1 - random 2,_y + 1 - random 2]
@(_time > 20 || _unit distance _crate <= 2 || unitReady _unit)
_unit switchMove "CivilToCivilPutDown"
~1
_i = 0
#loop
_unit addMagazine _mag
_i = _i + 1
if (_i < _nmag) then {goto "loop"}
_unit addWeapon _weapon
_unit doMove [_x + 5 - random 10,_y + 5 - random 10]
~(2 + random 2)
_unit playMove "CombatReloadMagazine"
exit
« Last Edit: 29 May 2007, 03:04:46 by Mr.Peanut »
urp!

Offline Rdavies

  • Members
  • *
Re: Trigger activation after two objs done
« Reply #6 on: 29 May 2007, 16:26:55 »
Thanks a lot, i know im being completely stupid now, but, where do I put that script, do I just copy and paste it into the on activation field of a trigger? Also two other things, should be the final questions, how do I get it so a radio command (E.G. 0-0-1 Alpha) remains hidden until a certain point? Also, with on screen text how do I format it as in starting a new line, I know its \N for hints, but that dosen't seem to work for plain text, when I type it in it goes off screen because its just one long sentence.
« Last Edit: 29 May 2007, 16:32:58 by Rdavies »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Trigger activation after two objs done
« Reply #7 on: 29 May 2007, 17:51:49 »
Let's say you want to arm all of your civvies. Assuming that you have named you civvies c1,c2,c3, ... the code line would be:
Code: [Select]
{[_x,myCrate,"M16","M16",4] exec "toarms.sqs"} forEach [c1,c2,c3,c4...]And you could put it in the activation of a trigger. Of course, each civ will be armed with an M16 and four M16 mags unless you change the third and fourth options to the weapons/mags of your choice. Tell me exactly what you are trying to do if you need a more specific solution.

To hide a radio trigger. Enter "hide radio" in the forum search box and read this thread.

As far as your split line text make sure you use titleText instead of titleCut and  \n should work.
« Last Edit: 29 May 2007, 17:57:17 by Mr.Peanut »
urp!

Offline Rdavies

  • Members
  • *
Re: Trigger activation after two objs done
« Reply #8 on: 31 May 2007, 17:48:32 »
Ah right, thanks. Just Two quick things, stuff which has cropped up while making my mission, titletext, how do you get it to come up? I've typed in something like titletext["message","bottom"] which is meant to be activated when you get to within 5M of  a unit, the problem is, no text comes up, and I know the trigger is firing because if in the trigger options I go into efffects and put text into the text box there it'll come up, and the hint which I put to be activated by the trigger comes up when the conditions are met. Also, is there anyway of cancelling a trigger, e.g. in my mission at the beggining, if you go to your commander he'll tell you that your men are en route, but I would like it so that when they arrive, or you've collected your men, he will no longer say this.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Trigger activation after two objs done
« Reply #9 on: 31 May 2007, 18:12:52 »
Code: [Select]
titleText ["Blah blah blah","PLAIN DOWN",x]Where x is the numer of seconds. Leave out x and it defaults to 1 second. Can't remember if that is the time for the text to appear or that it remains on the screen.

For your trigger problem, append the following to the On Activation of the trigger that adds the civs to your group:
Code: [Select]
; civs_joined = TRUE
Then append the following to the Condition of the trigger that makes the officer speak:
Code: [Select]
&& not civs_joined
« Last Edit: 31 May 2007, 18:21:20 by Mr.Peanut »
urp!