Home   Help Search Login Register  

Author Topic: local this && !local that but how about these locals.... NNNYYYAAAGGHHH!!!  (Read 1888 times)

0 Members and 1 Guest are viewing this topic.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Here's the situ:
A vehicle mounted weapon fires a bullet that is captured and deleted, and on the place of it a shell is created.
Now, usually one would make this so that if the vehicle firing the bullet is not local (to the server) the ceating script is not run to avoid multiple creations when more than one player is involved... (right??)

But what confuses me right the f out is the fact that a vehicle is local to it's driver...
So when an AI is the driver the vehicle is local to the server, but when HI is driver the vehicle is local to the driving client... (right??)

So if a simple local server is used to control the shell creation the vehicle's driver won't see any created shells, whereas all the others will see it (most likely)...
If local _vehicle is used then if the driver is HI only the driver will see the created shell...

So, how would one go about making this so that it would work under all those different localities?
Bear in mind that I have no clue about MP related scripting so on that part I'm a total n00b... :P

Maybe I need to do a check on the localities of those created shells and delete those that are not local to the server??
This all would need to happen in a very short fragment of a second though...

The resent 'evolvement' I had when I actually checked the locality of the fired bullet before it was deleted in the units "fired" eventHandler and by doing that the thing now works on dedi server with two players... more than two players and all goes to hell... So that's no good...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline MachoMan

  • Honoured
  • Former Staff
  • ****
  • KISS, Keep it Simple Stupid
camcreating always needs to be done on every machine in the game. Camcreate is local to the person excecuting it. So if only the server does it, no-one except the server will see the shells. Thus there is no need to do your  check.

Get those missions out there you morons!

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Quote
camcreating always needs to be done on every machine in the game. Camcreate is local to the person excecuting it. So if only the server does it, no-one except the server will see the shells

This confuses me...

We are talking about dedi servers right?
In that case U have to exec your script on the server to make sure all clients see it.
? local server:[]exec ".."

When U host your own game on internet then U have a situation where U are server and local player,and then U need to exec all scripts local to make sure they run at all clients.
? local player:[] exec "..."

But why do U catch,delete and Camcreate Hater_Kint?
U could also add any weapon\ammo U want to your vehicle and have no problems at all.
Or did I miss something?

Quote
So, how would one go about making this so that it would work under all those different localities?

Unfortunately there is no Unified method,We use options in the setup screen (Dedi-non dedi)
defined in description.ext (textsParam1[] or 2)

http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Quote
Camcreate is local to the person excecuting it
Ah, I knew I forgot to mention something... ::) I really should sleep at some time :P
I don't use camCreate, I use createVehicle...
And, this is an AddOn-side script so mission 'design elements' can't be used :(

Quote
In that case U have to exec your script on the server to make sure all clients see it.
Yes, this is what I'm come to understand...

So basicly I need a way to get the scripts execute only on the server no matter who is the driver in the vehicle (the owner of the vehicle)...

Quote
But why do U catch,delete and Camcreate Hater_Kint?
;D
This is Project MCAR related...

This for a Jeep that fires a 106mm Recoilless Gun, and as this has hugely simplier scripts that the missile department of MCAR I'm hoping that if this is possible to get working in MP there's a slight change for the missile stuff as well...

But as I find the logic behind all this OFP MP coding as confusing as women's logic, I'm a bit lost... :P ;D
« Last Edit: 16 Dec 2004, 21:01:17 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Maybe use Booleans in init.sqs:

For dedi servers:Dedicatedserver = true

?(local server) and ?(Dedicatedserver):[] exex "..."

For non-dedi:Dedicatedserver = false
?(local player) and ?!(Dedicatedserver):[] exec "..."

(need to test this ;))

I have a MP(dedi) map where I implemented the "catch and delete" ammo trick (Based on EH fired,deletevehicle and nearest object),so I see no big problems to just add another command to it.

Cant wait to shoot a TOW from a Skoda  :P
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Quote
I have a MP(dedi) map where I implemented the "catch and delete" ammo trick (Based on EH fired,deletevehicle and nearest object),so I see no big problems to just add another command to it.

Cant wait to shoot a TOW from a Skoda
Just remember to test it with multiple players... Otherwise it's not valid :P

Hopefully u get it working...
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Korax

  • Guest
Createvehicle does not need to be done on the server, it can be done on any client for the same effect.
For example
_GuyWhoFired = _this select 0
?! Local _GuyWhoFired : Exit
_bullet = "bullet" createvehicle getpos _guyWhoFired
etc...

