Jump to content
Sign in to follow this  
epicgoldenwarrior

Getpos grenade

Recommended Posts

Hey guys, just wondering how I can getpos grenade and then create vehicle on top of it?

Working on a "Special Grenades Script" which would include tear gas (working), incendiary (this, tryin to use bis fire effects or createvehicle fire), and poison gas nades, which haven't started yet but I'd also like a strip of code so if player distance SmokeShellGreen > 3 then do DoT so like every 5 seconds takes 20 dmg. If fire does not do damage then I would also need a strip of code like that too.

Share this post


Link to post
Share on other sites

I think your going to have to use a Fired EH, to get the grenade object, then you should be able to getPos and so forth. And the fire does cause damage, or at least the below example does:

fire = "test_EmptyObjectForFireBig" createVehicle position this;

I actually started having inspirations of doing something similar to this, but I wanted to do it to teach myself some about modding and addon creation, particle effects, and the sort, but I'm also really really lazy :p.

EDIT: Just to add some insight to the Fired EH, use (_this select 6) to get the grenade object (for position) and (_this select 4) to get the type of grenade used (so it only does something on SmokeShellGreen, or whatever you use).

EDIT2: Kind of interested in this if you can't tell. Below is an old link from A2OA, you should be able to do an alive check on the grenade object, keep getting an updated position of it to compare that to the closest players.

http://forums.bistudio.com/showthread.php?134958-How-can-I-get-the-exact-position-when-a-grenade-exploded&highlight=position+grenade

Edited by JShock

Share this post


Link to post
Share on other sites
Honestly you were the only one I was going to ask.

Don't know what that's supposed to mean... :p

But what exactly do you need working MP, this should all work MP because the grenade object is global, and any damage done to the player should be local. And createVehicle effects are global as well, so that shouldn't be an issue.

Share this post


Link to post
Share on other sites

Just a small addition. This can be handy within the EH so that it won't trigger anything but grenade stuff:

if (_this select 1 == "THROW") then {MyGrenade = (_this select 6) };

Share this post


Link to post
Share on other sites
Just a small addition. This can be handy within the EH so that it won't trigger anything but grenade stuff:

if (_this select 1 == "THROW") then {MyGrenade = (_this select 6) };

That and you can make it grenade class specific with (_this select 4):

if((_this select 4) == "SmokeShellGreen") blah...

Share this post


Link to post
Share on other sites

Totally forgot about this thread.

Anyway, how would I get that to work with this?

while{true} do {
[getPosATL "SmokeShellOrange","FIRE_SMALL"] call BIS_fn_createFireEffect;} //obviously this doesnt work. THIS IS ZONE.

waituntil{
((nearestObject [getpos player, "SmokeShellOrange"]) distance player < 10) 
and 
(getpos (nearestObject [getpos player, "SmokeShellOrange"]) select 2 < 0.5)
};

sleep 5;

};

So, I'd like to create fire in "ZONE" which is just what I'm calling that line/space.

Also, how would I make it for like, poison gas, so when you walk near it < 10m then you take like, 10dmg/sec until the smoke is over (or deletevehicle)

Yay

Share this post


Link to post
Share on other sites

Ok, just to clarify what your going for, you want to create a fire effect on the position of the orange smoke grenade?

Share this post


Link to post
Share on other sites

Yep. And, we gotta make sure that the fire does damage, I'm not sure if the fire is cosmetic.

Also, I dont want to have only 1 flame if possible, but a few around, so I can kill AI and such.

Also how do I call BIS-whitescreen? :D

Share this post


Link to post
Share on other sites

Try this....halfway psuedo, halfway has a chance:

player addEventHandler ["Fired",
{
if (((_this select 1) isEqualTo "THROW") && {((_this select 4) isEqualTo "SmokeShellOrange")}) then
{
	_grenadeObj = (_this select 6);
	_grenadePos = getPos _grenadeObj;
	_makeFire = [_grenadePos,_grenadeObj] spawn
	{
		private ["_grenadePos","_createdFires"];
		_grenadePos = (_this select 0);
		_grenadeObj = (_this select 1);
		_createdFires = [];
		//below creates anywhere from 2-5 fires in a ~5m radius around the grenade's position
		for "_i" from 0 to (floor(random 4)+2) step 1 do
		{
			_fire = "test_EmptyObjectForFireBig" createVehicle [((_grenadePos select 0) + floor(random(6))),
																((_grenadePos select 1) + floor(random(6)))
																(_grenadePos select 2)];
			_createdFires pushBack _fire;
		};
		//I think the below should work
		waitUntil {isNull _grenadeObj || !alive _grenadeObj};
		{ deleteVehicle _x; } count _createdFires > 0;
	};
};
}];

