Home   Help Search Login Register  

Author Topic: End game when all players have reached area  (Read 2966 times)

0 Members and 1 Guest are viewing this topic.

Offline Monty

  • Members
  • *
End game when all players have reached area
« on: 26 Oct 2008, 16:53:45 »
Hello, I would like to preface this post by apologising for my noobishness and by assuring you all that I've already searched for a topic to answer my problem. 

Anyway, I'm constructing a multiplayer mission where the goal is for all of the players to escape to an island whereupon the game will end, but I'm having a little difficulty with ending the game.  My first thought was to place triggers on the island for each playable unit that would fire and complete an objective when that player reached the area.  I then created another trigger to end the game when all the objectives had been completed (i.e. all players had made it to the island).  So, for example, when P1 arrived at the island, an objective would be completed and then when P2 arrived another objective would be completed.  When P1's and P2's objectives had been completed, the mission would end.  The problem is that if not all of the playable units are being played in the game the game couldn't end because the objectives tied to the unplayed playable units couldn't be completed.

I'm guessing there's a far more easier way to tell the game to end when all the players in the server have reached the island - can this be done through triggers or is some scripting required?  I'm grateful for any help you can offer.

Offline Zipper5

  • BIS Team
  • ****
Re: End game when all players have reached area
« Reply #1 on: 26 Oct 2008, 18:28:51 »
Hello, I would like to preface this post by apologising for my noobishness and by assuring you all that I've already searched for a topic to answer my problem. 

It's not a problem at all, everyone starts out that way. ;)

Is the island that you want them to go to inhabited by friendly units, or any units at all for that matter? A very simple way of doing it if that is not the case is placing a trigger covering the island which is activated by whatever side the players play on (BLUFOR, OPFOR, Independent, Civilian or Anybody).

I'm not positive this will work, and it's certainly not an elegant and simple method (I'm not "amazing" at scripting myself), but there's always room for trial and error. :D
You could try putting one trigger which determines when one of the unit enters it and one that determines when the other one does, and so on. Then you could place one more trigger that determines when these two (or more) triggers have been activated, meaning the units have entered the zone, and then ends the mission when this condition is met.

Problem for me is I have this idea, but I can't tell you how to do it simply because I don't even know how. >:(
If this is appropriate or the way others think it should be done then I think someone much more competent at this than I am will be able to tell you how to do it. Or they'll tell you an even better way, which is a lot more likely.

Hope that helps out a bit mate. Good luck getting this sorted.

Offline i0n0s

  • Former Staff
  • ****
Re: End game when all players have reached area
« Reply #2 on: 26 Oct 2008, 21:57:19 »
Code: [Select]
Script = { private ["_result", "_i"];
_result = true;
_i = 1;
while { (_i < 10) and _result } do {
if (!isnil format ["p%1", _i]) then {
if (call compile format ["!isnull p%1", _i]) then {
call compile format ["_result = _result and (p%1 in _this);", _i];
};
};
_i = _i + 1;
};
_result}

Name the players p1 to p10, in OnActivation of the trigger:
Code: [Select]
ThisList call Script

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #3 on: 27 Oct 2008, 00:38:45 »
Thanks!  :)


Am I right in understanding that to get the script to work I will have to save the script to the mission folder and add

Code: [Select]
server execVM "script.sqf";
to the init.sqs?

Offline i0n0s

  • Former Staff
  • ****
Re: End game when all players have reached area
« Reply #4 on: 27 Oct 2008, 10:58:52 »
Why "server"?

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #5 on: 27 Oct 2008, 12:49:18 »
That's just what I've been instructed to do when utilising other third party scripts.  Do I need to do something different?

Offline Carroll

  • Members
  • *
  • Mission Designer (MP-"well tryin to capiche"
Re: End game when all players have reached area
« Reply #6 on: 27 Oct 2008, 13:42:19 »
Group the Leader to a trigger which covers the desired area & set the activation to "Whole Group" present

Edit: not sure how you've put your mission together, but obviously all units must be of the same group for this simple way to work ok
« Last Edit: 27 Oct 2008, 13:48:19 by Carroll »

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #7 on: 27 Oct 2008, 14:25:02 »
I did consider that, but for my mission it's important that the players start isolated from each other and are unable to communicate.  If grouped together they would be able to give orders to each other.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: End game when all players have reached area
« Reply #8 on: 27 Oct 2008, 16:22:59 »
Consider using (assuming you have a BLUFOR detected trigger that ends the game):
Code: (trigger condition) [Select]
({ isPlayer _x } count thisList) == (playersNumber west)

Well, anyway, playersNumber tells you how many players on a given side are spawned and playing, not how many were placed down in the editor, so it should do you however you want to use it...
« Last Edit: 27 Oct 2008, 16:25:32 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline i0n0s

  • Former Staff
  • ****
Re: End game when all players have reached area
« Reply #9 on: 27 Oct 2008, 16:48:07 »
Use [] execVM "script.sqf";

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #10 on: 27 Oct 2008, 17:09:17 »
I've put that in the init.sqs and I've tested the trigger in the editor and in MP but it doesn't work.  Can you point out where I'm going wrong?


Offline i0n0s

  • Former Staff
  • ****
Re: End game when all players have reached area
« Reply #11 on: 27 Oct 2008, 23:26:38 »
"ThisList call Script" has to get to Condition.

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #12 on: 28 Oct 2008, 13:42:34 »
That's not working either.  I've tried both of these:

Code: ("In Condition Field") [Select]
ThisList call Script
Code: ("In Condition Field") [Select]
this && This call Script
But none of them have worked.  I've saved the script to the mission directory as "script.sqf" and I've put [] execVM "script.sqf" in the init.sqs.

Consider using (assuming you have a BLUFOR detected trigger that ends the game):
Code: (trigger condition) [Select]
({ isPlayer _x } count thisList) == (playersNumber west)

Well, anyway, playersNumber tells you how many players on a given side are spawned and playing, not how many were placed down in the editor, so it should do you however you want to use it...

I've given this a go but not I'm not having much luck with it either.  Is this how the trigger should look?



Thank you all for your continued help and perseverance.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: End game when all players have reached area
« Reply #13 on: 28 Oct 2008, 16:49:05 »
Sorry, what I gave you is the whole condition line, not intended to be added to "this &&". However, adding "this &&" doesn't make the slightest difference to how it works in this case, so that doesn't matter ;P

I suspect, therefore, that you fell foul of something I didn't specify, which can only be my fault. That line I gave requires that the players are on foot (it doesn't count vehicle crew; this can be corrected relatively easily though if the players are likely to be in a vehicle when they finish the mission, either by asking them to get out or changing the code slightly) and it only works if you have "disabledAI=1;" in description.ext (playable AI that are in-mission count, even if they are dead, with playersNumber but in any case not with isPlayer) and some sort of respawn (or revive) enabled, otherwise there will be dead players that can't get to the exit to trigger it. Sorry about those assumptions; I get so used to using these standard settings for missions, I didn't think about it enough :whistle:
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Monty

  • Members
  • *
Re: End game when all players have reached area
« Reply #14 on: 29 Oct 2008, 22:56:39 »
I've just got round to testing it and from what I can tell, it works!  Thank you very much for your help Messrs Spooner and i0n0s.  :)