Home   Help Search Login Register  

Author Topic: Toggle Squads Trigger  (Read 2163 times)

0 Members and 1 Guest are viewing this topic.

Offline Hellbender

  • Members
  • *
Toggle Squads Trigger
« on: 04 Feb 2008, 01:22:41 »
I am experimenting with a mission where the player controls more soldiers than usual. In my mission the player controls the squads via radio commands to go to different game logic waypoints, but I want the player to also be able to directly control a squad when he wants. So, for each squad I have made a radio trigger to make the squad join the player, and one to make the squad go back to being an independent squad. This works fine!

My question is this:

Is there any way that I can construct these radio triggers to simply toggle squads, "on/off"?
I am asking because I think it would be better to save radio triggers and only use 1 for each squad. Is this possible?

Offline Loyalguard

  • Former Staff
  • ****
Re: Toggle Squads Trigger
« Reply #1 on: 04 Feb 2008, 10:30:46 »
So if I understand correctly, you want a single radio trigger to be able to make the squad join the player and then when ready to switch back make and them indepdent again, correct?

One way to do this is using a global variable as your toggle.  Specifically, instead of one of the radio triggers executing whatever code you are using to join/leave the player's group, all the radio trigger does is change a global variable that is then monitored by other trigger(s)s or script(s) and depending on the current state of the variable the trigger or script executes the appropriate code so you only see one radio option, but there is more going on behind the scenes.  Since I don't know the exact code you are working with, here is a pseudo-code example

init.sqf
Code: [Select]
squadToggle = false; // Create a global variable to determine whether we want to the squad to join the player (true) or be independent (false).
Radio Alpha Trigger - Repeatedly
(This trigger checks to see if squadToggle is false and if it is makes it true (and vise versa) everytime you use radio alpha)
Cond: this
On Act.: if (!squadToggle) then {squadToggle = true} else {squadToggle = false};

Action Trigger (name it whatever you want) - Repeatedly
(This trigger monitors squadToggle and executes whatever code/script corresponds to the current state - I have used executing a script in the example but you could enter code directly in the On Act. and On Dea. fields)
Cond: squadToggle
On Act.: nul = [] execVM "squadJoinPlayer.sqf";
On Dea.: nul = [] execVM "squadIndependent";

So, to summarize what happens:

The squadToggle variable is false and the squad starts independent.  You select radio alpha and squadToggle becomes true which fires your action trigger (activates it) that makes code run for the squad to join the player.  When you want them to be independent again you select radio alpha again so squadToggle becomes false and makes your trigger de-activate which then makes other code run to make the squad become independent again.

I hope you find that helpful.  If you want a more specific example post the code, scripts, etc. you are using.  good luck!
« Last Edit: 04 Feb 2008, 11:12:50 by Loyalguard »

Offline Tajin

  • Members
  • *
Re: Toggle Squads Trigger
« Reply #2 on: 04 Feb 2008, 14:45:18 »
Well.... if you have multiple squads and the player joins one of them... then the other automatically are independent. So is a toggle really necessary ? I mean that would only really make sense if the player wanted to run around alone and for that you could simply add 1 more radio.



or....
simply this:


Code: [Select]
Cond: this
On Act.: if (player in (units squadname)) then {player join alone} else {player join squadname};

I guess that should do the trick. Checks wether the player is already in that squad... and puts him into his own lonely group in that case... otherwise it makes him join the squad.

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Toggle Squads Trigger
« Reply #3 on: 04 Feb 2008, 15:00:21 »
I'm only slightly curious about one thing:

Why not use teamswitch? Before you hit me, consider this:

What is the player doing when he's telling the other squads to "join him"? Isn't he in fact sending orders via radio to this squad's actual leader, such as "put your machine gunner in those bushes, and place your squad in line formation on that ridge"? Since it's clearly a question of temporary leadership, it seems to me it'd simply be more convenient to use teamswitch to quickly tell the other squad exactly what it is it needs to do, and make it so that if the "main" player character is killed while teamswitched, the mission ends regardless.

Teamswitch -is- bugged in the sense that teamswitching into a unit not in the player's squad will cause that unit to become quite unresponsive, but there's a fix over in this tutorial by me.  :)

Just a thought!

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Loyalguard

  • Former Staff
  • ****
Re: Toggle Squads Trigger
« Reply #4 on: 04 Feb 2008, 15:54:56 »
Tajin-

I guess I was assuming that the player has his own squad/group and just wanted the other squad to temporarily join him.  I realize that may not be the case so your solution might be the best way.  A couple of points on your code though:

This is what you wrote:
Code: [Select]
if (player in (units squadname)) then {player join alone} else {player join squadname}
But it probably needs to be like this to work:
Code: [Select]
if (player in (units squadname)) then {[player] join grpNull } else {[player] join squadname};
1. The join command requires an array as a parameter, so you have to put [ ] around Player (or whatever units you want to join a group).

2. To get a unit (or player for that matter) to leave a group its probably best to use: [player] join grpNull unless you already have an active group for him to join (in your case a group named "alone").  The reason for this is that I think a group is destroyed when it is empty (last unit leaves or dies) so I don't think a group can exist without any units in it so that is why player has to join grpNull and then if you need to name it you can alway use:

Code: [Select]
alone = group player;
Wolfrug's solution is also worth looking into.

Offline Tajin

  • Members
  • *
Re: Toggle Squads Trigger
« Reply #5 on: 04 Feb 2008, 19:20:21 »
yeah right, forgot that the join command requires an array of units.  :whistle:

Offline Hellbender

  • Members
  • *
Re: Toggle Squads Trigger
« Reply #6 on: 04 Feb 2008, 23:26:38 »
Well, maybe I should explain further!

In the mission I'm making, the player is a platoon leader of a mech. inf. platoon with about 40 soldiers, which is a lot to command in Arma. I want to try to give it a platoon leader feel to it without making the player want to commit suicide because of the stress it would involve to command so many soldiers like you do it in Arma. (The way I see it, Arma is normally ideal for squad leader missions.)

I don't just use teamswitch, because I want the player to play the whole mission in character as the platoon leader!
I've made some GameLogic waypoints for the player to command his platoon through, like attack the town, defend the crossroads, fall back, etc. This works fine with me because a platoon leader isn't supposed to command soldiers directly anyway, but through his squadleaders. The reason I want the squad toggle thingy is because I want the player to have the freedom to improvise and do things differently if he wants. I just thought it looked a bit ugly using up two radio commands for each squad instead of 1.

I'll upload the mission when its done so you can get a clearer picture!

I used Loyalguard's suggestion and made a global variable as my toggle which works perfectly!

Thank you all for your ideas!

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Toggle Squads Trigger
« Reply #7 on: 04 Feb 2008, 23:40:54 »
If you're good at reverse-engineering (;)) you can check out the Squad Control System I've got in Operation Dawning Hope, although you only control half a Marine platoon + some other assets there. I'm going to convert the SCS to a more easily usable resource and submit it to the Ed.Depot here soonish, but it's pretty much like a light (and addonless) version of the CoC CEX. There are some other "command and control" systems out there, but I can't seem to find them right now.

But of course, it's always the most fun to do something yourself :D

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Loyalguard

  • Former Staff
  • ****
Re: Toggle Squads Trigger
« Reply #8 on: 05 Feb 2008, 00:05:38 »
Looking forward to seeing the mission Hellbender!  Great concept!

I've been working on something similar but the player as one of the squad leaders taking order from a mission-driven "platoon leader".  AI squads work independently of your squad but with similar objectives and supporting one another.  Ypu advance together, cover each other flanks,etc.  It is intended to give you the feel of being part of a larger military operation without having to run more than a single squad.

It'd be nice to see your approach with the player as the platoon leader!  Sound great!  Good luck!
« Last Edit: 05 Feb 2008, 00:09:23 by Loyalguard »

Offline Barbolani

  • Members
  • *
Re: Toggle Squads Trigger
« Reply #9 on: 05 Feb 2008, 11:51:54 »
Hi all!,

Just for giving you ideas:

Im working on a mission similar. You are a platoon commander, and you control around 5 squads attacking some bases at the same time. The clue of winning the mission is a good use of tactics and support (artillery, reinforcements, airstrikes etc..)

Im trying to do this in the same way Ive seen in an OFPR mission where you controlled a few tanks directly and some more follow your men and act in the same way than them...

So, you are a team leader and you have in your platoon 5 squad leaders placed around the map. You control them directly. There are no vehicles, only infantry.

The non-directly-controlled squads are scripted so their squad leader dofollow or domove (i havent tried this yet) to my squad mate, and periodically checks their behaviour to have the same.

The problem im finding is on how to make them reveal all the units my squadmate knowsabout...

The good thing about this system is that you have revealed all the enemies your squad mates knowabout so you can call artillery from any position to any position.

If your squadmate dies, the non-controlled squad leader joins your group, and so on...