Jump to content
HazJ

[SOLVED] Detecting when a throwable has landed (after being thrown)

Recommended Posts

Hi,

So I am looking for a way to detect when a throwable (chemlight/smoke) has landed after it has been thrown. I use the FiredMan event handler to detect when it has been thrown but it triggers before it has landed (settled position). I have created a flashbang (still work in progress) but with that I use HandleDamage (removed damage received from grenade, etc) since it actually explodes so I use that for grenades. I assume this won't work for chemlights/smokes since they don't damage you. I want to create some different grenades types that don't deal damage by default.

Tried to check speed of projectile. Tried to check isNull on projectile. Neither worked.

  • Like 1

Share this post


Link to post
Share on other sites

Check the magnitude of the projectiles velocity.

player addEventHandler [ "FiredMan", {
	_nul = _this spawn {
		params[
			"_unit",
			"_weapon",
			"_muzzle",
			"_mode",
			"_ammo",
			"_magazine",
			"_projectile",
			"_vehicle"
		];
		
		waitUntil{ vectorMagnitude velocity _projectile < 0.02 };
		hint "stopped";
		
	};
}];

 

  • Like 3

Share this post


Link to post
Share on other sites

Thank you Larrow. Was thinking that but only tried "speed" which failed. Thanks again! Just one question: Why 0.02? Any specific reason? Will say 0 fail? Just leeway?

Share this post


Link to post
Share on other sites

No particular reason for 0.02. Velocity is in meters per second, so that would equate to 2cm a second which is pretty slow. Just thought it would be enough to count as stopped.

Not sure about 0 it depends when an objects physics is deemed low enough for the engine to perceive it as stopped. Which it must do at some point else the game would grind to a halt calculating tiny tiny values for all the physics objects laying around.

  • Like 3

Share this post


Link to post
Share on other sites

Hey @HazJ, that flash bang looks pretty awesome.  You probably know this already, but I thought I would point out that @phronk has a flashbang also in his Realism scripts.  Maybe you guys want to compare and share to produce the ultimate flash bang.

  • Like 2

Share this post


Link to post
Share on other sites

@johnnyboy - It is very basic at the moment, just created a working WIP version. I still need to modify the pp effect and stuff, as well as fade out game volume while flashed. I need to ditch playSound since that is affected by fadeSound command as well. I have a few things to try to get it working though. Wasn't aware of @phronk's version. Mine is for my upcoming project, I don't really use any ready-to-go third party stuff. I am happy to share some snippets with @phronk if he needs them.

  • Like 2

Share this post


Link to post
Share on other sites

Hi HazJ.  I'm working on a Bang Stick script at the moment.  When unit strikes with the bang stick I want a nice small explosion effect.  I like the one in your flash bang video in first post.  Do you have that script?  All I want is the fast fire/explosion effect.  I don't need the white flash or ear ringing.  I'm terrible at figuring out particle effects, so I'm hoping to re-use some someone else has built.

 

Do you have that effects script?  Can I use it?  Please advise.  Thanks.

Share this post


Link to post
Share on other sites

I gave up on it as couldn't figure out lineIntersectsXXX commands. I didn't want the flash to affect players who were close but weren't looking in the general direction. There is no fire effect? I think that is the ChromAberration you are seeing. Only the effects from ppEffect command, here:

	0 = ["ColorCorrections", 1500, [0.5, 0.5, 0, [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]] spawn
	{
		params ["_name", "_priority", "_effect", "_handle1"];
		_handle1 = ppEffectCreate [_name, _priority];
		_handle1 ppEffectEnable true;
		_handle1 ppEffectAdjust _effect;
		_handle1 ppEffectCommit 1.35;
		waitUntil {ppEffectCommitted _handle1};
		uiSleep 3;
		_handle1 ppEffectEnable false;
		ppEffectDestroy _handle1;
	};
	0 = ["ChromAberration", 200, [1, 1, true]] spawn
	{
		params ["_name", "_priority", "_effect", "_handle2"];
		_handle2 = ppEffectCreate [_name, _priority];
		_handle2 ppEffectEnable true;
		_handle2 ppEffectAdjust _effect;
		_handle2 ppEffectCommit 0.5;
		waitUntil {ppEffectCommitted _handle2};
		uiSleep 3;
		_handle2 ppEffectEnable false;
		ppEffectDestroy _handle2;
	};

I think I got this off the Wiki and modified it. Can't remember.

  • Thanks 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

×