Jump to content
Sign in to follow this  
smacker909

get position of smokeshellgreen

Recommended Posts

Im trying to get position to place a marker, for smoke thrown.. I have tried and searched, still trying and searching..any help will be appreciated! :D

Share this post


Link to post
Share on other sites

something like this using fired eventhandlers, tested.

_idx = player [url="http://community.bistudio.com/wiki/addEventHandler"]addEventHandler [/url]["Fired", {
if ((_this select 5) != "SmokeShellGreen") exitWith {};
_null = (_this select 6) spawn {
	_pos = getPos _this;
	sleep 1;
	while {(_pos distance (getPos _this)) > 0} do {
                       _pos = getPos _this;
		"myMarkerName" setMarkerPos _pos;
		sleep 1;
	};
};
}];

just be aware that you should remove the eventhandler if there is a time where the player should be able to throw smokes without marker moving...

edit: corrected while loop, it did not end due to missing line, now it does.

Edited by Demonized
added missing line in while loop, to make loop actually end..

Share this post


Link to post
Share on other sites

Thanks guys. Testing now.. :)

---------- Post added at 04:21 PM ---------- Previous post was at 03:42 PM ----------

Ok, worked like a charm.. using the example Kylania pointed out. Demonized, what would be the advantage of using the eventhandler method, I'm noob, so haven't gotten into that yet. Thanks!

hint "Chopper on the way";

_chopper = chopper2;
_chopper setCombatMode "blue";
_chopper setBehaviour "CARELESS";


// move to player
_chopper doMove (position player);
_chopper flyInHeight 65;

while {!unitReady _chopper} do {sleep 1};

//_chopper doMove (position player);
hint "Throw smoke!";

_smokeCnt = 0;

while {_smokeCnt == 0} do {
  _smokeArray = ((position player) nearObjects["SmokeShellGreen",50]);
  _smokeCnt = count _smokeArray;
  if (_smokeCnt > 0) then {
       _smoke = _smokeArray select 0;
       _smokePos = position _smoke;
       _lz = "HeliHEmpty" createVehicle (position _smoke);
      };
sleep 1;
};

hint "Landing.. get in!";
_chopper land "GET IN";

Share this post


Link to post
Share on other sites

the eventhandler grabs the EXACT grenade you threw, Kylania's grabs any green smoke grenade within 50 meters of yourself then selects the closest one.

The eventhandler is more accurate and reliable tbh.

Share this post


Link to post
Share on other sites

gotit. Thanks I guess in this case, the chopper pilot whouldn't know who threw the smoke... only to look for smoke. So in this case, i think I'm ok with what I have. Thanks again for the help.

Edited by smacker909

Share this post


Link to post
Share on other sites

the eventhandler just automatically runs when you use a weapon, for example what unit throws wich smoke grenade.

so you dont have to have a script "watching" the area around the player for "smokegrenades".

however there is after some thought, many different issues that arise using eventhandler wich needs to be considered or accounted for, and for a new scripter kylanias way would be the best choise for easy control.

in this case a eventhandler is probably just making the easy more difficult.

your script posted above looks like the best approach for your purpose, since you look for smoke near player so the possibility of wrong grenades would be small or insignificant.

edit: did not see last posts before posting...

Edited by Demonized

Share this post


Link to post
Share on other sites

That makes good sense Demonized. Thanks for the explanation. I'm soaking up as much as I can :D

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  

×