Jump to content
Khabal

Discrepancy between editor spawned smoke grenade and script spawned ones

Recommended Posts

Hi all,

First off, I am sorry if this is a known issue or if I am just plain wrong: I am new to scripting. I looked on the web but couldn't find anything about this topic...

 

For context, I am trying to create a permanent smoke grenade from script.

From the editor, it is straightforward: place a "smoke grenade" module and enable "permanent effect".

 

This -if I am not mistaking- changes the variable "repeat" from 0 to 1. Makes sense.

To make sure, I created a smoke grenade module and put "this setVariable ["repeat",1];" in its "init" module. Became permanent.

 

The weird part now is that when I try to set this variable in a script, even though it changes the variable, the grenade pops out of existence after it's normal duration... So I guess this has to be set in the object's "init".

But how do you access this init field since setVehicleInit has been disabled? Or do I get the problem wrong?

 

To create the grenade from script and try to make it permanent:
 

smoke_grenade = "SmokeShellGreen" createVehicle _atPosition;
smoke_grenade setVariable ["repeat", 1];

As a disclaimer, I am aware that there are workarounds involving while loops, I am not interested in a workaround for this problem; I am trying to understand how Arma3 works.

Share this post


Link to post
Share on other sites
Hi all,
First off, I am sorry if this is a known issue or if I am just plain wrong: I am new to scripting. I looked on the web but couldn't find anything about this topic...
 
For context, I am trying to create a permanent smoke grenade from script.
From the editor, it is straightforward: place a "smoke grenade" module and enable "permanent effect".
 
This -if I am not mistaking- changes the variable "repeat" from 0 to 1. Makes sense.
To make sure, I created a smoke grenade module and put "this setVariable ["repeat",1];" in its "init" module. Became permanent.
 
The weird part now is that when I try to set this variable in a script, even though it changes the variable, the grenade pops out of existence after it's normal duration... So I guess this has to be set in the object's "init".
But how do you access this init field since setVehicleInit has been disabled? Or do I get the problem wrong?
 
To create the grenade from script and try to make it permanent:
 
smoke_grenade = "SmokeShellGreen" createVehicle _atPosition;smoke_grenade setVariable ["repeat", 1];

As a disclaimer, I am aware that there are workarounds involving while loops, I am not interested in a workaround for this problem; I am trying to understand how Arma3 works.



The grenade isnt what the repeat cariable is going on I don't think, that's the module. The module will most likely have a script (probably a loop) running to spawn new ones constantly.

That or the script is generating the same smoke particles the grenades use. Dont ask me how =P

Sent from my LG-H870 using Tapatalk

Share this post


Link to post
Share on other sites

The problem is that the type and effect of the module are only evaluated once when the module is placed or activated. Here are my tests:

  1. Placed 2 smoke grenade modules in editor, both non repeatable, smoke1 is yellowsmoke2 is blue.
  2. Test: Just what you expect. The command smoke1 setVariable ["type", "SmokeShellBlue"]; doesn't do anything
  3. Made the modules activated by a trigger
  4. No smoke as long as the trigger isn't triggered
  5. Activated trigger: same as (2.)
  6. Second try: No smoke, trigger not activated
  7. Execute smoke1 setVariable ["type", "SmokeShellBlue"]; 
  8. Activate trigger
  9. Both smokes are BLUE

