Forum Jump :

Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#1 Posted at 2012-09-08 02:50        
     
Well, I would like to spawn IEDs all over the map in editor. Easiest and fastest way I can do this is by creating markers on the map named "IED", "IED_1", etc. then in the init of the marker, command it to run a script
_handle = this execVM "IED_trigger.sqf";

Contents of IED_trigger:

_trg1 = createTrigger["EmptyDetector", getMarkerPos "[[IED] and [IED_1] and [IED_2] and [IED_3] and [IED_4] and [IED_5] and [IED_6] and [IED_7] and [IED_8] and [IED_9] and [IED_10] and [IED_11] and [IED_12] and [IED_13] and [IED_14] and [IED_15] and [IED_16] and [IED_17] and [IED_18] and [IED_19 and [IED_20] and [IED_21] and [IED_22] and [IED_23] and [IED_24] and [IED_25] and [IED_26] and [IED_27]]"; //keep adding number IED_X until all markers are present.
_trg1 setTriggerArea[15,15,0,false];
_trg1 setTriggerActivation["WEST","PRESENT",false];
_trg1 setTriggerStatements["this","nul=[this] execVM 'IED.sqf';"];

exit

and then in the IED script, spawn an explosion, probably "bomb="M_Sidewinder_AA";".
Only problem is, I'm new to scripting, and I don't know how to spawn a bomb at the position of the object, in which this script is ran (using execVM).

I know there are IED scripts out there, but I'm stubborn and I want to learn :D


Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#2 Posted at 2012-09-08 06:01        
     
bomb = "Sh_105_HE" createVehicle getpos IED;

If you wanted it in that script you'd use:

_site = _this select 0;
bomb = "Sh_105_HE" createVehicle getpos _site;


Advertisement


Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#3 Posted at 2012-09-08 18:19        
     
# Pirin :
bomb = "Sh_105_HE" createVehicle getpos IED;

If you wanted it in that script you'd use:

_site = _this select 0;
bomb = "Sh_105_HE" createVehicle getpos _site;

Could you explain what
_this select 0;
does?

And thanks very much, kind sir :)


Author Message

palyarmerc  

I live inside the editor


Posts: 753
Rank:


Level: Member

Country: uk
Location:
Occupation: *Retired from ArmA*
Age:
In-game name: Paly

 
#4 Posted at 2012-09-08 20:13        
     
(just 'cos I'm online at the same time as you jaydotosh )

An array is defined by the contents therein
array = []
array = ["zero","one","two","three"]
thus
_this select 4 would be "three"

Added 55 minutes later:

