Home   Help Search Login Register  

Author Topic: Setpos Getpos in MP  (Read 2059 times)

0 Members and 1 Guest are viewing this topic.

Offline SafetyCatch

  • Members
  • *
  • War...it's fantastic!
Setpos Getpos in MP
« on: 10 Jun 2009, 13:30:53 »
Hi guys,

I'm currently working on a MP mission which uses a setpos getpos command that is vital to the progress of the mission. However, being ArmA MP, the results are highly unpredictable.

The mission is a Blackhawk down style of mission. I wanted a cinematic feel to the crash, so I made a Blackhawk "wreck" move to the position of where the actual Heli crashed. (Looking forward to ArmA2 where this won't be necessary). Anyway, here is a snippet from the script:

Code: [Select]
~10
heliwreck setpos getpos heli
~1
deletevehicle heli

As you can see there's a delay so that the wreck is moved before the destroyed heli is deleted.

The problem here is that not everyone can see the heli wreck when it is eventually found. During a game a team of 5 was present and only 2 could see the wreck, not including the host. On a second time playing the mission, no one could see the wreck at all, only the dead pilots on the ground.

So my question to the community is, as "setpos getpos" is far too unreliable for multiplayer ArmA, what is the alternative?

Thanks guys! :)

Safety

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Setpos Getpos in MP
« Reply #1 on: 10 Jun 2009, 14:31:02 »
I can promise you that getPos/setPos are not unpredictable in MP, but that doesn't mean that general MP scripting is easy if you don't understand its more complex behaviour ;)

Assumption: heli and heliwreck are objects placed in the editor, rather than dynamically created. The script is run from the KILLED handler on the helo.

I suspect the issue is to do with the locality of the heli and heliwreck. When flown, the heli is local to the pilot. When destroyed, it will slowly "move" to being local to the server. Thus, I'd expect the behaviour to be erratic, based on whether the pilot was a host or client and/or the network bandwidth.
Code: [Select]
; Only try to do anything at all on the server (host in your case)
? not isServer : exit
~ 10
; Wait until the destroyed heli has reverted to existing on the server before trying to replace it.
@local heli
heliwreck setPos (getPos heli)
deleteVehicle heli
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline SafetyCatch

  • Members
  • *
  • War...it's fantastic!
Re: Setpos Getpos in MP
« Reply #2 on: 10 Jun 2009, 14:46:07 »
Wow thanks Spooner I'll try that out, but what exactly does the ? not isServer : exit part do? Just to let you know the pilot and heli is all AI controlled, no clients/hosts involved.


EDIT: Quick question, on the same mission some AV-8Bs are moved using setpos getpos to a gamelogic off the ground for them to provide a scripted bombing run (also using gamelogics) as they pass over a trigger.

The problem is sometimes the AV-8Bs are double spawned, including the bombs, causing massive overkill. I'm guessing this is caused by the same desync issues. Can this be solved in the same way?
« Last Edit: 10 Jun 2009, 15:00:51 by SafetyCatch »

Offline Knight Trane

  • Members
  • *
Re: Setpos Getpos in MP
« Reply #3 on: 10 Jun 2009, 16:10:17 »
Quote from: SafetyCatch
but what exactly does the ? not isServer : exit part do?

It's a "check".  It's a line of code that checks if the script is running on a server.  As opposed to a Client machine.  So read the code as:  "IF this machine is not a server then exit without action."

Checkout these topics in the OFPEC MP Tutitorial
Determining whether the script is running on a client or the server
The Locality of Objects
and of course the entire tut.  Definitely worth the read.
Overview


Quote from: SafetyCatch
Quick question, on the same mission some AV-8Bs are moved using setpos getpos to a gamelogic off the ground for them to provide a scripted bombing run (also using gamelogics) as they pass over a trigger.

Same issue.   Different cause.  Your troopers are walking into a trigger that then starts a bomb run by the AV8Bs?  Well the trigger is tripped on the client and the server at almost the same time.  But, no quite.  So you get multiple instances of the script running.  

If you want Bomb action in your mission check out
Mando Bombs and Mando Air Support



« Last Edit: 10 Jun 2009, 16:31:20 by Knight Trane »

Offline SafetyCatch

  • Members
  • *
  • War...it's fantastic!
Re: Setpos Getpos in MP
« Reply #4 on: 10 Jun 2009, 17:56:28 »
Well sort of. Destroying a AAA site (ammo crates and SAM launcher) starts the AV-8Bs off, then they trip a marker for the bomb to be spawned. As this mission has quite a few scripts moving units and objects, can the ? not isServer : exit command be applied to fix all the problems?

Thanks for the help guys. :)
« Last Edit: 10 Jun 2009, 17:59:15 by SafetyCatch »