Home   Help Search Login Register  

Author Topic: MP particle script question  (Read 1525 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
MP particle script question
« on: 08 May 2009, 01:30:57 »
Can anyone tell me if this sandstorm script would work well in MP, meaning that all players would experience the same effects?
It works well in editor and is run from the init.sqs

During an intro (introactive) the effects are spawned at other locations than player.
At some map locations (Opteryx's Afghan Village 1.0) the effects around the player seem to "die", but starts again when entering previously visited areas  :dunno: that's why I got uncertain about the MP thing.

You don't want one player to see nothing, while the player right next to him has perfect visibility  :scratch:

Code: [Select]
_particles = [];
if (_this == "sandstorm") then {

_dust1 = "#particlesource" createVehicleLocal getpos uh60wreck; 
_dust2 = "#particlesource" createVehicleLocal getpos campflag; 
_dust3 = "#particlesource" createVehicleLocal getpos vehicle player;
 
_dust1 setParticleRandom [0, [100, 100, 0], [0, 0, 0], 0, 0, [0, 0, 0, 0], 0, 0];
_dust1 setParticleCircle [0.1, [3, 3, 0]];
_dust1 setDropInterval 0.01;

_dust2 setParticleRandom [0, [200, 200, 0], [0, 0, 0], 0, 0, [0, 0, 0, 0], 0, 0];
_dust2 setParticleCircle [0.1, [3, 3, 0]];
_dust2 setDropInterval 0.01;

_dust3 setParticleRandom [0, [200, 200, 0], [0, 0, 0], 0, 0, [0, 0, 0, 0], 0, 0];
_dust3 setParticleCircle [0.1, [3, 3, 0]];
_dust3 setDropInterval 0.01;

while {introactive} do {
_dust1 setParticleParams [["\Ca\Data\Cl_basic.p3d", 1, 0, 1], "", "Billboard", 1, 10, [1, 0, 0], [0,0,0], 5, 0.2, 0.1568, 0.0, [20, 20], [[0.7,0.6,0.5,0.0],[0.7,0.6,0.5,0.2],[0.7,0.6,0.5,0.0]], [0, 1], 1, 0, "", "", uh60wreck];
_dust2 setParticleParams [["\Ca\Data\Cl_basic.p3d", 1, 0, 1], "", "Billboard", 1, 10, [1, 0, 0], [0,0,0], 5, 0.2, 0.1568, 0.0, [20, 20], [[0.7,0.6,0.5,0.0],[0.7,0.6,0.5,0.2],[0.7,0.6,0.5,0.0]], [0, 1], 1, 0, "", "", campflag];
sleep 1;
};

while {true} do {
_dust3 setParticleParams [["\Ca\Data\Cl_basic.p3d", 1, 0, 1], "", "Billboard", 1, 10, [1, 0, 0], [0,0,0], 5, 0.2, 0.1568, 0.0, [20, 20], [[0.7,0.6,0.5,0.0],[0.7,0.6,0.5,0.2],[0.7,0.6,0.5,0.0]], [0, 1], 1, 0, "", "", vehicle player];
sleep 1;
};
};


Thanks in advance you guys  ;)

Laggy
« Last Edit: 08 May 2009, 01:38:33 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 Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: MP particle script question
« Reply #1 on: 08 May 2009, 14:32:58 »
Well, you should be fine if you just create the effect at the location of every player and update it so it stays at the player's location. You don't gain anything by putting it at static locations really. The issue with putting it at the position of the player's vehicle is that that position can be significantly different to that of the player's eye (as you move, the particles will be created at your feet and you'll never see them since you will have moved by the time they have drifted up. You also need to keep it there, so the player can always see it. I'd suggest placing it, and keeping it, just in front of the player's eyes:
Code: (untested) [Select]
_dust = "#particlesource" createVehicleLocal getpos vehicle player;
_dust setParticleParams [["\Ca\Data\Cl_basic.p3d", 1, 0, 1], "", "Billboard", 1, 10, [1, 0, 0], [0,0,0], 5, 0.2, 0.1568, 0.0, [20, 20], [[0.7,0.6,0.5,0.0],[0.7,0.6,0.5,0.2],[0.7,0.6,0.5,0.0]], [0, 1], 1, 0, "", "", nil];
_dust setParticleRandom [0, [100, 100, 0], [0, 0, 0], 0, 0, [0, 0, 0, 0], 0, 0];
_dust setDropInterval 0.01;
waitUntil
{
  _dust setPos positionCameraToWorld [0, 0, 1]; // Place 1m in front of player's eyes, so should cover view entirely.
  false; // Run forever.
};
This method also has the advantage of working if the player is seeing a cut-scene or other camera effect (such as SPON RearView). You may be able to get away with creating particles less often (higher value in setDropInterval) since all the particles will be in the player's view and you wouldn't need to make it as a circle. Probably need to play around with all the parameters in this case to get it looking good though. I'm just pushing you in the direction I would probably go...
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: MP particle script question
« Reply #2 on: 09 May 2009, 00:09:36 »
Thanks a lot Spooner,

Being a hopeless "trial and error" scripter myself, I have to return on this feedback  :whistle:

Laggy

EDIT: This seems to work really well and looks good, Doesn't matter if the player sees a cutscene (far away) or acts as "himself". Don't know what you think of the coding, still spawn a circle of particles, but it works and doesn't seem to cause much lag at all.

Code: [Select]
sleep 1;

if (param2 == 1) then {storm = false};

_particles = [];
if (_this == "sandstorm") then {

_dust = "#particlesource" createVehicleLocal getPos vehicle player;
_dust setParticleRandom [0, [300, 300, 0], [0, 0, 0], 0, 0, [0, 0, 0, 0], 0, 0];
_dust setParticleCircle [0.1, [3, 3, 0]];
_dust setDropInterval 0.01;

while {storm} do
{
_dust setPos positionCameraToWorld [0, 0, 1];
_dust setParticleParams [["\Ca\Data\Cl_basic.p3d", 1, 0, 1], "", "Billboard", 1, 10, [1, 0, 0], [0,0,0], 5, 0.2, 0.1568, 0.0, [20, 20], [[0.7,0.6,0.5,0.0],[0.7,0.6,0.5,0.2],[0.7,0.6,0.5,0.0]], [0, 1], 1, 0, "", "", positionCameraToWorld [0, 0, 1]];
sleep 1;
};
};
« Last Edit: 10 May 2009, 11:01:51 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 Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: MP particle script question
« Reply #3 on: 10 May 2009, 17:22:59 »
You only need to continually use setParticleParams if those params change continually. Since you are using the setPos to ensure that the particles are in front of the player's view, you should be able to get away with pulling that statement before the main loop, as I did.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: MP particle script question
« Reply #4 on: 11 May 2009, 00:33:27 »
Works really well, thank you  :D
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.