I guess that this also works for the "repeat" variable, but as I said, the variables are only evaluated once and then passed to a script (which I can't find). Inside this script it might look like this:

_module = _this;
_smokeColor = _module getVariable "type";
// ...
_repeat = _module getVariable "repeat";
// ...

Similiar function from the other smoke module:

Spoiler

/*
	File: fn_moduleEffectsSmoke.sqf
	Author: Borivoj Hlava

	Description:
	Module function. Creates smoke on position of module (called usually by BIS_fnc_moduleEffectsEmitterCreator).

	Parameter(s):
	_this select 0 (Object) - Module logic.
	
	Returned value:
	None.
*/

_logic = _this param [0,objnull,[objnull]];
_emitter = (_logic getVariable "effectEmitter") select 0;
_pos = getPos _logic;
_emitter setPos _pos;

//--- variables set by user
_colorRed = _logic getVariable ["ColorRed",0.5];
_colorGreen = _logic getVariable ["ColorGreen",0.5];
_colorBlue = _logic getVariable ["ColorBlue",0.5];
_colorAlpha = _logic getVariable ["ColorAlpha",0.5];
_timeout = _logic getVariable ["Timeout",0];
_particleLifeTime = _logic getVariable ["ParticleLifeTime",50];
_particleDensity = _logic getVariable ["ParticleDensity",10];
_particleSize = _logic getVariable ["ParticleSize",1];
_particleSpeed = _logic getVariable ["ParticleSpeed",1];
_particleLifting = _logic getVariable ["ParticleLifting",1];
_windEffect = _logic getVariable ["WindEffect",1];
_effectSize = _logic getVariable ["EffectSize",1];
_expansion = _logic getVariable ["Expansion",1];

if (_colorRed > 1) then {_colorRed = 1};
if (_colorRed < 0) then {_colorRed = 0};
if (_colorGreen > 1) then {_colorGreen = 1};
if (_colorGreen < 0) then {_colorGreen = 0};
if (_colorBlue > 1) then {_colorBlue = 1};
if (_colorBlue < 0) then {_colorBlue = 0};


//--- particle effect creation
_emitter setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal_02",8,0,40,1],"","billboard",1,_particleLifeTime,[0,0,0],[0,0,2*_particleSpeed],0,0.05,0.04*_particleLifting,0.05*_windEffect,[1 *_particleSize + 1,1.8 * _particleSize + 15],
		[[0.7*_colorRed,0.7*_colorGreen,0.7*_colorBlue,0.7*_colorAlpha],[0.7*_colorRed,0.7*_colorGreen,0.7*_colorBlue,0.6*_colorAlpha],[0.7*_colorRed,0.7*_colorGreen,0.7*_colorBlue,0.45*_colorAlpha],
		[0.84*_colorRed,0.84*_colorGreen,0.84*_colorBlue,0.28*_colorAlpha],[0.84*_colorRed,0.84*_colorGreen,0.84*_colorBlue,0.16*_colorAlpha],[0.84*_colorRed,0.84*_colorGreen,0.84*_colorBlue,0.09*_colorAlpha],
		[0.84*_colorRed,0.84*_colorGreen,0.84*_colorBlue,0.06*_colorAlpha],[1*_colorRed,1*_colorGreen,1*_colorBlue,0.02*_colorAlpha],[1*_colorRed,1*_colorGreen,1*_colorBlue,0*_colorAlpha]],
		[1,0.55,0.35], 0.1, 0.08*_expansion, "", "", ""];
// ["JmenoModelu"],"NazevAnimace","TypAnimace",RychlostAnimace,DobaZivota,[Pozice],[SilaPohybu],Rotace,Hmotnost,Objem,Rubbing,[Velikost],
// [Barva],[FazeAnimace],PeriodaNahodnehoSmeru,IntensitaNahodnehoSmeru,"OnTimer","PredZnicenim","Objekt";
_emitter setParticleRandom [_particleLifeTime/2, [0.5*_effectSize,0.5*_effectSize,0.2*_effectSize], [0.3,0.3,0.5], 1, 0, [0,0,0,0.06], 0, 0];
						//[lifeTime, position, moveVelocity, rotationVelocity, size, color, randomDirectionPeriod, randomDirectionIntensity] 
_emitter setDropInterval (1/_particleDensity);


//--- timeout
if (_timeout != 0) then {
	[_logic,_timeout] spawn {
		scriptName "fn_moduleEffectsSmoke_timeoutLoop";
		_logic = _this select 0;
		_timeout = _this select 1;
		
		sleep _timeout;
		deleteVehicle ((_logic getVariable "effectEmitter") select 0);
	};
};

 

 

1 hour ago, crazy538 said:

The module will most likely have a script (probably a loop) running to spawn new ones constantly.

I'm not too sure about this. The smoke grenade makes a sound when it drops (even with the module the first time). This isn't the case here. After the first grenade is spawned there is no other sound anymore. Though these are just educated guesses....

Share this post


Link to post
Share on other sites
Just now, Khabal said:

I am trying to create a permanent smoke grenade from script

 

Don't know about the variables, but what if you simply spawned a different type of smoke shell (without a module) ?

"SmokeShellGreen_Infinite" createVehicle _atPosition;

I hope this helps

  • Like 4

Share this post


Link to post
Share on other sites
11 hours ago, Nikander said:

 

Don't know about the variables, but what if you simply spawned a different type of smoke shell (without a module) ?


"SmokeShellGreen_Infinite" createVehicle _atPosition;

I hope this helps

How did you find this solution? o_O

That effectively creates a permanent green smoke grenade, and it's by far the easiest method! =)

 

So, does that mean the module smoke grenade with "permanent effect" creates a "SmokeShellGreen_Infinite" ? It confuses me that you have to rely on a completely new object to make it permanent...

 

Anyhow, thank you guys for your fast and educated answers!

Cheers,

Khab

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

×