Also how do I call BIS-whitescreen? :D

I have no idea.

Share this post


Link to post
Share on other sites

Do you know what I mean by whitescreen? :/

Like, with a trigger u can make whitescreen/blackscreen/tv set or wtv. Like that.

Will test right now!

---------- Post added at 21:57 ---------- Previous post was at 21:52 ----------

SITREP: doesnt work :( is _createdfires something?

You may want to look at the BIS createfire thing I used, maybe that would work.

Idk. Still new @ scripting so I'm purely suggestions.

Share this post


Link to post
Share on other sites

Well, the below makes the fires and such, just not the right position:

player addEventHandler ["Fired",
{
if ((_this select 4) isEqualTo "SmokeShellOrange") then
{
	_grenadeObj = (_this select 6);
	_makeFire = [_grenadeObj] spawn
	{
		private ["_grenadePos","_grenadeObj","_createdFires"];
		_grenadeObj = (_this select 0);
		_grenadePos = getPos _grenadeObj;
		_createdFires = [];
		sleep 2;
		for "_i" from 0 to (floor(random 4)+2) step 1 do
		{
			_fire = "test_EmptyObjectForFireBig" createVehicle [((_grenadePos select 0) + floor(random(6))),
																((_grenadePos select 1) + floor(random(6))),
																(_grenadePos select 2)];
			_createdFires pushBack _fire;
			sleep 0.01;
		};
		waitUntil {isNull _grenadeObj || !alive _grenadeObj};
		{ deleteVehicle _x; } count _createdFires > 0;
	};
};
}];

And atm, I'm not quite sure why it's giving that result, it seems that it gets the position of the grenade not too long after it leaves the player's hand but I haven't found any type of "waitUntil" to combat that.

Edited by JShock

Share this post


Link to post
Share on other sites

maybe waitUntil {isTouchingGround _grenadeObj} can help here

AND to make fire manually:

	_colorRed =          0.6;
_colorGreen =        0.5;
_colorBlue =         0.5;
_particleLifeTime =  1;
_particleDensity =   100;
_particleSize =      1;
_particleSpeed =     2;
_effectSize =        1.2;
_orientation =       5.4;
_damage =            1;

//--- FIRE
_emisorFuego = "#particlesource" createVehicle _pos;
_emisorFuego setPosATL _pos;
_emisorFuego setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal",16,10,32], "", "billboard", 1, _particleLifeTime, [0,0,0], [0,0,0.4 * _particleSpeed], 0, 0.0565, 0.05, 0.03, [0.9*_particleSize,0],[[1*_colorRed,1*_colorGreen,1*_colorBlue,-0], 1*_colorRed,1*_colorGreen,1*_colorBlue,-1],1*_colorRed,1*_colorGreen,1*_colorBlue,-1],[1*_colorRed,1*_colorGreen,1*_colorBlue,-1],1*_colorRed,1*_colorGreen,1*_colorBlue,-1],1*_colorRed,1*_colorGreen,1*_colorBlue,0]],[1], 0.01, 0.02, "", "", "",_orientation,false,-1,[[3,3,3,0]]];
_emisorFuego setParticleRandom [_particleLifeTime / 4, [0.15*_effectSize,0.15*_effectSize,0], [0.2,0.2,0], 0.4, 0, [0,0,0,0], 0, 0, 0.2];

if (_damage > 0) then {_emisorFuego setParticleFire [0.6*_damage, 0.25*_damage, 0.1];};
_emisorFuego setDropInterval (1/_particleDensity);

//--- FIRE LIGHT
_lightSize = (_particleSize + _effectSize)/2;

_light = createVehicle ["#lightpoint", (getPos _emisorFuego), [], 0, "CAN_COLLIDE"];
_light setPos [_pos select 0,_pos select 1,(_pos select 2) + 0.5];
_light setLightBrightness 1.0;
_light setLightColor [1,0.65,0.4];
_light setLightAmbient [0.15,0.05,0];
_light setLightIntensity (50 + 400*_lightSize);
_light setLightAttenuation [0,0,0,1];
_light setLightDayLight false;

Edited by KoVValsky

Share this post


Link to post
Share on other sites
maybe waitUntil {isTouchingGround _grenadeObj} can help here

Tried that and the code never gets past that waitUntil block, same goes for checking the grenade's velocity. And isTouchingGround can be unpredictable at times when it is the only condition.

Share this post


Link to post
Share on other sites

Ok.. and waitUntil {(((getPosATL _grenadeObj) select 2) < 0.1 or something?)?

player addEventHandler ["Fired",
{
   if ((_this select 4) isEqualTo "SmokeShellOrange") then
   {
       _grenadeObj = (_this select 6);
       _makeFire = [_grenadeObj] spawn
       {
           private ["_grenadePos","_grenadeObj","_createdFires"];

           // FOR TESTING ONLY, BUT IT WORKS -----------
		while {((getPosATL (_this select 0))select 2)> 0.1} Do 
		{
			hint format ["%1",(getPosATL (_this select 0))select 2];
			sleep 0.1;
		};
           // ---------------------------------------------
           _grenadeObj = (_this select 0);
           _grenadePos = getPos _grenadeObj;
           _createdFires = [];
           sleep 2;
           for "_i" from 0 to (floor(random 4)+2) step 1 do
           {
               _fire = "test_EmptyObjectForFireBig" createVehicle [((_grenadePos select 0) + floor(random(6))),
                                                                   ((_grenadePos select 1) + floor(random(6))),
                                                                   (_grenadePos select 2)];
               _createdFires pushBack _fire;
               sleep 0.01;
           };
           waitUntil {isNull _grenadeObj || !alive _grenadeObj};
           { deleteVehicle _x; } count _createdFires > 0;
       };
   };
}];  

Edited by KoVValsky

Share this post


Link to post
Share on other sites
Ok.. and waitUntil {(((getPosATL _grenadeObj) select 2) < 0.1 or something?)?

Yep, that seems to do the trick:

player addEventHandler ["Fired",
{
   if ((_this select 4) isEqualTo "SmokeShellOrange") then
   {
       _grenadeObj = (_this select 6);
       _makeFire = [_grenadeObj] spawn
       {
           private ["_grenadePos","_grenadeObj"];
           _grenadeObj = (_this select 0);
		waitUntil { (getPosATL _grenadeObj select 2) < 0.1 };
		_grenadePos = getPosATL _grenadeObj;
           sleep 1;
           for "_i" from 0 to (floor(random 4)+2) step 1 do
           {
               _fire = "test_EmptyObjectForFireBig" createVehicle [((_grenadePos select 0) + floor(random(6))),
                                                                   ((_grenadePos select 1) + floor(random(6))),
                                                                   (_grenadePos select 2)];
               sleep 0.01;
           };
       };
   };
}];  

Edited by JShock

Share this post


Link to post
Share on other sites

Will check in 5 min or so...I assume I am checking the most recent comment?

Also how would I add a line of code that says _unit distance grenade < 5 and loop damage?

For another nade. :D xD

Share this post


Link to post
Share on other sites

Well, below is pseudo code to hell, but it's a basic concept brainstorm :p:

while {alive _grenadeObj} do
{
if (alive player && {player distance _grenadeObj < 5}) then
{
	player setDamage ((getDamage player) + 0.1);
};

if (isNull player || !alive player) exitWith{};

sleep 1;//however fast you want damage to be applied
};

Share this post


Link to post
Share on other sites

Also how do I call BIS-whitescreen? :D

For an instant change, you could use ppEffectCreate. But that can only be created and removed instantly plus it's pretty complicated as you can do a lot with post process effects.

Your way to go is probably this:

0 cutText ["", "WHITE OUT", 0.01];
sleep 3;
0 cutText ["", "WHITE IN", 10];

That way, the player is blind for 3 seconds and will slowly regain his view.

Info: For the "WHITE OUT" line, you have to set a value > 0.001 as anything below that (including 0) will result in the default value (1) to be used.

Share this post


Link to post
Share on other sites

Will try em tomorrow or so, busy, but code seems good. Plan on maybe using this for my Tier-1 missions (check first one out on workshop!) but yea.

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  

×