Jump to content
Sign in to follow this  
Fuzzy Bandit

Dynamically Created Artillery

Recommended Posts

Hello!

Working on dynamically-created laser-guided artillery. So far the laser-guided part works, but the dynamically-created part evidentially doesn't. No bombs come a-flyin'!

I can successfully call in artillery by calling the script below from an action when my laser is pointed at something using an "Artillery" and "Virtual Artillery" module placed in the editor. Want I want to do, however, is create the artillery modules dynamically, so the script will work anywhere on the map.

Script I'm using is posted below. _myLaserTarget is the location of my laser-dot, and man1 is the person with the action to call in the artillery and (in this test case) the man carrying the laser.

My question: What's wrong with it?

arty.sqf

_myLaserTarget = [man1] call getMyLaserTarget;
if(not isNull _myLaserTarget) then {
   artilleryuse = artilleryuse + 1; 
   if (artilleryuse == 1) then {
	sleep random 5;
	[west,"HQ"] sideChat "Confirm Laser. Target acquired and adjusting aim. Call us again when you're ready to fire."}; 
   if (artilleryuse == 2) then {
	artyspawn1 = "BIS_ARTY_Logic" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3500, getPos man1 select 2];
	vartyspawn1 = "BIS_ARTY_Virtual_Artillery" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3505, getPos man1 select 2];
	artyspawn1 synchronizeObjectsAdd [vartyspawn1];
	[vartyspawn1] call BIS_ARTY_F_initVehicle;
	sleep random 5;
	[artyspawn1, getposASL _myLaserTarget, ["IMMEDIATE", "LASER", 0, 1]] call BIS_ARTY_F_ExecuteTemplateMission; 
	[west,"HQ"] sideChat "Round one away! Splash ETA 1 minute. Stand by and keep the target designated."};
   if (artilleryuse == 3) then {
	deleteVehicle artyspawn1;
	deleteVehicle vartyspawn1;
	sleep random 5;
	[west,"HQ"] sideChat "Confirm Laser. Target acquired and adjusting aim. Call us again when you're ready to fire."};
   if (artilleryuse == 4) then {
	artyspawn2 = "BIS_ARTY_Logic" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3500, getPos man1 select 2];
	vartyspawn2 = "BIS_ARTY_Virtual_Artillery" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3505, getPos man1 select 2];
	artyspawn2 synchronizeObjectsAdd [vartyspawn2];
	[vartyspawn2] call BIS_ARTY_F_initVehicle;
	sleep random 5;
	[artyspawn2, getposASL _myLaserTarget, ["IMMEDIATE", "LASER", 0, 1]] call BIS_ARTY_F_ExecuteTemplateMission; 
	[west,"HQ"] sideChat "Round two away! Splash ETA 1 minute. Keep target designated and stand by. One more round left!";};
if (artilleryuse == 5) then {
	deleteVehicle artyspawn2;
	deleteVehicle vartyspawn2;
	sleep random 5;
	[west,"HQ"] sideChat "Confirm Laser. Target acquired and adjusting aim. Call us again when you're ready to fire."};
if (artilleryuse == 6) then {
	artyspawn3 = "BIS_ARTY_Logic" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3500, getPos man1 select 2];
	vartyspawn3 = "BIS_ARTY_Virtual_Artillery" createVehicle [getPos man1 select 0, (getPos man1 select 1)+3505, getPos man1 select 2];
	artyspawn3 synchronizeObjectsAdd [vartyspawn3];
	[vartyspawn3] call BIS_ARTY_F_initVehicle;
	sleep random 5;
	[artyspawn3, getposASL _myLaserTarget, ["IMMEDIATE", "LASER", 0, 1]] call BIS_ARTY_F_ExecuteTemplateMission; 
	[west,"HQ"] sideChat "Round three away! Splash ETA 1 minute. Keep target designated and stand by. Bingo on ammo.";
	man1 removeAction 0;
	sleep 60;
	deleteVehicle artyspawn3;
	deleteVehicle vartyspawn3;};
} else {
sleep random 5;
[west,"HQ"] sideChat "Negative on that request. No Laser Target found."; hint "Check your batteries are loaded, or try a different spot!";
if ((isNull _myLaserTarget) AND (artilleryuse == 1)) then {
	artilleryuse = artilleryuse - 1;
};
if ((isNull _myLaserTarget) AND (artilleryuse == 3)) then {
	artilleryuse = artilleryuse - 1;
};
if ((isNull _myLaserTarget) AND (artilleryuse == 5)) then {
	artilleryuse = artilleryuse - 1;
};
};

Share this post


Link to post
Share on other sites

If this is 'off-map' arty, why not skip the guns and spawn missiles in flight?

Share this post


