OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: SafetyCatch on 10 Jun 2009, 13:30:53

Title: Setpos Getpos in MP
Post by: SafetyCatch 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
Title: Re: Setpos Getpos in MP
Post by: Spooner 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
Title: Re: Setpos Getpos in MP
Post by: SafetyCatch 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?
Title: Re: Setpos Getpos in MP
Post by: Knight Trane 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 (http://www.ofpec.com/tutorials/index.php?action=show&id=44&page=14)
The Locality of Objects (http://www.ofpec.com/tutorials/index.php?action=show&id=44&page=10)
and of course the entire tut.  Definitely worth the read.
Overview (http://www.ofpec.com/tutorials/index.php?action=show&id=44&page=9)


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 (http://www.ofpec.com/ed_depot/index.php?action=details&id=524&game=ArmA)


Title: Re: Setpos Getpos in MP
Post by: SafetyCatch 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. :)