Home   Help Search Login Register  

Author Topic: Mission ending & revealing problems  (Read 2696 times)

0 Members and 1 Guest are viewing this topic.

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Mission ending & revealing problems
« on: 12 Feb 2009, 00:08:51 »
I've started making some MP missions, which I'm pretty new to actually and I've ran into a few problems lately...

The first problem is ending the mission. A friend of mine wrote the following script to me which I've used:

Code: [Select]
#start
~1

_cnt1 = {alive _x} count units pagrp
_cnt1 = _cnt1 + ({alive _x} count units pbgrp)

_cnt2 = {_x distance ENDAREA < 200} count units pagrp
_cnt2 = _cnt2 + ({(_x distance ENDAREA) < 200} count units pbgrp)

if(_cnt2 == _cnt1) then {goto "end"} else {goto "start"}

#end
end=true

Basicly it should count the alive units from two groups and execute the ending trigger when every each one of them is within 200 meters from the ENDAREA gamelogic. The script gets executed once all of the mission objectives are complete. In single player it seems to work alright, no problems at all, but in multiplayer the ending trigger gets executed even if the player(s) aren't within the range of the ENDAREA gamelogic. Does anyone know what's that about and how to fix it?

My second problem is about the reveal command. The AI seems to be really dumb sometimes - We can even drive right in front of their nose with an armed truck and snip them one by one and they won't care. The other friendly groups to them don't seem to care either, even when we're within their hearing range. So I created this little script below to make them more intelligent:

Code: [Select]
if(pickup distance BASE < 170) then {goto "reveal"} else {exit}

#reveal
grp1 reveal pickup
grp2 reveal pickup
grp3 reveal pickup
grp4 reveal pickup
exit

The script should reveal the pickup truck armed with an MG to those four enemy groups when it is firing within 170 meters from the gamelogic BASE. I added an eventhandler "fired" to the truck's init field which executes that script... Again, in single player it seems to work fine and they'll always engage me as they should, but in multiplayer we can still drive right in front of their nose and shoot them and they won't give a shit. Is there a way to fix this?
???

Walter_E_Kurtz

  • Guest
Re: Mission ending & revealing problems
« Reply #1 on: 12 Feb 2009, 04:18:28 »
Multiplayer is not my metier, but I think the problem may be that all machines end up running the script.

Have a look at the Multiplayer Trigger, Script & addAction guide.


My instinct would be to add:
Code: [Select]
?!(local server): exitto the start of each script - so that it is only run on the server

and then publicVariable the fact the "end is true" when necessary:
Code: [Select]
end = 1; Publicvariable "end"

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: Mission ending & revealing problems
« Reply #2 on: 12 Feb 2009, 09:54:24 »
Thanks for your answer. I found some new useful information from that link, though your advice didn't have any effect on either of my problems...

Edit 1: After some little testings with hint command to display the values of cnt1 and cnt2 from my first script, it appears that they get the value scalar bool and so on when either of the groups don't exist. When both of the groups have at least one player, then I get the correct value. Is there any workaround on this? Maybe to check if either of the groups do not exist and then discount them from the variables? I'm not sure which is the best way or how to do this so I'll trust you mission editing gurus on this.

Edit 2: So I found out how to check if the values are "scalar bool array string 0xfcffffef" and improvised the script a little to check if either of the groups are that and count it as 0, so I've got that sorted out. :) Now there's only my second problem...
« Last Edit: 14 Feb 2009, 12:06:17 by Rellikki »

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Mission ending & revealing problems
« Reply #3 on: 17 Feb 2009, 16:42:21 »
Your second script needs only to be run on the machine(s) where grp1-4 are local. If they are enemy AI, then you must make sure this script gets executed on the server. It will do no harm to run it on all machines, but you must ensure it runs on the server.
urp!

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: Mission ending & revealing problems
« Reply #4 on: 19 Feb 2009, 21:14:50 »
I'm pretty sure it runs on the server too. I made the thing display a hint in the #reveal section and every player (including me, the hoster) got the hint displayed. So the script works all fine, but it seems like the reveal command doesn't have any effect at all.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Mission ending & revealing problems
« Reply #5 on: 20 Feb 2009, 02:30:51 »
But you said the script is called by a fired event handler attached to the truck. Are AI or players in the truck? A fired event handler only runs on the machine on which the vehicle is local. I suggest you use the fired handler to run a script that publicVariable a True/False variable(e.g. switchFired). Then add a trigger with condition switchFired that calls the reveal script. This is similar to the first addAction example in the aforementioned tutorial.
urp!

Offline Clayborne

  • Members
  • *
Re: Mission ending & revealing problems
« Reply #6 on: 14 Jun 2009, 21:23:01 »
I'm having a similar problem with an ending trigger.

Currently I have a trigger with the condition

