Jump to content
Mynock

Ambient Artillery Battery Script

Recommended Posts

I wrote this script with the purpose of having AI controlled artillery pieces continually fire rounds without lowering the main cannon to re-adjust their aim each time. I figured I'd share it with the community so that others might benefit. It can be useful for a fire base to add ambience, an objective to destroy an enemy artillery piece firing on imaginary friendlies far away, at a firing range to make it look like the AI is practicing, or any other idea you can come up with where this would be useful.

This script is not designed for accurate AI artillery fire; do not try and use it for this purpose. There are other scripts out there that handle this. If you want to make this work on a mortar be sure you see below** for instructions!

The script is run on an artillery unit and forces the unit to aim at an object (a marker will not work, I will explain why below*) with a set barrel angle and fire continuously until the loop is canceled, either by destroying the unit itself, or deleting/destroying the object that is the target. Other parameters include the ability to delete the projectile after it is fired so it never impacts the ground anywhere, have the unit be set as captive, have the unit auto reload when it runs out of shells/rockets, and have a minimum and random delay time between shots if desired.

You are free to modify this for personal use within your own mission to achieve your desired effect, but please do not redistribute a modified version publically as it will make it harder for me to keep track of and potentially liable.

The only limitation is you may not use or distribute this script on any monetized platform. No exceptions without written consent from myself.

Google Drive Link: Mynock's Ambient Artillery Battery Script v1.0

 

Sorry my mic is so garbage :(

Extensive documentation is provided within the script including all parameter default values, what changing the parameters will do, etc. It should provide you with a very easy to follow guide to get it to work how you want.

Special thanks to: kydoimos, Radioman, kylania

*The reason for not using a marker is for ease of exiting the while/do loop in the mission editor. All that's required to exit the loop (if you want the artillery unit to remain) is to delete the object that is the target via a trigger, another script, an addAction, however you want to do it. There are multiple invisible objects you can place, which is what I recommend using.

**I guess mortars function differently than artillery units, so if you want the mortar to stop firing after killing the gunner for that mortar, you'll need to name the unit that is the gunner for the mortar, then place a trigger with the condition of !alive mygunnername and in the on activation field use the deleteVehicle command to delete the target. That will allow the loop to be exited and the mortar will stop firing on it's own. I have no clue why it does that with mortars, sorry. Thanks to meaty for pointing that out.

  • Like 8
  • Thanks 1

Share this post


Link to post
Share on other sites

Well done, mate! :D Great stuff!

Thanks for your help in getting me on the right track to making this work.

Share this post


Link to post
Share on other sites

Cheers bro, I vaguely tried getting the arty to constantly aim and gave up, so youve saved me some time in the future lol

Share this post


Link to post
Share on other sites

Awesome. If I want the shell to impact, will it cause damage? How can I pick a specific type of shell or ammo?

 

Great work.

 

Reed

Share this post


Link to post
Share on other sites
Thanks.

 

 

Cheers bro, I vaguely tried getting the arty to constantly aim and gave up, so youve saved me some time in the future lol

Glad it will help.

 

 

Hi, I Want to thank you for the made work!

You're welcome.

 

Awesome. If I want the shell to impact, will it cause damage? How can I pick a specific type of shell or ammo?

 

Great work.

 

Reed

The shell will do damage when it impacts, however this script is not designed with accurate artillery fire in mind. Selecting a specific ammunition type would require several more lines to be added to the script, some of which I tried and was unable to get working properly, and for my purpose was unnecessary. It sounds like you're probably looking for a more advanced script than this. My script is designed to add ambiance, not bombard a position with a specific shell type with any actual accuracy. I'd recommend doing some searching for a script that will better suit your needs as this one would take extensive modification to select a specific ammunition type and to aim with any sort of accuracy.

Share this post


Link to post
Share on other sites

Great script! works great for arty vehicles etc, however if i add it to a mortar it keeps firing even with the crew killed. Anyway to stop this script running when the crew dies/leaves? :)

Share this post


Link to post
Share on other sites

Great script! works great for arty vehicles etc, however if i add it to a mortar it keeps firing even with the crew killed. Anyway to stop this script running when the crew dies/leaves? :)

Have you tried running the script on the gunner instead of the actual mortar itself? Another way to do it would be to exit the loop by deleting the target when the crew is killed with a trigger, but if you have more than one thing using that target that might not be ideal; for example in the trigger condition put !alive dude1 && !alive dude2; (those being the mortar crew members names) and then in the activation field put deleteVehicle mytargetname;. I didn't really write this with mortars in mind, mostly just artillery, but that doesn't mean it can't be tweaked for your scenario to work.

