Jump to content
Sign in to follow this  
CarlGustaffa

AI not aiming M119 for elevation.

Recommended Posts

Hi

First post here, and extremely unfamiliar with this scripting language, so be patient smile_o.gif I've done searches, but haven't found any real solutions to my problems.

I'm trying to make the M119 Howitzer act as artillery support. It is placed as Empty/Static/M119 with name uM119. A couple of soldier named uM119G and uM119C (gunner and cargo) mounts the M119 through a GETIN waypoint.

The other end, the hit area, is already working.

Regards

Carl Gustaffa

So far so good. I'm using MAP:Invisible target (addon) for target practice, since no other dummytypes would work (for me). When I place it on the ground closeby the M119 fires when doTarget and doFire commands are issued in a sqs script.

But when I move the target away or lifts it into the air (setpos getpos, and a visible target confirms the position stays that way), the gun barrel doesn't lift to follow (mounted machineguns work though), and then AI never fires.

So I figured this as a newbie no-go. Then I tried avoiding all logic and just fake everything, but I couldn't even make the gun/gunner obay my fire command from the script. But I'd still like the barrel to raise to a chosen value of mine. Questions:

1. How can I force AI to elevate and properly aim the barrel of the M119, when other static objects seem to work?

2. How do I fire this particular weapon with the (script) fire command?

Any help is welcome.

Share this post


Link to post
Share on other sites
Guest

This is an example of what ive done, that works, using CSL's .sqf script. For me, this maintains a nice continual gun angle regardless of distance, for me this is better than having the gun train strait up for anything within 3000 meters because of setting a standard hieght for target(like 3 - 5000m, etc).

When the target is moved, a new doWatch is required before it will face new position.

this is an example from my scripts in mission, I have taken a bunch of stuff out just to scrictly answer your question, although u may later want to put in additional checks, if Arty is alive, if your gunner is still in there...

You only need edit a few names in this script to get it to run on your artillery, to at least see it work. The other two scripts below this one you just copy and paste, nothing more.

this is just an example, it will currently endlessy loop as is, until some condition is put in to end firing or change target/etc

If you really just wanting a more simplified approach as far as just setting the target height and using that, maybe someone else can help with that part, its been so long since I had tried that method that I cant really help there, because I wanted personally a more appealing looking gun angle and switched to this method.

From somewhere, of course, you execute this script:

[] exec "ArtilleryTest.sqs"

ArtilleryTest.sqs

;type in the appropriate round to explode
;this can be left as is if desired, 125 mm HE round is currently selected

_barrageAmmoCSLBarrage = "SH_125_HE"

;put in the name of you artillery peice in place of MYARTILLERYPEICENAME

_ArtyPeice = MYARTILLERYPEICENAME

;must get type of round to fire

?(typeOf _ArtyPeice) == "D30":_PrimaryWepType = "D30"
?(typeOf _ArtyPeice) == "M119":_PrimaryWepType = "M119"

#beginFiring


;set arty peice facing/gun angle to target by calling CSL's CSL_GetMoveIncrementArty
;in place of the part in this line - getpos MYTARGETNAME, put in whatever you are using as target
;you can even use a marker position (getMarkerPos "myMarker")

   _watchPos = ([getpos _ArtyPeice, getpos MYTARGETNAME] call CSL_GetMoveIncrementArty)

; now arty peice will face target, and get a nice moderate gun angle

   _ArtyPeice doWatch _WatchPos

   ;set delay to allow arty to face target

   ~4

;be sure arty has full ammo to fire

   _ArtyPeice setvehicleammo 1

   ; this event handler will allow gun to fire no true round only on this firing cycle, so player can still use it
   ;I know, im using setVehicleammo twice here, just to be safe

   _ArtyPeice AddEventHandler ["fired",{DeleteVehicle (NearestObject [_This Select 0,_This Select 4]),(_This select 0) setvehicleammo 1,Town4ArtilleryOne removeAllEventHandlers "Fired"}]

   ;Fire Arty

   _ArtyPeice Fire _PrimaryWepType

   ;set delay before spawning round at target

   ~3

   ; spawn a round above the target
   ; of course, again, replace getpos MYTARGETNAME with whatever you are using to get your target position

   _barrageAmmoCSLBarrage createVehicle getpos MYTARGETNAME

; Delay Before Execution Of next Shot
   ~42

; loop

goto "beginFring"

So, in all essence, you can use CSL's arty sqf like I did in this script anywhere, just put in the position of the artillery peice and the position of the target, and it will keep a nice gun angle every time.You dont have to know anything about the script below, aside from how to call it i.e. - _watchPos = ([getpos _ArtyPeice, getpos MYTARGETNAME] call CSL_GetMoveIncrementArty) example from line in script

Just copy this script into a clean sqs file, and name it the below name with the new extension .sqf

CSL_GetMoveIncrementArty.sqf

// to use
// pass 2 positions, returns a 3rd postion in between the 2 positions 10 meters away
private
[
   "_positionACSL",
   "_positionBCSL",
   "_X1CSL",
   "_Y1CSL",
   "_X2CSL",
   "_Y2CSL",
   "_distanceACSL",
   "_distanceBCSL",
   "_distanceCCSL",
   "_reductionRatioCSL",
   "_returnPostionCSL",
   "_outputCSL"
];

_postionACSL = _this select 0;
_postionBCSL = _this select 1;

_X1CSL = _postionACSL select 0;
_Y1CSL = _postionACSL select 1;
_X2CSL = _postionBCSL select 0;
_Y2CSL = _postionBCSL select 1;

_distanceACSL = _X1CSL - _X2CSL;
_distanceBCSL = _Y1CSL - _Y2CSL;
_distanceCCSL = sqrt ((_distanceACSL * _distanceACSL) + (_distanceBCSL * _distanceBCSL));

_reductionRatioCSL = _distanceCCSL/10;

_returnPostionCSL = [(_X1CSL +((_X2CSL - _X1CSL)/_reductionRatioCSL)), (_Y1CSL +((_Y2CSL - _Y1CSL)/_reductionRatioCSL)),7.00];

_outputCSL = _returnPostionCSL;
_outputCSL

if you dont have one, make a script named Init.sqs, and copy the below code in

Init.sqs

CSL_GetMoveIncrementArty = compile preprocessFile "CSL_GetMoveIncrementArty.sqf"

The CSL_GetMoveIncrementArty.sqf is ColonelSandersLite's work completely btw, not mine.

Lastly, part of the barrage script there was originally written by ColonelSandersLite, although its been modified heavily over time, credit is due him for his part.

Btw, there is a way to change the gun angle setting that is currently used by these scripts, very simple to change, but ill see if you decide to go with this and get it going first before I put that in :smile_o:

Edited by Guest

Share this post


Link to post
Share on other sites

Hi

Thanks alot for the reply. And thanks for putting me in the right direction. From what I can see I have done a few mistakes:

1) I used doTarget instead of doFollow.

2) I used doFire instead of Fire.

I shall retry tonight using these, and if that fails have another look at other peoples scripts smile_o.gif

Btw, the M119 have a gunner position and two cargo positions. Does it make any difference if these positions are filled or not? Reload times didn't change, but was unable to check anything else.

Share this post


Link to post
Share on other sites

Those cargo positions are going to be just eye candy.

It'll *look* better with the extra guys. That's it.

BTW, the arty piece has a bit of a bug. If you "kill it" it doesn't catch fire or display a damage texture. It will kill the crew and make it unmanable though.

Share this post


Link to post
Share on other sites

Well, I agree that it looks better at least with one additional guy sitting there, but the third one really is badly done; moving around "attached" to the gun while it slides around smile_o.gif

Checked it out a bit, and it turns out it actually has a 7 man crew (M119A1), actually is UH-60 transportable and towable by HMMWV. This gun just screams to be scripted some more biggrin_o.gif

7 man crew is: Section Chief, Gunner, Ammo Team Chief, Assistant Gunner, Number One man, Advanced party.

Anyone know what their tasks are?

More here: http://tri.army.mil/LC/CF/Cft/Cftl/m119ston.htm

Share this post


Link to post
Share on other sites

7 man crew is: Section Chief, Gunner, Ammo Team Chief, Assistant Gunner, Number One man, Advanced party.

Anyone know what their tasks are?

Unless I can't count, you've got six there bud wink_o.gif.

I found this too, it's US military origin I think by the document setup.

1 - E6, 13B HOWITZER SECTION CHIEF

1 - E5, 13B AMMUNITION TEAM CHIEF

1 - E5, 13B GUNNER

1 - E4, 13B ASSISTANT GUNNER

1 - E4, 13B PRIME MOVER DRIVER

2 - E3, 13B CANNONEER

I found this, but the source if unofficial, and vietnam era. I don't know how much artillery operation at a gun level has changed since then.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Howitzer Section Crewmembers (table 1)

Full 10 Man Crew 9 Man Crew 8 Man Crew 7 Man Crew

CS/Chief of Section CS CS CS

G/Gunner G G G

AG/Assistant Gunner AG/1 AG/1 AG/1

Cannoneer #1

Cannoneer #2 2 2 2

Cannoneer #3 3 3 3/5

Cannoneer #4 4 4/6 4/6

Cannoneer #5 5 5

Cannoneer #6 6

Driver D D D

Crewmembers Duties (table 2)

Title/Number Basic Functions

Chief of Section In charge of making sure everything is set properly

Gunner Lay howitzer, set quadrant and deflection, adjust for displacement

Assistant Gunner Opens/closes breech, sets and changes primer, fires the howitzer

Cannoneer #1 Assembles swab, pail, rammer staff, rams Projo w/#4, swabs powder chamber

Cannoneer #2 Prep ammo, fuze ammo

Cannoneer #3 Jack up howitzer, carry Projo w/#6, loads powder

Cannoneer #4 Jack up howitzer, ram Projo w/#1

Cannoneer #5 Sets out Aiming Posts and Collimator, assemble powder charge & pass to #3

Cannoneer #6 Strings Commo wire to XO Post, preps ammo, carriers Projo w/#3

Driver Drives prime mover

Here's the whole page BTW:

http://www.bravecannons.org/the_gun/fire_mission.html

Note tha the guy that wrote it is an ex-artilleryman from vietname and he says pretty bluntly that by the book is not how it was done.

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  

×