Jump to content
Sign in to follow this  
super-truite

meteors, spawn/call and MP compatibility

Recommended Posts

I am making a meteor rain script. Basically I create a small object and I make it move server side and then I need on each client to spawn some particle effects on the object to make the trail (if the particle effect is spawn server side, no one sees it).

So, since it is a piece of code I need to use a lot (several meteors flying at the same time), I precompile the particle effect code in the init.sqf and I execute it using spawn.

The issue I am facing is that it works...sometimes...

One meteor has his smoke trail while the next one could not have it...

I am not reaching the particle limit as in SP, with a more brutal code, I can see every trails simultaneously, so I am guessing it is a problem with my use of spawn.

The potential issue I see is that the preprocessed script is used simultaneously by a bunch of meteors.

Any ideas?

Code:

meteor creation:

if(isServer)  then {

sleep 2;
_target = _this select 0;
_pos = getpos _target;
_x0 = _pos select 0;
_y0 = _pos select 1;


while {true} do {

_target = _this select 0;


_r = random 5000;
_theta = random 360;
_z= 500+(random 1000);
_pos1 = [_x0+_r*(Cos _theta),_y0 + _r*(Sin _theta),_z];
_object = "Land_Bucket_F" createVehicle _pos1;
_object setpos _pos1;


_fly = [_object] execVM "flight.sqf";


sleep 0.5;
};


};

meteor trajectory (flight.sqf):

_object = _this select 0;
_vx =100+ random 10;
_vy =100+random 10;
_vz=-(50+random 10);

_particles = [_object] spawn trail_precompiled; // in the init.sqf:  trail_precompiled =compile preprocessFileLineNumbers "trail.sqf";

while {((getpos _object) select 2) >5} do

{

_object setvelocity [_vx,_vy,_vz];
sleep 0.01;

};

_explosion = "HelicopterExploBig"  createvehicle (getpos _object);
sleep 1;
deletevehicle _object;

Particle effect (trail.sqf):

_object = _this select 0;

_li = "#lightpoint" createVehicle getpos _object;
_li setLightBrightness 0.5;
_li setLightAmbient[1,1,1];
_li setLightColor[1, 1, 1];
_li lightAttachObject [_object, [0,0,0.1]];

_ps1 = "#particlesource" createVehicle getpos _object;
_ps1 setParticleCircle [0, [0, 0, 0]];
_ps1 setParticleRandom [0, [0.1, 0.1, 0], [0.2, 0.2, 0.4], 0.3, 0.25, [0, 0, 0, 0.1], 0, 0];
_ps1 setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 8,0], "", "Billboard", 1, 10, [0, 0, 0], [0, 0, 0.5], 0, 10.1, 7.9, 0.01, [2, 2, 2], [[0,0,0,-4], [0,0,0,-4], [0,0,0,-2],[0,0,0,0]], [0.125], 1, 0, "", "", _object];
_ps1 setDropInterval 0.001;

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×