Jump to content
Sign in to follow this  
[aps]gnat

Terminate not actually stopping them

Recommended Posts

Any idea why these scripts don't actually seem to terminate.

I get the message once the vehicle is dead, but the FX scripts are still working / running ! crazy_o.gif

CommonInit.sqs

Quote[/b] ]

_plane = _this select 0

[_plane] execVM "\myPlane\scr\FX.sqf";

FX.sqf

Quote[/b] ]

_veh = (_this select 0);

Private ["_script1","_script2","_script3","_script4"];

_script1 = _veh execVM "\myplane\scr\Afterburner.sqf";

_script2 = _veh execVM "\myplane\scr\SonicBoom.sqf";

_script3 = _veh execVM "\myplane\scr\WingtipTrails.sqf";

_script4 = _veh execVM "\myplane\scr\FuselageVapour.sqf"];

waituntil {(!(alive _veh))};

terminate _script1;

terminate _script2;

terminate _script3;

terminate _script4;

Hint "Fx has been terminated";

Share this post


Link to post
Share on other sites

I'm assuming that the hint is displayed, meaning that the problem isn't you condition there.

Just a stab in the dark here, but knowing arma, I have a feeling that perhaps terminate doesn't like to exit certain loops? Like maybe it'll exit a while loop, but not a waituntil loop.

Anyways, why not just use the same condition to exit the scripts from within them, you are passing the vehicle anyways.

Also, I know it's popular, but that is not how the private command is meant to be used. It's unnecessary and redundant. Private has to do with variable scope. All those variables are local to the script anyways. See the comments on the Biki section for private variablenamelist for detail.

Share this post


Link to post
Share on other sites

[APS]Gnat I would check those FX scripts. Do they start other scripts that may not be terminating?

ColonelSandersLite I've been thinking the same thing about the private command. I've started seeing it used in scripts that do not return anything and I was wondering if they knew something I didn't.

--Ben

Share this post


Link to post
Share on other sites

Thx Col. Sanders

The other loops are;

Quote[/b] ]while {true} do {

So maybe theres the problem. These are un-terminatable maybe !

As you say, probably best if I move the condition to the actual scripts.

PublicV noted, cheers.

@Ben

No, no other scripts called from those. Thx

Share this post


Link to post
Share on other sites

Well .... this is getting WEIRD ... ! crazy_o.gif

Quote[/b] ]while {(alive _this)} do {

Wont terminate when its burning!

Even tried;

Quote[/b] ]_plane = _this;

while {(alive _plane)} do {

And still it won't terminate.

... and yes, "_this" is correct and functioning, because its used everywhere else in the script.

Share this post


Link to post
Share on other sites
Quote[/b] ]Wont terminate when its rurning!

I just knocked up a simple test with two scripts running. They both terminated without any problems.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_Unit=_This Select 0;

_Script1=_Unit ExecVM "Script1.sqs";

_Script2=_Unit ExecVM "Script2.sqs";

WaitUntil {!(Alive _Unit)};

Hint "Here";

Terminate _Script1;

Terminate _Script2;

Script1.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">WaitUntil

{

Player SideCHat Format ["Time %1 %2",_This,Time];

Sleep 1;

False

};

Script2.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">While {True} Do

{

Player SideCHat Format ["Time 2 %1 %2",_This,Time];

Sleep 1;

};

Using either WaitUntil or While.

But then there is no sensible reason why WaitUntil or While should work any different with the terminate command.

Share this post


Link to post
Share on other sites

Thanks UNN

I did some more testing and its telling me they are terminated sad_o.gif

..... so that can only mean I do not understand how setParticleParams and similar work ... because these scripts still provide visual effect AFTER they are terminated crazy_o.gif

My research will have to take another avenue.

Example script that still provides visual effects after termination.

Quote[/b] ]

// ---------------------

// FX scripts by Lethal

// ---------------------

private ["_MaxIntensity","_Boost","_leftengine","_rightengine&q

uot;,"_emitters","_Intensity","_looptime", "_plane"];

_MaxIntensity = 2;

_Boost = 0.4;

_Intensity = 0;

_this setvariable ["afterburner",false];

_maxspeed = 1300;

_plane = _this;

_leftengine = "#particlesource" createVehicle position _this;