Why dont you just use the ied script
nul=execVM "ied.sqf";
(grabbed from mission -- Kill'emAll[co10].ProvingGrounds_PMC)


This post was edited by palyarmerc (2012-09-08 21:09, ago)

....that's all folks....!

Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#5 Posted at 2012-09-08 21:30        
     
Yup, additional to what palyarmerc said the array _this is special. It's what is being fed to the script.

So you're calling your script like this:

nul=[this] execVM 'IED.sqf';

The [this] in your code there refers to the object that script is being called from, in this case it would be the trigger actually, which is probably not what you wanted. You'd probably want to use:

nul=[IED1] execVM 'IED.sqf';

Then inside the IED.sqf script _this would be the array of [IED1] while _this select 0 would be the object IED1.

So when you did _site = _this select 0; then getPos _site what you'd be doing is getting the object of the IED itself and it's location and creating a bomb there.

Make sense?

Another example for this would be to allow you to have different size explosions:

IED.sqf:
_site = _this select 0;
_bombType = if (count _this > 1) then {_this select 1} else {"Sh_105_HE"};
bomb = _bombType createVehicle getpos _site;

By adding the line seeing if the array _this is larger than 1 element we can override the default medium sized explosion with whatever round we wanted.

Script call for default 105mm arty round IED at the location of IED2:

nul=[IED2] execVM 'IED.sqf';

Script call for an optional larger sized explosion at the location of IED4:

nul=[IED4, "Bo_GBU12_LGB"] execVM 'IED.sqf';

This post was edited by Pirin (2012-09-08 21:45, ago)


Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#6 Posted at 2012-09-08 22:43        
     
# Pirin : Yup, additional to what palyarmerc said the array _this is special. It's what is being fed to the script.

So you're calling your script like this:

nul=[this] execVM 'IED.sqf';

The [this] in your code there refers to the object that script is being called from, in this case it would be the trigger actually, which is probably not what you wanted. You'd probably want to use:

nul=[IED1] execVM 'IED.sqf';

Then inside the IED.sqf script _this would be the array of [IED1] while _this select 0 would be the object IED1.

So when you did _site = _this select 0; then getPos _site what you'd be doing is getting the object of the IED itself and it's location and creating a bomb there.

Make sense?

Another example for this would be to allow you to have different size explosions:

IED.sqf:
_site = _this select 0;
_bombType = if (count _this > 1) then {_this select 1} else {"Sh_105_HE"};
bomb = _bombType createVehicle getpos _site;

By adding the line seeing if the array _this is larger than 1 element we can override the default medium sized explosion with whatever round we wanted.

Script call for default 105mm arty round IED at the location of IED2:

nul=[IED2] execVM 'IED.sqf';

Script call for an optional larger sized explosion at the location of IED4:

nul=[IED4, "Bo_GBU12_LGB"] execVM 'IED.sqf';

Makes sense, thanks! Oh, and just out of curiosity, did you learn arma 2 scripting via experience with other languages, or by simply reading Mr. Murray's book?

Added 34 minutes later:

WTF now for some reason my init.sqf isn't working. And yes, it is an SQF file, and not a txt file:

[player,0.2,0,3,true] execVM "cly_heal.sqf"
server execVM "revive_init.sqf";

enableSaving [false, false];

execVM "briefing.sqf";

player setVariable ["BIS_noCoreConversations", true];
if(true_ exitWith {};

Am I doing something wrong?

This post was edited by jaydotosh (2012-09-08 23:18, ago)


Author Message


Posts: 1484
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2012-09-08 23:26        
     
if(true_ exitWith {};
should be
if (true) exitwith {};


Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#8 Posted at 2012-09-09 00:01        
     
# F2kSel : if(true_ exitWith {};
should be
if (true) exitwith {};

Didn't work.


Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#9 Posted at 2012-09-09 01:26        
     
It's SQF, you don't need that kind of exit thing at all, get rid of it. :)


Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#10 Posted at 2012-09-10 15:17        
     
# Pirin : It's SQF, you don't need that kind of exit thing at all, get rid of it. :)

Should I initiate this script from my init file via execVM?


Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#11 Posted at 2012-09-10 17:39        
     
# jaydotosh : Should I initiate this script from my init file via execVM?

All I was really saying is that the "if true exit" thing has no use in SQF and you can remove that one line from your script. SQF files will exit on their own.

Your script was failing because you were missing a character from that line, but you didn't need it anyway. :) Everything else looks OK.


Author Message


Posts: 27
Rank:


Level: Member

Country: uk
Location: South West England
Occupation: PHP Ninja
Age:
In-game name: TacticalExplosive

 
#12 Posted at 2012-09-10 21:10        
     
# Pirin : All I was really saying is that the "if true exit" thing has no use in SQF and you can remove that one line from your script. SQF files will exit on their own.

Your script was failing because you were missing a character from that line, but you didn't need it anyway. :) Everything else looks OK.

No, I mean should I start the whole IED script in general within the init file?


Author Message

Pirin  



Posts: 1547
Rank:


Level: Member

Country: us
Location: Atlanta, GA
Occupation: IT
Age: 43
In-game name: kylania

 
#13 Posted at 2012-09-10 21:17        
     
Nope, the IED.sqf is a script that just creates a bomb, so it's something you want only the server to do and only when one gets triggered, so keep it separate.






Tags: How, Ied, Script, Scripting