This way you wont have to worry about more then one person executing the script, and it will still work all the same.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Well, that was the first thing I tried and it does not work properly... (But I'll retry...)
Sure, no multiple creations are made but there's still the poblem for everybody not seeing the 'creation'....

Numerous different approaches have been used and exhausted without any luck... :(
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Here's the desync-free way to do it. I'm assuming that the "shell" that is created is then kept alive until impact and is left to do damage to the target.

First you define two types of "shells" (the ones to be created), one being the shell that does the actual damage, and another dummy shell with the same properties as the real one except that the damage it does is zero. (Meaning hit=0; indirectHit=0; indirectHitRange=0)

Then the fired EH that is to "catch&delete", as Pl. Patton put it, will do one of the following:
  • On the machine where the firer is local, the shell to be created is the real one
  • On the machines where the firer isn't local, the dummy shell is used
  • The shell is then camCreate:d (ie not createVehicle:d) and handed off to the flight dynamics script
What does all of this accomplish? A couple of things:
  • Everyone gets to see the nice missile hurling away
  • No unneccessary and desync-creating traffic is created
  • The real missile will impact on the machine that fired it, doing real damage. Ouch! ;D
  • On all other machines, server or not, the dummy will just impact and go boom, doing no damage
To put it differently: what is it that we don't do and what do we have to do instead?
  • We don't use createVehicle, so we have to camCreate on all machines so everyone can see something flying
  • We don't want the target damaged N times, N being the number of machines involved so we have to use dummy shells with 0 damage as "spoof missiles".
  • We don't create unneccessary network traffic, so the tracking script for the missile has to run on all machines
Pseudo-code for a fired EH using an imaginary "shell" called "MCAR_Wocket" or "MCAR_DummyWocket" depending on which machine the EH runs on
Code: [Select]
_firer=_this select 0
_shelltype="MCAR_Wocket"
?!local _firer: _shelltype="MCAR_DummyWocket"
...
...
_shell=_shelltype camCreate _somePosition
...
... script continues and steers the missile to target
« Last Edit: 20 Dec 2004, 13:12:21 by Killswitch »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Interesting...
This might actually work...

Also, I have never been so clear on the differences between createVehicle and camCreate, some have said createVehicle would be more MP friendly, and some have said it's not...
So I've more or less just figured that no-one actually knows for sure, and went on with createVehicle...

I'll put this one into testing... :P
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Ok, the think Korax suggested seems to work on the Recoilless Gun stuff, so thnx! :cheers:

Only tested on dedi with two players though ::)

I will keep this topic open because I'm pretty sure I will be back on this... :P
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Also, I have never been so clear on the differences between createVehicle and camCreate, some have said createVehicle would be more MP friendly, and some have said it's not...
So I've more or less just figured that no-one actually knows for sure, and went on with createVehicle...
Actually, the difference between createVehicle and camCreate is quite well-known. It boils down to
  • The result of camCreate is local to the machine where it is issued. Ex: creating something that goes boom, for effect.
  • The result of createVehicle will eventually be broadcast to all machines. Ex: creating a Jeep on the server.
As for what's best for a particular situation, well, that depends on the problem at hand. If you need to spawn something that isn't done too often (say, vehicles from a CTI type game factory), createVehicle issued on one node only is yer daddy. For other situations, the use of camCreate can greatly improve the performance in MP. Let's examine that further by a few examples:

Say you have an explosion script that will hurl debris around when a vehicle is destroyed. Best practice is to create said random debris on each client using camCreate. Why? Because using lots of createVehicle calls on one machine only will cause a lot of unneeded network traffic, causing desync. And we don't like desync at all. Good rule of thumb: if something is temporary and mostly for show/effect -> bell should ring: "aha, camCreate time". If you use the drop command, there's a good chance that camCreate should/could be nearby.

In other situations, it's best to centralise control of the newly created object to one node only. Creating new vehicles and or units (using createUnit) is where this applies.

Real-world examples

There are a few very illustrative examples of what happens if you don't use the differences between camCreate and createVehicle wisely. A cautionary note: the addons themselves are otherwise excellent and I love them to bits.

Case 1: multiple createVehicle calls on one machine in MP
Try the Hudson/Pennywise F18 airplane. Gather a few friends for a MP session and let one person fly around in a cluster bomb-equipped F18. The effect is more noticeable the more players you have. Now have the pilot drop one or more cluster bombs and see what happens to your framerate and the desync.... The desync storm that thing creates can take out the internet for miles around :-X.

So what did they do? They use lots of createVehicle calls on one machine to create the many cluster bomb bomlets. Result: lots of network traffic and unhappy MP players.

Case 2: multiple createVehicle calls on all machines in MP

Now try one of Footmunches excellent planes, say the F4 Phantom. This baby has napalm bombs on it. Here's where it gets really nasty the more players you have. Again, have one guy fly the Phantom and ripple off all the napalm canisters. If you haven't experienced negative framerates yet, you're in for a treat ;D

Reason: the napalm effects script will do multiple createVehicle calls on each and every machine in the MP session. Unsurprisingly, this leads to the server and clients choking on traffic and overhead.

In both cases, by reworking the addons/scripts to use camCreate and "dummy shells" where needed greatly improved MP playability without changing the way the addons work and look.

Examples of good MP coding
ATM, I can think of only one example: the War Games League addpack (WGL), currently in version 4.12. Feel free to have a peek at how they did their MP coding for the effects department. In short, this is MP coding done right! Low impact, low desync, proper use of both camCreate and createVehicle.

So, how does this apply to MCAR and MP?
Well, I hope this will help you guys experiment with and use the differences between camCreate and createVehicle to your advantage.

Cheers!
« Last Edit: 22 Dec 2004, 06:22:38 by Killswitch »

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
And all this time I've somehow understood that createVehicle is more MP friendly ::)
Well, you learn something new everyday... :P

Quote
Well, I hope this will help you guys experiment with and use the differences between camCreate and createVehicle to your advantage
You are free (and more than welcome) to join us if you feel like it ;)
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.