Jump to content
Sign in to follow this  
kocrachon

Create On Smoke Toss and Empty Vehicle?

Recommended Posts

So I am trying to create a mission where you toss a smoke grenade, and where that smoke grenade lands it creates an actual H helipad. How do I make it to where an object is created on a tossed object?

I am also trying to use this same feature for when I toss a C4 from the ACE2 mode, it will create an invisible H which will be the activation for an explosion trigger.

So my goal is, how do I toss an "item" and have a vehicle/building created where that "item" lands.

Next up, how do I run a check for if something gets in the driver seat of a car? I dont want to test for specific people to get in that car, I want a check that says, if ANYONE gets inside the driver seat of the car, it activates the trigger.

Share this post


Link to post
Share on other sites

I made a script where you throw a green smoke and a c130 flies over the smoke position.

In order to get the smoke grenade's position I had to call a script whenever the player (or whatever unit) throws a SmokeShellGreen or whatever. I used the

http://community.bistudio.com/wiki/addEventHandler

http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers

object addEventHandler [type, command] 

method to look for the "Fired" event. In the fired event, you can get what type of ammo was fired. If you check that it was a smokeshell or whatever, you can run a script that has

_smokeShell = getPos _unit nearestObject "SmokeShellGreen";
sleep 15;
_smokeShellPos = getPos _smokeShell;

Or something similar to get the position of the smoke shell 15 seconds after the player throws it.

From there you could do createVehicle with an invisible H or whatever on that position.

With regards to checking if someone gets into the vehicle, that would also be accomplished with an event handler on the vehicle.

http://community.bistudio.com/wiki/ArmA_2:_Event_Handlers#GetIn

Edited by xPaveway

Share this post


Link to post
Share on other sites

Ah sweet, so it looks like event handlers are my key to all of this, thanks for the info.

so my question now is, how do I make it to where its when ever "anyone" does it. I understand the object addeventhandler blah blah, but how do I make it to where when anyone does it and not just a specific person?

---------- Post added at 07:28 AM ---------- Previous post was at 07:07 AM ----------

edit

Ok, so I am not quite sure how to set this eventhandler fired.

is it

Soldier1 addeventhandler [Fired[smokeShellGreen]]

---------- Post added at 07:50 AM ---------- Previous post was at 07:28 AM ----------

sorry for yet another post, here is my sample script. It doesn't seem to work though..

_ammotype = _this select 4;

? _ammotype iskindof "SmokeShellGreen": goto "smokeg";

exit;


#smokeg

hint format["Ammo type just fired is %1",_ammotype]; 


_smokeg = nearestObject [player, _ammotype];

~4

_heli = "HeliHCivil" createVehicle (getPos _smokeg select 0, getPos _smokeg select 1, getPos _smokeg select 2);


exit;

and my init is

this addEventHandler ["fired", {_this exec "smokeg.sqf"}]; this addMagazine "SmokeShellGreen";

I get the hint that says ""Ammo type just fired smokeshellgreen" but the vehicle/ helipad isn't created.

Edited by HavocDemon

Share this post


Link to post
Share on other sites

I don't know about creating a vehicle but you could always created the vehicle in the editor and use the setpos to move it to where you want.

Share this post


Link to post
Share on other sites

Id rather not due that, due to some of the vehicles and equipment I want to create later, not to mention if I wanted to create an unlimited amount for each time they throw one, IE

Every time they throw a green smoke it creates a heli pad for the UH-60 AI to detect when it brings them a medic. So I wanted to have the old ones stay and have the new ones created. Which would mean an individual script for each one.

---------- Post added at 06:00 PM ---------- Previous post was at 05:40 PM ----------

EDIT:

So I have this script which works once, but after I use it once, it will always create the H in the same spot, not where my new smokes land.

_ammotype = _this select 4;

? _ammotype iskindof "SmokeShellGreen": goto "smokeg";

exit;


#smokeg

hint format["Ammo type just fired is %1",_ammotype]; 


_smokeg = nearestObject [player, _ammotype];

~4

_marker = createMarker ["_Marker", (getpos _smokeg)];
_markers setMarkerShape "ICON";
"_Marker" setMarkerType "empty";

_asloc = getMarkerPos "_Marker";

_heli = "HeliHRescue" createVehicle _asloc;
_heli setpos _asloc;

exit;

Share this post


Link to post
Share on other sites

try this


_ammotype = _this select 4;

? _ammotype iskindof "SmokeShellGreen": goto "smokeg";

exit;


#smokeg

hint format["Ammo type just fired is %1",_ammotype]; 


_smokeg = nearestObject [player, _ammotype];

~4

_pos = position _smokeg;

_heli = "HeliHRescue" createVehicle _pos;
_heli setpos _pos;

exit;

Share this post


Link to post
Share on other sites

For adding the handler you'd do this

soldier addEventHandler ["Fired", "_this exec 'yourScript.sqf'"] 

Where in yourScript.sqf you have the

_ammotype = _this select 4;

Because the "Fired" event passes an array of: [unit, weapon, muzzle, mode, ammo]. Since you are selecting index 4 of the array (ammo), _ammotype will be a string with the ammo name.

To check that it's a smoke grenade you'd check that with

if (_ammotype == "SmokeShell") then {
//do your code like create vehicle or whatever
}

List of possible ammotype strings: http://community.bistudio.com/wiki/ArmA_2:_Weapons

Also: why are you using exit and stuff? are you writing .sqs scripts? I'd recommend .sqf, it's at least somewhat more like a scripting language. Also I'd recomment using an if block rather than the question mark stuff

Edited by xPaveway

Share this post


Link to post
Share on other sites

Also: why are you using exit and stuff? are you writing .sqs scripts? I'd recommend .sqf, it's at least somewhat more like a scripting language. Also I'd recommend using an if block rather than the question mark stuff

Well, it is an SQF, but I put the exit; there because I was told that every time you fire, it will load that script, and this prevents it from being held forever in the memory.

Share this post


Link to post
Share on other sites
Well, it is an SQF, but I put the exit; there because I was told that every time you fire, it will load that script, and this prevents it from being held forever in the memory.

It's an SQS.

SQF is executed with execVM and it doesn't use goto's, the conditions are also done differently.

EDIT: To further clarify, SQF is a syntax style, not an extension. Extension can be anything, it is just a (logical) standard to use .sqf.

Edited by Deadfast

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  

×