Home   Help Search Login Register  

Author Topic: Weird mission ending problem  (Read 1931 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Weird mission ending problem
« on: 22 Feb 2010, 15:48:57 »
Hi all,

EDIT:

In my mission "1-13 Red Mercury" I have just got a beta testing report regarding a weird mission ending bug or design error. You are supposed to disarm a nuclear bomb and if you perform the correct action an end trigger is started.

From mission start a random script (only run on the server) decides on the correct way to disarm the bomb, as in:
Code: [Select]
_number = ceil random 5;

if (_number == 1) then {correctDisarm = "DISCONNECT THE BATTERY"; publicVariable "correctDisarm"};
if (_number == 2) then {correctDisarm = "REMOVE THE EXPLOSIVES"; publicVariable "correctDisarm"};
if (_number == 3) then {correctDisarm = "FLIP THE ARMING SWITCH"; publicVariable "correctDisarm"};
if (_number == 4) then {correctDisarm = "SHORTCIRCUIT THE GENERATOR"; publicVariable correctDisarm"};
if (_number == 5) then {correctDisarm = "DISMANTLE THE TIMER"; publicVariable "correctDisarm"};

In player sided action scripts the performed disarm method is chosen, as in example:
Code: [Select]
nukedisarmer = _this select 0;
publicVariable "nukedisarmer";

disarmPerformed = "DISCONNECT THE BATTERY";
publicVariable disarmPerformed;

In a global trigger I have this condition:
Code: [Select]
! (isNil "nukedisarmer") AND (disarmPerformed == correctDisarm) AND isNil "screwup"

onActivation:
Code: [Select]
hint "Task completed."; tskObj4 setTaskState "SUCCEEDED"; goodend = true; [] exec "winoutro.sqs"

"screwup" is a variable that is set to true if the wrong disarm method is used. Before that it is undefined.

What one tester has told me is that only the disarmer player got the winoutro and mission ending. The other players stayed in game... How is this possible when the winoutro is started through publicVariable command???

I have of course checked this function on a dedicated server myself and this never happened to me, though of course I was the disarmer in that test. Read somewhere that ArmA2 has some kind of "bandwith" limit for custom scripts, could that be the issue or have I missed something really important here?

Finally, I still don't know if JIP could have created a mess for me here, the tester never gave me a thorough description. A also NEVER get any script errors, even though I have -showScriptErrors active.

Would this be safer:
Code: [Select]
! (isNil "nukedisarmer") AND ! (isNil "correctDisarm") AND ! (isNil "disarmPerformed") AND (disarmPerformed == correctDisarm) AND isNil "screwup"

Should I run EVERYTHING via the server that then decides when the mission is accomplished? Don't see why since the publicVariable command from the player action shouldn't really have any weird sync problems... right?

END EDIT

Otherwise I am stumped  :blink:

Laggy
« Last Edit: 23 Feb 2010, 18:08:56 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shuko

  • Members
  • *
Re: Weird mission ending problem
« Reply #1 on: 24 Feb 2010, 18:39:08 »
Why make such complex conditions?

I assume only one player will select the action. Then it either goes boom or mission ends successfully?

So, determine if the action was correct or not in the action script, then pubvar it.

if ("cut something" == correctDisarm) then {
  goodend =  true;
  pubicvariablevar "goodend";
} else {
  badend =  true;
  pubicvariablevar "badend";
};

Then you can just have simple triggers:

cond: goodend
onact: task done, show outro

cond: badend
onact: task fail

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Weird mission ending problem
« Reply #2 on: 28 Feb 2010, 12:10:11 »
Thanks Shuko,

Points taken, however, I need the different variables as I have a lot of sound FX (sideradio and stuff) that depend on them. I might be able to change it slightly, but I honestly don't see why this slightly reduced complexity would make the whole difference between a failing solution and a successful one.

Your solution broadcasts one variable through the script, mine two. They both depend on the correctDisarm variable given by the server.

Not arguing here and I really appreciate your input, I just wonder if the ArmA2 engine is that much pickier than OFP or Armed Assault, because I've never had these problems before. Really frustrating...

Thanks again,

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shuko

  • Members
  • *
Re: Weird mission ending problem
« Reply #3 on: 28 Feb 2010, 13:24:03 »
Well, you can still broadcast the disarmer etc if you need to use them in elsewhere, but it's kind of pointless to check for them in the task condition as the disarm check already does all the work.

Engine is picky, but don't really know if it's changed from OFP. With conditions you have to remember that Arma doesn't support lazy evaluation, so when using AND/ORs you need to make sure all vars are defined etc.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Weird mission ending problem
« Reply #4 on: 28 Feb 2010, 13:48:29 »
Quote
Arma doesn't support lazy evaluation, so when using AND/ORs you need to make sure all vars are defined etc.

I thought the isNil command covered lazy evaluation, but I guess not as much as I would hope. I started using isNil "var" instead of ! var, since the latter solution gives an error if it is not initiated as false.

The thing is, in triggers you can still check for undefined variables without an error report, could that be the problem? In this condition line "disarmPerformed" is undefined from mission start, the var itself does not exist until the action script PV's it.

Code: [Select]
! (isNil "nukedisarmer") AND (disarmPerformed == correctDisarm) AND isNil "screwup"
Would this addition change anything?

Code: [Select]
AND ! (isNil "disarmPerformed")
Thanks a lot Shuko,

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Shuko

  • Members
  • *
Re: Weird mission ending problem
« Reply #5 on: 28 Feb 2010, 21:03:22 »
Well yeah, isnil check should work fine. However, I still don't understand the reason to use them in this case.

Why would you need to check for something like:

"disarmPerformed", when someone uses a disarm action, which pubvars the used choice and/or result of success, that by itself already tells everyone that disarm is performed. Using extra variable is just redundant.

"screwup", same as above; action script already determines success.

"nukedisarmer", not needed for task update condition, but you can pubvar the person using the disarm action so you can use it elsewhere.