_rightengine = "#particlesource" createVehicle position _this;

_emitters = [_leftengine,_rightengine];

{_x setParticleRandom [0.05,[0.05,0.05,0.05],[0.05,0.05,0.05],0,0.8,[0.1,0.1,0.1,0],0,0]} foreach _emitters;

{_x setDropInterval 0} foreach _emitters;

_looptime = 0.1;

while {(alive _plane)} do {

if ((isengineon _this) and ((_this animationPhase "ExhaustUp") > 0.99) and ((_this animationPhase "ABSwitch") > 0.5)) then

{

if (_Intensity < _MaxIntensity) then {_Intensity = _Intensity + 0.1*(10*_looptime)};

if ((speed _this) < _maxspeed) then {_this setVelocity [(velocity _this select 0)+((vectordir _this) select 0)*((_Boost*_Intensity/2)*(10*_looptime)),(velocity _this select 1)+((vectordir _this) select 1)*((_Boost*_Intensity/2)*(10*_looptime)),(velocity _this select 2)+((vectordir _this) select 2)*((_Boost*_Intensity/2)*(10*_looptime))]};

if (fuel _this > 0) then {_this setFuel ((fuel _this)-((1/1200)*(3*_looptime)))};

}

else {if (_Intensity > 0) then {_Intensity = _Intensity - 0.2*(10*_looptime)}};

_leftengine setParticleParams ["\Ca\data\cl_exp","","Billboard",1,0.07,[-1.2,-8.9,-1.0],[(velocity _this select 0) - ((vectordir _this) select 0)*30,(velocity _this select 1) - ((vectordir _this) select 1)*30,(velocity _this select 2) - ((vectordir _this) select 2)*30],1,1.2745,1,0,[0.6+(2*(speed _this/_maxspeed)),0.5+(10*(speed _this/_maxspeed))],[[0.040,0.100,0.900,0.1500*_Intensity],[0.200,0.200,0.800,0.1000*_Intensity],

[0.500,0.200,0.000,0.0250*_Intensity],[0.000,0.000,0.000,0.0000*_Intensity]],[0],0,0,&quot

;","",_this];

_rightengine setParticleParams ["\Ca\data\cl_exp","","Billboard",1,0.07,[1.2,-8.9,-1.0],[(velocity _this select 0) - ((vectordir _this) select 0)*30,(velocity _this select 1) - ((vectordir _this) select 1)*30,(velocity _this select 2) - ((vectordir _this) select 2)*30],1,1.2745,1,0,[0.6+(2*(speed _this/_maxspeed)),0.5+(10*(speed _this/_maxspeed))],[[0.040,0.100,0.900,0.1500*_Intensity],[0.200,0.200,0.800,0.1000*_Intensity],

[0.500,0.200,0.000,0.0250*_Intensity],[0.000,0.000,0.000,0.0000*_Intensity]],[0],0,0,&quot

;","",_this];

{_x setpos (getpos _this)} foreach _emitters;

if (_Intensity > 0) then {{_x setDropInterval 0.001} foreach _emitters} else {{_x setDropInterval 0} foreach _emitters};

_looptime = time;

sleep 0.05; // mod by Crowe

_looptime = time - _looptime;

};

Share this post


Link to post
Share on other sites
Quote[/b] ]so that can only mean I do not understand how setParticleParams and similar work

I know what you mean. I think it's changed a lot since OFP. Not had much experience with particles in Arma myself, so I was still thinking along the lines of the previous OFP examples, when I tried it.

What happens if you DeleteVehicle the particle source? I can see where you were comming from. It's better to concentrate the end conditions for multiple scripts, into one line of code with the terminate command. But I guess it's just not practicle with particles.

Share this post


Link to post
Share on other sites

Reading fast through that (forum mangled) script I didn't see you destroying the particlesources you have created.

That's the easiest way to make them stop 'effecting'..

EDIT:

Too slow.. icon_rolleyes.gif

Share this post


Link to post
Share on other sites

Yeh, thanks guys.

Simple as it is, this is enough to get rid of the effects.

Quote[/b] ]deleteVehicle _leftengine;

deleteVehicle _rightengine;

But yes, using an external "terminate" would not work .....

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  

×