Jump to content
Fastfood4Bigfoot

[SOLVED] eventHandler for opening the parachute

Recommended Posts

Hi,

 

I need help to get this running. I want to call some code on opening the parachute. I didn't found anything matching in the list: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers. I even tried the GetIn-Handlers because the parachute seems to be handled as a vehicle. Any ideas?

 

Thx in advance ;)

Share this post


Link to post
Share on other sites

That's not what I'm searching for. I know how to open the parachute. I want to react with a script on opening the parachute. So when the player uses the default mouse wheel menu entry "open parachute", something should happen.

Share this post


Link to post
Share on other sites

^^^

if (animationState player == "para_pilot") then {
    ("SmokeShell" createVehicle (position player)) attachto [(vehicle  player)];
};

You might want to tweak the offset of that smokeshell, though.

 

ToAQnrs.jpg

  • Like 1

Share this post


Link to post
Share on other sites

Yep, that code works - but I still don't know whats the best way of checking the current state again and again.

player addEventHandler ["AnimChanged", {
    params ["player", "para_pilot"]; hint "hello";
}];

didn't worked. Shall I just use a dumb while-loop?

Share this post


Link to post
Share on other sites

I would think the EH would be preferable, but your example is not how they work. Just spitballing, but it should be something like this I think?

player addEventHandler ["AnimChanged", { 
    if ((_this select 1) == "para_pilot") then {
        ("SmokeShell" createVehicle (position player)) attachto [(vehicle player)];
    }; 
}];

Most probably wrong, but something like that.

I've got work to do, but I'll give it a shot in the morning, unless a smarter person beats me to it.

  • Like 3

Share this post


Link to post
Share on other sites

untested

player addEventHandler ["AnimChanged",
{	
	params ["","_anim"];
	if (_anim isEqualTo "para_pilot") then
	{
		("SmokeShell" createVehicle (position player)) attachto [(vehicle  player)];
	};
}];

AnimChanged EH

 

edit: too late...

Share this post


Link to post
Share on other sites

Nope. Both don't seem to work. Best working code until now is

while {true} do {
	if (animationState player == "para_pilot") then {
    	("SmokeShell" createVehicle (position player)) attachto [(vehicle  player)];
    	};
	sleep 0.1;
};

 

Share this post


Link to post
Share on other sites

Hmm, can´t test it yet...

What about...

player addEventHandler ["AnimChanged",
{	
	params ["","_anim"];
	hint format ["%1",_anim];
}];

...to check anim name?

Share this post


Link to post
Share on other sites
2 minutes ago, Lucullus said:

Hmm, can´t test it yet...

What about...


player addEventHandler ["AnimChanged",
{	
	params ["","_anim"];
	hint format ["%1",_anim];
}];

...to check anim name?

Nothing happens. I don't really understand AnimChanged yet.

Share this post


Link to post
Share on other sites
32 minutes ago, Fastfood4Bigfoot said:

Best working code until now is...

 

Use this instead:

player addEventHandler ["AnimChanged",
{	
	if (animationState player == "para_pilot") then
	{ 
		("SmokeShell" createVehicle (position player)) attachto [(vehicle  player)];
	};
}];

"para_pilot" is an action name, not an anim name.

Share this post


Link to post
Share on other sites
1 hour ago, Harzach said:

You might want to tweak the offset of that smokeshell, though.

:rofl:hahahaha

  • Haha 1

Share this post


Link to post
Share on other sites
12 minutes ago, Lucullus said:

 

Use this instead:


player addEventHandler ["AnimChanged",
{	
	if (animationState player == "para_pilot") then
	{ 
		("SmokeShell" createVehicle (position player)) attachto [(vehicle  player)];
	};
}];

"para_pilot" is an action name, not an anim name.

Nope. Nothing yet.

Share this post


Link to post
Share on other sites

Arma vanilla?

41 minutes ago, Lucullus said:

player addEventHandler ["AnimChanged", { params ["","_anim"]; hint format ["%1",_anim]; }];

^^^ this should give you a continual hint as you move...

Share this post


Link to post
Share on other sites
17 minutes ago, Lucullus said:

Arma vanilla?

^^^ this should give you a continual hint as you move...

No mods, newest version. Nothing on the screen, no hint, no error. When I'm landing and walking on the ground, it prints some letters, like "amovpercmstpsraswrfldnon".

Share this post


Link to post
Share on other sites

Just use the action menu event handler.

