Jump to content
Sign in to follow this  
doubledizz

Move marker to thrown position of smoke/chemlight?

Recommended Posts

I want to move my base respawn markers to the position of a defined thrown item, ie: smoke grenade or chemlight.

I thought Game Logic could help for location but I haven't worked out how to pair it to a units items in their inventory. I'm guessing that needs it's own init.sqf?

I'm also unsure if you can even affect a markets location using Game Logic.

Any thoughts?

Share this post


Link to post
Share on other sites

So something like...

player addeventhandler ["fired",{if((_this select 4) == "SmokeShellOrange") then getPos?

and I'm stuck haha. I have no experience in this degree of scriping...

Share this post


Link to post
Share on other sites

I used a hand grenade for testing but you can replace that with whatever you want

player addEventHandler ["Fired",
{
if ((_this select 4) == "GrenadeHand") then
{
	(_this select 6) spawn
	{
		sleep 0.1;
		waitUntil {(speed _this <= 0) || (!alive _this)};
		"myMarker" setMarkerPos (getPos _this);
		hint ("Respawn marker has been moved to " + (str getPos _this));
	};
};
}];

Edited by DreadedEntity

Share this post


Link to post
Share on other sites

player addEventHandler ["Fired",
{
if ((_this select 4) == "SmokeShellOrange") then
{
	_newMrkPos = getPos (_this select 6);
	"markerName1" setMarkerPos _newMrkPos;
	"markerName2" setMarkerPos _newMrkPos;
};
}];

Only issue being that every time the player throws an orange smoke grenade, the markers will reset their positions, so you may want to have a triggered public variable that turns to true when you want the markers to be able to move and then set it false again once the markers have been moved.

i.e.

//in init.sqf
PV_markerMove = false;
publicVariable "PV_markerMove";



//initPlayerLocal.sqf
player addEventHandler ["Fired",
{
if ((PV_markerMove) && {((_this select 4) == "SmokeShellOrange")}) then
{
	_newMrkPos = getPos (_this select 6);
	"markerName1" setMarkerPos _newMrkPos;
	"markerName2" setMarkerPos _newMrkPos;
               PV_markerMove = false;
               publicVariable "PV_markerMove";
};
}];



//some triggered event
//in a trigger's onAct field for example
PV_markerMove = true;
publicVariable "PV_markerMove";

Edited by JShock

Share this post


Link to post
Share on other sites
Only issue being that every time the player throws an orange smoke grenade, the markers will reset their positions, so you may want to have a triggered public variable that turns to true when you want the markers to be able to move and then set it false again once the markers have been moved.

I think it would be a lot easier in this case to just limit the amount of smoke grenades...only squad leaders get orange smoke grenades anyway

Share this post


Link to post
Share on other sites

Oh man. Both of these post made me weep haha. So awesome.

I am running class loadouts on start and respawn, so I am able to limit the orange smokes. But I still love the idea of controlling when it can and can't be done.

My original thought was to attempt a "cooldown" timer. But I think I'll just use the Arma wiki to understand these scripts first and get them running!

Share this post


Link to post
Share on other sites
But I think I'll just use the Arma wiki to understand these scripts first and get them running!

I'm so happy after reading this that I think it might just bring a tear to my eye

One thing that might be pretty cool too is to only add the event handlers to squad leaders so only they can change the marker in the first place, like, even if they die and another unit picks up his smoke and throws it, it won't do anything

Share this post


Link to post
Share on other sites
But I think I'll just use the Arma wiki to understand these scripts first and get them running!

I agree with Dreaded.

Another thing to try is to add the EH to the player once certain conditions are true, then remove it when those conditions are false.

Share this post


Link to post
Share on other sites

OK I'm about halfway through all of "ArmA: Introduction to Scripting" stub's "see also" pages on the BIS wiki. Your scripts are starting to make sense, although i don't think could've written them myself.

One thing is still confusing me though...

How do you know the element to call when writing _this select... ?

I understand _this is a magic variable so _this I think is referring to player object, but I haven't been able to find the player object's array anywhere!?

Is this because it's in the game engine so it doesn't need to be online? Like in the config section or something?

Share this post


Link to post
Share on other sites

All of the _this select's that we are using come from the Event Handler page, which on the right hand column of the row pertaining to each particular event handler (EH) it gives the parameters that the EH uses when running code (the array of variables that the EH defines after said event occurs). They are given in order, so for example the "Fired" EH that we are using here:

unit: Object - Object the event handler is assigned to

weapon: String - Fired weapon

muzzle: String - Muzzle that was used

mode: String - Current mode of the fired weapon

ammo: String - Ammo used

magazine: String - magazine name which was used

projectile: Object - Object of the projectile that was shot (Arma 2: OA and onwards)

unit is passed as (_this select 0) and is referring to the object that the EH is attached to
weapon is passed as (_this select 1) and is the weapon that was used (fired)
muzzle is passed as (_this select 2) and is the muzzle of the weapon used
mode is passed as (_this select 3) and is the firing mode of the weapon used
ammo is passed as (_this select 4) and is the ammo-type used by the weapon
magazine is passed as (_this select 5) and is the magazine that was used
projectile is passed as (_this select 6) and is the actual bullet/grenade/etc that came out

You may want to read up on ARRAYS to understand this concept a bit better.

Edited by JShock
Wording and added some links

Share this post


Link to post
Share on other sites

Thanks JShock.

So I finally got time to work on this. Unfortunately, no luck on either versions.

JShock, newMkrPos I don't think exists anymore, couldn't find it anywhere in the bis wiki... EDIT: I'm a nub, it's a variable. I see it *facepalm*

DreadedEntity, not sure where yours wouldn't work (not sure how to test them in editor. Been running LAN MP missions to test)

player addEventHandler ["Fired",
{
   if ((_this select 4) == "GrenadeHand") then
   {
       (_this select 6) spawn
       {
           sleep 0.1;
           waitUntil {(speed _this <= 0) || (!alive _this)};
           "myMarker" setMarkerPos (getPos _this);
           hint ("Respawn marker has been moved to " + (str getPos _this));
       };
   };
}];  

I was thinking maybe here... waitUntil {(speed _this <= 0) || (!alive _this)};

You're saying wait until nade is still or until not alive. But when is a smoke nade considered used up in the game? Because a frag nade explodes and thats it. Smoke continues to do things for a bit longer.

I'll try it with the nade like you have. But so far, haven't been able to get the markers to move :(

EDIT: what about using createMarker and deleting the marker at the start of the EH? So, delete it and create it again with the same name...?

Edited by doubleDizz

Share this post


Link to post
Share on other sites

Yes, once the smoke grenades "run out" of smoke is when the grenade returns !alive.

And based off another thread that was being worked on yesterday try and use getPosATL instead of just getPos for the grenade object (_this select 6).

Reference:

http://forums.bistudio.com/showthread.php?185787-Getpos-grenade&p=2831493&viewfull=1#post2831493

Edited by JShock

Share this post


Link to post
Share on other sites

Tried with both variations and getposALT returns a blank error. Editor just brings up blank notification with OK button.

I'm using the code in the player unit init box

Share this post


Link to post
Share on other sites
Tried with both variations and getposALT returns a blank error. Editor just brings up blank notification with OK button.

I'm using the code in the player unit init box

I just tested the below code, and it works perfect for me (in unit's init field):

this addEventHandler ["Fired",
{
   if ((_this select 4) isEqualTo "GrenadeHand") then
   {
       _grenadeObj = (_this select 6);
       _moveMarker = [_grenadeObj] spawn
       {
           private ["_grenadePos","_grenadeObj"];
           _grenadeObj = (_this select 0);
           waitUntil { (getPosATL _grenadeObj select 2) < 0.1 };
           _grenadePos = getPosATL _grenadeObj;
           "mrkName" setMarkerPos (_grenadePos);
       };
   };
}];

Share this post


Link to post
Share on other sites

That does work! Rad.

EDIT: B_IRStrobe works!! hell yes!

The marker I've been wanting to move is the DESTINATION marker for ALiVE's Multispawn module. Using the Multispawn module's "Insertion" type sets the respawn via a helicopter, using an INSERTION and DESTINATION marker.

So now I can set the insertion point wherever I want, during a mission! I've only been able to get hand grenade to work though haha. Smoke and IR nades don't trigger the setMarkerPos.

What is "select 2" referring to in the waituntil. I don't understand what a GrenadeHand's muzzle would be?

Share this post


Link to post
Share on other sites
That does work! Rad.

The marker I've been wanting to move is the DESTINATION marker for ALiVE's Multispawn module. Using the Multispawn module's "Insertion" type sets the respawn via a helicopter, using an INSERTION and DESTINATION marker.

So now I can set the insertion point wherever I want, during a mission! I've only been able to get hand grenade to work though haha. Smoke and IR nades don't trigger the setMarkerPos.

Where you see "GrenadeHand" in the code, you change that to whatever the classname is of the grenade/object you want to use for this feature:

SmokeShell (white smoke grenade)
SmokeShellOrange (orange smoke grenade)
SmokeShellGreen (green smoke grenade)
SmokeShellRed (red smoke grenade)
etc.

What is "select 2" referring to in the waituntil. I don't understand what a GrenadeHand's muzzle would be?

"select 2" is referring to the 3rd element of the position array obtained through the getPosATL command, the 3rd element of a position array is the z-axis, or elevation of the object, so basically this line of code is waiting for the grenade to be less than 0.1 meters from the ground before doing anything else, the something else being move the marker.

EDIT: To clarify something I said, you can replace "GrenadeHand" with the ammoType of the fired object (grenade, or whatever), which can be found in the fourth column for an object on the Arma 3 Assets page.

Edited by JShock

Share this post


Link to post
Share on other sites

YES! this thread solved almost all my problems. phew. thanks guys, especially doubleDizz for this thread!

Share this post


Link to post
Share on other sites
YES! this thread solved almost all my problems. phew. thanks guys, especially doubleDizz for this thread!

No problem, good luck

Share this post


Link to post
Share on other sites

Should be posibble with this script do that player (client) throw smoke and dedic server create invisible helipad for heli on the place, where smoke falls. ??

I've tried some things, but I dont know how to get from client, where script run values (coordinates, of fallen smoke).

 

vojak addEventHandler ["Fired",
{  
   if ((_this select 4) isEqualTo "SmokeShellOrange") then {
   kour = (_this select 6);
   pohybhelipad = [kour] spawn {
           kour = (_this select 0);
           waitUntil { (getPosATL kour select 2) < 0.1 };
           pozicekoure = getPosATL kour;
           hint format ["%1", pozicekoure];
   };
   };
}];

 

All I need to know, is how to get numbers from "pozicekoure" to dedic.. where can I work with it.. 

Please help i dont have experience with variables..

 

 

Share this post


Link to post
Share on other sites

Solved, it works fine for me.

 

grp = group heli_evak;

vojak addEventHandler ["Fired",
{  
   if ((_this select 4) isEqualTo "SmokeShellOrange") then {
   kour = (_this select 6);
   pohybhelipad = [kour] spawn {
           kour = (_this select 0);
           waitUntil { (getPosATL kour select 2) < 0.1 };
           pozicekoure = getPosATL kour;
           publicvariable "pozicekoure";
           call test_exec;
   };
   };
}];

test_exec = {
remoteExec ["test",2];
};

test = {
sleep 2;
nadymacek = "Land_HelipadCircle_F" createVehicle pozicekoure;   // need to change for invisible type.. this was for testing
sleep 1;
call boby_kour_evak_exec;
};

boby_kour_evak_exec = {
remoteExec ["boby_kour_evac_fnc",2];
};

boby_kour_evac_fnc = {
_wp1 = grp addWaypoint [pozicekoure, 0];
_wp1 setWaypointStatements ["true", "heli_evak land 'nadymacek'"];
};

heli_evak setvariable ["odletame", true];
heli_evak addaction ["<t color=""#09FF00"">"+"Odletet",{call odlet_exec},nil,1,true,true,"","(_target getvariable ""odletame"")"];

odlet_exec = {
remoteExec ["odlet_fnc",2];
};

odlet_fnc = {
heli_evak setvariable ["odletame", false];
_wp2 = grp addWaypoint [konec, 0];
_wp2 setWaypointStatements ["true", "'END1' call BIS_fnc_endMission"];
};

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  

×