Link to post
Share on other sites

Well that sounds like an awesome idea. And how exactly would I do such a thing? :D

Anyways, why isn't my script working? Am I doing something painfully wrong?

EDIT: Just read that to create the ARTY Logic I MUST use createUnit as opposed to createVehicle.

Will try this when I get the chance.

Edited by Fuzzy Bandit
Reading...

Share this post


Link to post
Share on other sites

createVehicle them. I suppose you'd then just add vector and velocity, or just spawn them at the target after a delay. I avoid modules, as they tend to be unreliable and unoptimized. Making your own, for instance, won't go over a hundredth of the size of the arty module, without worrying about respawn and the like.

But it's just a suggestion. I won't try to sway you away from the module - that's a fine way to go, too.

Share this post


Link to post
Share on other sites

And what exactly would I use to add vector and velocity to the shell?

Currently, I know how to do:

(Can't remember ARTY shell classname off by heart, so using GBU12 classname instead)

bomb1 = "Bo_GBU12_LGB" createVehicle [getPos _myLaserTarget select 0, getPos _myLaserTarget select 1, (getPos _myLaserTarget select 2)+300];

As far as I know, that should create a GBU12 300m in the air above _myLaserTarget.

Can't find anywhere that defines vector and velocity though!

EDIT

I don't think I want to do this. The whole point of the laser-guided rounds is that the Artillery Battery targets it, locks on and fires, meaning that you could follow a moving tank with the laser as the round was going through the air, and it would follow your laser and hit bang on, like a laser-guided GBU12 from an A-10. I'd MUCH prefer to use a virtual artillery battery, and doing so also enables easier customisation (e.g. Round type, timing, number of rounds).

So if I changed the code from 'createVehicle' to 'createUnit', would that work?

"BIS_ARTY_Logic" createunit [(getPos man1 select 0, (getPos man1 select 1)+3500, getPos man1 select 2),alpha,"artyspawn1=this"];
"BIS_ARTY_Virtual_Artillery" createunit [(getPos man1 select 0, (getPos man1 select 1)+3505, getPos man1 select 2),alpha,"vartyspawn1=this"];
artyspawn1 synchronizeObjectsAdd [vartyspawn1];
[vartyspawn1] call BIS_ARTY_F_initVehicle;

Would this actually work? I'm typing this without any testing - not sure if the code would fail or not, as I'm not totally sure how I can contain all of the position within the array, 'cause it's an array inside an array!

Edited by Fuzzy Bandit

Share this post


Link to post
Share on other sites

I'm currently toying with spawning artillery rounds or missiles near target, but for some reason i'm not getting it to work. I have:

- A trigger activated by radio command

- A marker where I want missiles to be spawned from, simulating a ship or helicopter

This code in trigger activation field:

missile = "Bo_GBU12_LGB" createVehicle (getMarkerPos M);

Where M is marker name. Currently LGB classname is used for testing purposes, will be changed to hellfire or some other. However nothing happens when I click radio command. I've also assigned a text message which is sent when this trigger is activated, and that part works, but the bomb is not spawned for some reason. This code is basically same as in BIKI, but what am I missing here?

Share this post


Link to post
Share on other sites
what am I missing here?

All you need is to slightly change your code. First off you don't need the brackets, and if it's a marker you need to put speech marks around it.

missile = "Bo_GBU12_LGB" createVehicle getMarkerPos "M";

That should work.

It will basically, however, create a huge explosion at the marker "M", as opposed to artillery rounds / hellfires (or whatever you want) coming in from a certain direction using vectors and velocity.

Share this post


Link to post
Share on other sites

Thanks, that worked. It was weird because I've used similar script before and it worked then. I am planning to use spawning marker further away from target and spawning laser guided missiles from there, instead of just dropping them over target. Something like in main campaign where you got to destroy a building and a couple of tanks with laser designator and missile call.

Share this post


Link to post
Share on other sites

If you're planning on doing that, I think you'll want to spawn the marker in the air so that the missiles spawn there too.

I think you can do that in the initialisation line of the marker:

this setPos [getPos this select 0, getPos this select 1, (getPos this select 2)+200];

That should spawn whatever it is 200m in the air... I think.

On second thoughts, do markers even have initialisation boxes? If not, use an invisible helipad and don't use speechmarks when defining it to call in the bomb.

Share this post


Link to post
Share on other sites

You can do it like this:

missile = "Bo_GBU12_LGB" createVehicle [getMarkerPos "M" select 0, getMarkerPos "M" select 1, (getMarkerPos "M" select 2)+250];

It will directly spawn the bomb 250m over the marker. As far as I know markers are always at zero height.

Share this post


Link to post
Share on other sites

Fair enough - my brain's not in gear for simple logic today! :P

Still need someone in here to help explain how to add vector and velocity to the things!

Share this post


Link to post
Share on other sites

setVelocity, setdir

Biki has a good example of the first. Just been playing with it myself - pretty funny watching the massive missile slowly arc down at danger close. Remember to take gravity into account as well. Just add some lines to keep it readjusting to laser target and she's right to go. And then someone will come along and tell you how the module works :p

Share this post


Link to post
Share on other sites

I won't pretend to be an expert, but in reference to the first post.

This is how I created the module dynamically, found somewhere on here posted by somebody brighter than me, and it does work.

_LogicCenter = createCenter sideLogic;
_LogicGroup = createGroup _LogicCenter;
"BIS_ARTY_Logic" createUnit [[0,0,0], _LogicGroup, "art1 = this;"];

Where art1 is it's name.

Also are you using ACE2, that caught me out with the latest update where they had created their own arty module, and ment that the orig as above would no longer work. Meaning you would need to find and sub the ACE modules class name insitu of the bis version.

P.s. Cheers Xeno for the quick headsup to my mistake with the ace version if you read this.

Share this post


Link to post
Share on other sites
Also are you using ACE2, that caught me out with the latest update where they had created their own arty module, and ment that the orig as above would no longer work. Meaning you would need to find and sub the ACE modules class name insitu of the bis version.

You've got to be kidding me! I played my mission through with a few friends yesterday evening, and the artillery (the main bit) didn't work! It was so embarrassing, and it had worked before I updated ACE - I just didn't think about that!

Thanks for the code - I'll try it out.

Share this post


Link to post
Share on other sites
Wow I didn't know ACE had arty?!

Yeh, unfortunately they added it in an update on the 3rd. Damn them! :P

Share this post


Link to post
Share on other sites

Hm, BIS ARTY module should work fine again when you use the latest ACE update, or better at least 1.1 stable, if not please create a ticket at dev-heaven with a repro mission.

I've checked it with a M252 battery synced to the BIS ARTY module when fixing it and it was ok.

Btw...

Place a battery in the editor, synced to an ACE Artillery module, name the module for example bat1

Then in a script do the following...

ace_sys_bi_arty_DLG_Batteries = [bat1];
[] spawn ace_sys_bi_arty_fnc_ArtyRequest;

Execute the script from an action or whatever you like (it's a client script).

You can also set the time that the artillery battery has to wait between two missions with:

ace_sys_bi_arty_DLG_TimeBetweenMissions = x; (x = seconds, default is 0)

and the number of rounds with:

ace_sys_bi_arty_DLG_Rounds = [1,2,3,4,5,6,7,10,100,200,500000000]; (array, default is [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,25,30,60,120,240,300])

Place those vars in init.sqf for example.

Xeno

Edited by Xeno

Share this post


Link to post
Share on other sites

Does this script work for multiple Arti-Batteries as well? How would the script look like?

Is there any possibility, maybe to ask if the first Battery is still "reloading" and using another Battery instead? Im not sure about the syntax and the possibilites of ACE ...

Share this post


Link to post
Share on other sites
Does this script work for multiple Arti-Batteries as well? How would the script look like?

ace_sys_bi_arty_DLG_Batteries = [bat1,bat2,bat3,bat4,bat5,bat6,bat7,batxxx,M252Bat,M119Bat,Whatevernameyougaveabattery];
[] spawn ace_sys_bi_arty_fnc_ArtyRequest;

Xeno

Share this post


Link to post
Share on other sites

thx, hoped that it works that way :)

still i had a problem with the script ...

I have a Battery, ACE Module (u dont mean virtual one dont u? or maybe both?) and i put the Variables into the Init.sqf

ace_sys_bi_arty_DLG_TimeBetweenMissions = [300];
ace_sys_bi_arty_DLG_Rounds = [25,50,75,100];

Then i created another SQF file and put this in there:

ace_sys_bi_arty_DLG_Batteries = [bat1,bat2,bat3,bat4];
[] spawn ace_sys_bi_arty_fnc_ArtyRequest;

Then i tried to call this script with an Actionmenu at some Computer with this

nul = this addAction ["Artillerieschlag", "functions\arti.sqf"];

Works fine till i actually wait for the shells to drop at a certain location ...

I suppose my method of calling the script is wrong, or im missing an Array/String whatever after the addAction, dunno :(

Share this post


Link to post
Share on other sites

Xeno (or anyone else that knows the answer), that's all fine, but how would I get that to spawn dynamically, say 3.5km north of my current position?

What I'm aiming to do (as said in the first post) is spawn virtual artillery dynamically wherever I am on the map. My code's posted on the first post. What would I need to change to make it all work?

Cheers

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  

×