Results 1 to 8 of 8

Thread: get position of smokeshellgreen

  1. #1

    get position of smokeshellgreen

    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!

  2. #2

  3. #3
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    something like this using fired eventhandlers, tested.
    Code:
    _idx = player addEventHandler ["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.
    Last edited by Demonized; Aug 2 2011 at 17:48. Reason: added missing line in while loop, to make loop actually end..
    My scripts:
    Spoiler:

    what to do when posting any kind of code dammit!!

    Any new mission editor or scripter in Arma2 should have read Mr Murrays Editing Guide Deluxe at least once, it still applies for A2 even though it was made for Armed Assault.

  4. #4
    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!


    Code:
    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";

  5. #5
    Second Lieutenant GossamerSolid's Avatar
    Join Date
    Feb 3 2006
    Location
    Ontario, Canada
    Posts
    4,052
    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.

    Missions/Gamemodes - F.U.B.A.R. (WIP)
    Mods/Addons - Green Sea Conflict (WIP)
    Resources - ArmA 3 Notepad++ Syntax Highlighting
    PC - i5 3570K | Gigabyte GTX 680 OC | 16GB DDR3

  6. #6
    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.
    Last edited by smacker909; Aug 2 2011 at 17:40.

  7. #7
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    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...
    Last edited by Demonized; Aug 2 2011 at 17:49.

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •