Jump to content
PCanas

Make AI Artillery Fire on Target

Recommended Posts

Hi :)

 

So, I'm making a mission where the enemy AI has a village occupied. There they have artillery pieces (Sochor) firing at a neighbour village.

I don't know how to make this, but this is how I imagine it:

 

1- There are several targets at the neighbour village, and the several artillery pieces will fire at them. The targets are invisible, they're there just to tell the artillery where to aim.

1.1- It can be 1 artillery-1 target, or have 2 or 3 targets per artillery piece and make them select radomly, each time they fire.

 

2- The artillery is to fire continously until they get destroyed (they might require infinte ammo). Obviously, when destroyed, the attack on the neighbour village wil stop.

 

3- Each artillery piece is to fire with random delays between X and Y seconds.

3.1 - Each artillery piece should have it's own delay, to avoid synch shots. For example, artillery A fires with a random delay between 15 and 25 seconds, artillery B fires with random delay between 10 and 20, etc.

 

4- The artillery should ignore enemy presence.

 

If possible, I'd like to avoid "external" script files, i.e., I'd like to put the code in the init of the vehicle itself.

 

 

Thanks in advance! :)

Share this post


Link to post
Share on other sites

Look at doArtilleryFire, but don't discount script files. There's so much you can do with them. Although this command is pretty simple for just dropping into a unit init. 

Share this post


Link to post
Share on other sites

I'll try that.

 

I didn't discard script files completely, it's just I'm completely dumb when it comes to scripting, so if I can avoid it and make it more "simple", that'd be a plus ;)

Share this post


Link to post
Share on other sites

On my AI compilation list linked in my sig, there is these couple of listings which might help as well:

How to make AI mortar fire at position?
http://tinyurl.com/kg9923r

Enemy AI using artillery
http://tinyurl.com/m84qme6

 

In the future if you can before you post anything about AI to review my list and see if there is any thread, addon, script, ect,.

not already talking about or has what you are looking for. Hope that helps.

 

  • Like 1

Share this post


Link to post
Share on other sites

Ok, I've read your posts and the links suggested by @Gunter Severloh, but since my understanding of scripts is close to none, I'm still adrfit here...

 

What code do I have to use, what should I write and where, to make it happen the way I'd like to, i.e., have an artillery piece (not mortars, its a sochor) firing at a target, every x-y seconds, until it (the artillery) gets destroyed?

Share this post


Link to post
Share on other sites
On 1-7-2017 at 0:43 PM, PCanas said:

If possible, I'd like to avoid "external" script files, i.e., I'd like to put the code in the init of the vehicle itself

 

If you want an interesting scripted sequence of events (that is what you described), a.... script is the best way to do it. You cannot expect just dropping a couple of lines in an init for a sequence of events with multiple conditions. You can probably do this with multiple triggers and modules etc., but that won't be much easier then scripting.

Don't be afraid, jump in, the water is great :-)

 

https://community.bistudio.com/wiki/ArmA:_Introduction_to_Scripting

 

  • Like 1

Share this post


Link to post
Share on other sites

As pointed out scripting is far better and in a way easier once you know the basics.

Having said that you could just use the Fire Mission  waypoint for something very basic.

 

Place a move WP next to the Artillery and use the wp's timers to delay the start of the barrage

Then place an Fire Mission  WP where you want it to fire.

 

for infinite ammo place this in the Vehicles Init

this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

 

To stop the barrage when an object has been destroyed you could use a trigger and delete the Fire Mission waypoint

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
14 minutes ago, f2k sel said:

As pointed out scripting is far better and in a way easier once you know the basics.

Having said that you could just use the Fire Mission  waypoint for something very basic.

 

Place a move WP next to the Artillery and use the wp's timers to delay the start of the barrage

Then place an Fire Mission  WP where you want it to fire.

 

for infinite ammo place this in the Vehicles Init

this addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];

 

To stop the barrage when an object has been destroyed you could use a trigger and delete the Fire Mission waypoint

 

That WP method seems to work, at least the Sochor reacts, the thing is the target is out of range. How can I make AI define the range in the Sochor?

Share this post


Link to post
Share on other sites

I don't think there is an easy way to adjust the range.

 

You can fake it but that's quite involved, place the waypoints within range so the Arty have something to fire at.