inGameUISetEventHandler [ "Action", "
	params[ '', '_caller', '', '_actionName' ];
	
	if ( _actionName == 'OpenParachute' ) then {
		hint format[ '%1 opened their parachute', name _caller ];
	};
"];
  • Like 4

Share this post


Link to post
Share on other sites
1 hour ago, Larrow said:

Just use the action menu event handler.

 

Works perfectly (natch),  but I still want to figure out why the AnimChanged EH won't do anything.

  • Like 1

Share this post


Link to post
Share on other sites

Code works for me, too, but is also creating new problems.

inGameUISetEventHandler [ "Action", " 
    params[ '', '_caller', '', '_actionName' ]; 
     
    if ( _actionName == 'OpenParachute' ) then { 
            ('SmokeShell' createVehicle (position player)) attachto [(vehicle  player)]; 
    }; 
"];

If I'm using the code above, there's the clicking sound of a thrown grenade when I open the parachute. But nothing happens... until I touch the ground - then the grenade immediately starts producing smoke. I don't know at all what's going on there, quite weird...

Share this post


Link to post
Share on other sites

The smoke grenade is being spawned before the parachute exists, I would guess. This works:

inGameUISetEventHandler [ "Action", "
    params[ '', '_caller', '', '_actionName' ];
    
    if ( _actionName == 'OpenParachute' ) then {
        hint format[ '%1 opened their parachute', name _caller ];
        _nul = [_caller] spawn {
            _caller = _this select 0;
            sleep 3;
            ('SmokeShellRed' createVehicle (position _caller)) attachto [(vehicle _caller),[-0.4,0,1.5]];
            ('SmokeShell' createVehicle (position _caller)) attachto [(vehicle _caller),[0,0,1.5]];
            ('SmokeShellBlue' createVehicle (position _caller)) attachto [(vehicle _caller),[0.4,0,1.5]];
        };
    };
"];

2wBJhDj.jpg

  • Like 1

Share this post


Link to post
Share on other sites
inGameUISetEventHandler [ "Action", "
	params[ '', '_caller', '', '_actionName' ];
	
	if ( _actionName == 'OpenParachute' ) then {
		_thread = [ _caller ] spawn {
			params[ '_caller' ];

			waitUntil { vehicle _caller != _caller };
			
			_emitters = [];
			{
				_x params[ '_pos', '_color' ];
				
				//Following borrowed from BI smoke module
				_color params[ '_colorRed', '_colorGreen', '_colorBlue', '_colorAlpha' ];
				
				_emitter = '#particlesource' createVehicle ( vehicle _caller modelToWorldVisual _pos );
				_emitter attachTo [ vehicle _caller, _pos ];
				_nul = _emitters pushback _emitter;
				
				_timeout = 0;
				_particleLifeTime = 50;
				_particleDensity = 10;
				_particleSize = 1;
				_particleSpeed = 1;
				_particleLifting = 1;
				_windEffect = 1;
				_effectSize = 1;
				_expansion = 1;
				
				_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, '', '', ''];
				
				_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];
				_emitter setDropInterval (1/_particleDensity);
			}forEach [
				[ [0,0,1], [ 1, 0, 0, 1 ] ],
				[ [0,0,0], [ 1, 1, 1, 1 ] ],
				[ [0,0,-1], [ 0, 0, 1, 1 ] ]
			];
			
			waitUntil{ vehicle _caller isEqualTo _caller };
			
			{
				deleteVehicle _x;
			}forEach _emitters;
		};
	};
"];

Adjust particles, their position and colors to what ever you desire.

 

EDIT: Added removal of particles once the player has touch down.

  • Like 3

Share this post


Link to post
Share on other sites

@Harzach: Nice offsets for the smoke grenades, although in already saw in videos the smoke grenade to be tied to to a leg:

 

@Larrow: Nice solution, works until the landing - probably I will further improve the smoke grenade with automatically respawning smoke shells. Maybe a little bit too much smoke, thinking about tweaking the parameters.

Share this post


Link to post
Share on other sites
1 hour ago, Fastfood4Bigfoot said:

@Harzach: Nice offsets for the smoke grenades, although in already saw in videos the smoke grenade to be tied to to a leg:

That's what @davidoss was going for in your other topic, but of course, the problem is that we can't attachTo a unit in a parachute. Offsetting a smokeshell down to where the player's foot should be would look even worse, as the player's legs are constantly swinging and moving around, while the smokeshell would stay in the same relative position.

  • 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

×