Edit: Let me test something real quick, because you may have exposed an oversight I'd not considered with regards to vehicles being damaged but not destroyed.

Share this post


Link to post
Share on other sites

I love this script for what is does. I was wanting to change the ammo type, to use the smoke for example for the ambience. I see what your saying for accurate and advanced scripts, but I didn't need that.

 

I tried to get this to work with a group, like the NATO Artillery SPG Platoon, but only one tank fires, instead of all 4.

 

THanks for your work,

Reed

Share this post


Link to post
Share on other sites

I love this script for what is does. I was wanting to change the ammo type, to use the smoke for example for the ambience. I see what your saying about for accurate and advanced scripts, but I didn't need that.

 

THanks for your work,

Reed

You're going to have to do some research then and see what's required to select a different ammunition type and then implement it. I had a lot of difficulties getting the thing to fire in the first place because a lot of the muzzle selection commands don't seem to work consistently, which is the route I tried to go originally (selecting the muzzle and then the ammunition type). I'm not going to be ripping the script apart at this time to add that feature, but if you find a way to do it, feel free to modify the script for your own personal use, and if you find a way to do it and want to share it with me please do so, if it's something I can implement into the original script for some added features I'll do so and credit you for the contribution of course. Sorry I can't be of further assistance other than I'd suggest reading through the variety of fire, doFire, etc commands on the wiki pages.

If you're more after the smoke and less concerned about the barrel remaining static (which was ultimately the point of me writing this) then commandArtilleryFire might be more than enough for your needs.

Share this post


Link to post
Share on other sites

meaty, that's weird about the mortar, because I've just tried it with a bit of added code that specifically checks if the unit has a gunner or not, and if it doesn't to exit the loop, however it continues to fire regardless. This script may not work for mortars for some unknown reason. Sorry sir. I'll play around with it for another few minutes and see what I come up with, but that's odd that it works with a vehicle but not with a mortar. Perhaps there's something in the config that's different with a mortar? It's really quite strange. You can try those workarounds though and see if they will work for you.

Share this post


Link to post
Share on other sites

Excellent, thank you. My purpose for this was to have an enemy artillery platoon head to a waypoint, the travel would take them several minutes in game. Once the platoon hits the desired location, a trigger would run your script and have the artillery firing randomly at myTarget until they are all killed.

 

Ill research a way to change the ammo type.

 

Thank you for your script.

 

Reed

Share this post


Link to post
Share on other sites

Excellent, thank you. My purpose for this was to have an enemy artillery platoon head to a waypoint, the travel would take them several minutes in game. Once the platoon hits the desired location, a trigger would run your script and have the artillery firing randomly at myTarget until they are all killed.

 

Ill research a way to change the ammo type.

 

Thank you for your script.

 

Reed

Yeah, running the script once they reach said waypoint should work. Is there a specific reason behind having them fire smoke shells vs just having the shell be deleted so there's no impact sound?

Share this post


Link to post
Share on other sites

Just for testing purposes. So I could see the impact area when setting up the barrel elevation after the artillery has reached its destination.

Share this post


Link to post
Share on other sites

So following up on meaty's thing about the mortars, I guess they behave differently than artillery, so a simple work around to exit the firing loop is to use a trigger that fires when the mortar gunner dies or leaves the mortar and have that trigger delete the target you placed. Simple enough really, probably more so than me adding more stuff to make it work specifically for a mortar. I've updated the script file with instructions about this, but since I didn't really change anything it's still v1.0. I've also added a note about it to the OP in case anyone else it looking to do something similar with a mortar.

Share this post


Link to post
Share on other sites

and for those who want to know what code to add to the trigger :)

 

In the 'Condition' field put =

!alive t1G

t1G is the name of the mortar gunner

 

In the 'On Activation' field put

deleteVehicle myTarget1;

with myTarget1 being the object your mortars are "aimed" at

 

:)

  • Like 1

Share this post


Link to post
Share on other sites

I tried to get this to work the way I explained, but am having no success.

 

I set the vanilla sholef with a few waypoints, then the scripted waypoint with your script and no joy. Then I tried a trigger at the end of the waypoints and no joy.

 

I named the sholef art1 and used same in script.

 

Thank you for any assistance.

Share this post


Link to post
Share on other sites

Without seeing the mission it's tough for me to know what the problem might be. You can send me the mission file and I can look when I get a chance. Working fine for me when I test it.

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

×