Then you have to delete the shell when it's been fired and then spawn a new shell over a target such as game logic.

 

so set up the  waypoints as previous but place them somewhere that the artillery can actually fire at.

Place this code in the Artillery init.

 

this addeventhandler ["fired", {(_this select 0) setvehicleammo 0}];this addEventHandler ["fired",{deleteVehicle (_this select 6) ;0= [] spawn {sleep 8;barrage = [getpos logic_1,nil,100,1,10] spawn BIS_fnc_fireSupportVirtual;} }];

 

and place a game logic where you want the actual shells to hit and name it logic_1

 

Do you even need the actual  artillery?

 

 

 

 

Share this post


Link to post
Share on other sites

Yes, the actual artillery has to be in the map, since one of the mission objectives is to destroy them. I've managed to make shells fall in one place, using the Ordenance module, but I don't have the artillery. I managed to make the ordenance module stop if the artillery is destroyed, but it looks wierd aince the shells will be falling but the artillery won't be firing.

 

Now that I mention this, maybe there's an easier way, mixing both methods...

 

Make artillery fire.

Define delay between shots and give infinite ammo.

Delete fired shell.

Have ordenance module(s) with same delay as artillery. (or "synched" to the artillery)

Have them on repeat.

Add random spread to them (how?) so the shells don't fall always on the same spot

Stop ordenance module when artillery is destroyed (using trigger)

 

What's the part from your script that deletes the shell?

 

Share this post


Link to post
Share on other sites
this addEventHandler ["fired",{deleteVehicle (_this select 6)}]

will delete the shells.

 

in stead of the ordinance module use the   firesupportvirtual function  I used in previous example.

 

You can change the shell the delay and radius

 

    Parameters:
    Select 0 - ARRAY or OBJECT or STRING: Target position ([x,y,z] or Object or "Marker")
    Select 1 - STRING: Ammo (you can use nil or empty string for default 82mm mortar)
    Select 2 - NUMBER: Radius
    Select 3 - NUMBER: Number of rounds to be fired
    Select 4 - NUMBER or ARRAY: Delay between rounds - use either #x for precise timing or [#x,#y] for setting min and max delay
    Select 5 - (OPTIONAL) CODE: Condition to end bombardment before all rounds are fired
    Select 6 - (OPTIONAL) NUMBER: Safezone radius - minimal distance from the target position where shells may be fired at
    Select 7 - (OPTIONAL) NUMBER: Altitude where the shell will be created, default 250
    Select 8 - (OPTIONAL) NUMBER: Descending velocity, in m/s. Default is 150, if you use flare as ammo, set it to lower value (1-5) to let it fall down slowly
    Select 9 - (OPTIONAL) ARRAY: String of sounds to be played on the incoming shell, default is silence

    Returns:
    Boolean

    Examples:
    _barrage = [BIS_Player,"Sh_82mm_AMOS",100,24,10] spawn BIS_fnc_fireSupportVirtual;
    _barrage = [[3600,3600,0],nil,100,24,10] spawn BIS_fnc_fireSupportVirtual;
    _barrage = ["BIS_mrkTargetArea","",100,24,10,{BIS_Player distance BIS_EscapeZone < 100}] spawn BIS_fnc_fireSupportVirtual;
    _barrage = [BIS_Player,nil,100,24,10,{dayTime > 20},50] spawn BIS_fnc_fireSupportVirtual;
    _barrage = [BIS_Victim,"Sh_82mm_AMOS",100,24,10,{dayTime > 20},75,500,200,["mortar1","mortar2"]] spawn BIS_fnc_fireSupportVirtual;
    _barrage = [ BIS_Victim, "Sh_82mm_AMOS",100, 24,[10,20],{dayTime > 20},75,500,200,["mortar1","mortar2"] ] spawn BIS_fnc_fireSupportVirtual;

 

 

 

 

 

 

Share this post


Link to post
Share on other sites

Alternatively you could try the ambient artillery script from my signature, might do what you need.

 

Cheers

Share this post


Link to post
Share on other sites

Ok, problem solved in a "whatever" fashion...

 

I put the scripts in the artillery to delete the shells, and places ordnance modules on repeat. The game automatically repeats them every 6 seconds, I think, but I delayed the start of each module by a different ammount of time, so they are out of synch.

 

Thanks anyway for the help :)

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

×