("alive _x" count units grp1 == "_x in thislist" count units grp1) and ("alive _x" count units grp2 == "_x in thislist" count units grp2)

This works in when both groups are present. However, if one of these groups is turned off in an MP game, the trigger does not fire with only the remaining group present, because I guess the game doesn't recognize that the other group was there in the first place.

Is there a condition line I can use for this, or would it have to be a script?

Offline firegraphite

  • Members
  • *
Re: Mission ending & revealing problems
« Reply #7 on: 15 Jun 2009, 04:56:19 »
Hmm.. I'm not sure if I understand clearly what you have in mind  :scratch: but.. maybe try this..

Make a separate trigger for each group that sets a variable to true if all members are dead.

Trigger 1
cond: (count units grp1) < 1
on activation: grp1dead = true; publicVariable "grp1dead"

Trigger 2
cond: (count units grp2) < 1
on activation: grp2dead = true; publicVariable "grp2dead"

Then your end trigger:
(("alive _x" count units grp1 == "_x in thislist" count units grp1) and (("alive _x" count units grp2 == "_x in thislist" count units grp2) or grp2dead)) or (("alive _x" count units grp2 == "_x in thislist" count units grp2) and grp1dead))

just check my syntax... there might have been something i missed and i don't know exactly when to use brackets or stick with parenthesis... to simplify basically the end trigger condition should be either of these:
grp 1 and grp 2 in trigger
grp1 in trigger and grp2dead
grp2 in trigger and grp1dead

I hope this helps...



« Last Edit: 15 Jun 2009, 04:57:56 by firegraphite »

Offline Clayborne

  • Members
  • *
Re: Mission ending & revealing problems
« Reply #8 on: 15 Jun 2009, 12:47:56 »
Sorry maybe I wasn't clear;

In a Multiplayer game, if you disable all playable members of one of the groups in the game lobby, the game does not seem to know that the group was ever there in the first place.

This is exactly the same as in SP if you delete group bravo. Because bravo is not there, as far as the game is concerned it cannot count the units from bravo, because there is no bravo.

I guess a better question would be: Can I tell the game to count all members of player-controlled groups? That way, even if Bravo is disabled, the game will only try to count the units from alpha, being the only group with human players.

does count units group player only work in SP, or can it be used to count units in multiple player-controlled groups?

Is there some line I can put in the init.sqs to tell the game that a certain unit may exist even if he is not present?

« Last Edit: 15 Jun 2009, 13:24:57 by Clayborne »

Offline firegraphite

  • Members
  • *
Re: Mission ending & revealing problems
« Reply #9 on: 15 Jun 2009, 17:00:40 »
ahh... I see... LoL. well to tell you the truth i don't know of any way to detect if the player slot has been disabled. But then I might still suggest a way to get around it..

Set a certain variable to false in an init file. lets say, "bravohere"
Then put a trigger (lets call this bravochecker) at a certain remote part of the island, or preferably a separate island, where no one would go straying about. This trigger will be set off by the presence of unit/s from the group's side. On activation it sets to true the variable "bravohere"

The group in question will also start from some other remote location with a trigger that will be set off if they are present. On activation they are teleported to bravochecker. Then bravochecker would teleport them to the designated starting position for the mission and set to true the "bravohere" variable. Oh and have some intro playing while all this is going about. LoL.

So there.. that should take care of detecting whether the group has been disabled or not. I hope.. Then the end trigger would have to call a script that checks if bravohere has been set to true.

Well... it does seem all too crude.. I hope you could bear with me.. I'm just improvising and not too good with all these scripting stuff and all..  :dunno:

Offline Clayborne

  • Members
  • *
Re: Mission ending & revealing problems
« Reply #10 on: 15 Jun 2009, 18:23:04 »
Well thanks for the replies anyway.

A solution for this would be useful to know (someone must have done this at some point), but for now it so happens I can get around it by using countSide, because all West units rally at the same location at the end. I'm just having a bit of trouble with the syntax. Does anyone know what this should look like?

Basically I have a trigger detecting all West units

westunits = WEST CountSide thisList

and for the rally point trigger it needs to be something like

"_x in (list trigger1)" west countside westunits == west countSide westunits

This doesn't work though. Anyone know what it should be?

EDIT

Okay I found a solution, suggested by Chris Death on the BIS forum. So, in case anyone needs to do this in future:

Put this in the Init.sqs:

group_array = []
"if (alive _x) then {group_array = group_array + [_x]}" foreach [unit1,unit2,unit3...]


Naming each playable unit. Then create your end trigger:

West Present

Condition: "_x in thislist" count group_array == "alive _x" count group_array AND "alive _x" count group_array > 0"

Activation: end1 = 1 or whatever

This acheives the desired effect, i.e. detecting whether or not both groups exist and counting the number of living units from both groups who are present in the trigger.
« Last Edit: 15 Jun 2009, 21:28:47 by Clayborne »