PDA

View Full Version : [TEC] changing 40mm/37mm to deck gun for AI?


akdavis
05-14-08, 04:15 PM
In my ongoing quest for improved surface action in SH4, I'm wondering if it is possible to have the AI treat 1 AA gun on a sub as a deck gun so that more than two guns can be firing on a surface target simultaneously. (This is assuming that having the AI utilize an AA gun for both surface and air targets is impossible).

Here is my rationale for such a change: I've personally found that having the AI fire on air targets is not important to me at all. I almost always dive, and if I happen to be caught with my pants down, I'd rather man at least one gun myself. However, I find myself continually annoyed that when I initiate a gun action, there are all these automatic weapons going unused.

The ideal solution would be to chose one AA gun to be recognized as a second deck gun. On boats with only a single AA gun + deck gun, the AI would use both against surface targets and you could man the AA gun to turn it against aircraft if needed (or boats with 1 gun could be left as is if you always manned the AA gun during a surface engagement). On boats with 2 AA guns, whichever gun you prefer to use against aircraft would be the second deck gun. When engaged in a surface action, you could could man the pure AA gun and have 3 guns firing against a surface target simultaneously (e.g. AI engages designated target with 4" gun and 40mm Bofors, you engage with 20mm/second Bofors).

Potential barriers:
-although you can take control of multiple AA gun positions, on boats with 2 deck guns, you cannot take control of the second deck gun. Would this happen if the sim treated an AA gun as a deck gun?
-can the AI aim an AA gun at a surface target, or is AI aiming hardcoded to the deck gun sight, i.e. would your Bofors have to exchange the open sight for an optical sight?
-Fleet Boats with 2 5" deck guns might not be able to utilize such a change.
-if you had to give up aiming the deck gun yourself (which I believe is far too easy anyways, and should be left to the AI), could anything be done about the AI's woeful inability to handle any targeting order other than to fire at the waterline?
-you might have to have crew manning both deck guns and AA guns when engaging an aircraft if you wanted the gun to load when you weren't manning the position.
-could an AA gun maintain its position on the sub and still be used by the AI against surface targets?

Snaptrap
05-14-08, 05:59 PM
Why not replace the AA guns with deck guns and just throw rocks at the planes when they attack?

Honestly, I don't see why this couldn't be done, but my guess would be tedious work and ultimately pointless. What I did with my mod was apply the late war conning towers to all the subs, and for most of them, they come with two deck and aa guns. This method would be easiest with a few simple lines to edit for each file.

akdavis
05-14-08, 09:55 PM
That's cool, but I like history and don't think it pointless. Of course, I could give all the subs nuke torpedoes and stop worrying about topside ordance altogether. :88)

ref
05-15-08, 06:41 AM
Try changing the weapon type from AAgun to Cannon in the weapon sim file, at least in sh3 as long as it has AP/HE and AA shells it opens fire on both surface and air targets.

Ref

Snaptrap
05-15-08, 07:54 AM
That's cool, but I like history and don't think it pointless. Of course, I could give all the subs nuke torpedoes and stop worrying about topside ordance altogether. :88)

I understand. I used nuke torps once and I think they take too much of the challenge element from the game.

Snaptrap
05-15-08, 08:07 AM
Try changing the weapon type from AAgun to Cannon in the weapon sim file, at least in sh3 as long as it has AP/HE and AA shells it opens fire on both surface and air targets.

Ref

Any shell type can be used for this. The important thing is that the Crew AI understands that the gun can be used on either surface or air targets. I was going to do this once but left it out because the shells used in the AA guns were at maximum strength and only used to quickly dispatch annoying aircraft. It would've ended up doing the same for everything else too.

ref
05-15-08, 09:37 AM
Try changing the weapon type from AAgun to Cannon in the weapon sim file, at least in sh3 as long as it has AP/HE and AA shells it opens fire on both surface and air targets.

Ref

Any shell type can be used for this. The important thing is that the Crew AI understands that the gun can be used on either surface or air targets. I was going to do this once but left it out because the shells used in the AA guns were at maximum strength and only used to quickly dispatch annoying aircraft. It would've ended up doing the same for everything else too.

A human player can shoot any type of shell, the AI will only shoot if they have the correct type of shell for the different kind of targets, also if the weapon controller is set to AAgun they'll only shoot to airplanes, if it's set to to cannon they'll shoot at both kind of targets only if they have the correct ammo.

Ref

Snaptrap
05-15-08, 09:42 AM
A human player can shoot any type of shell, the AI will only shoot if they have the correct type of shell for the different kind of targets, also if the weapon controller is set to AAgun they'll only shoot to airplanes, if it's set to to cannon they'll shoot at both kind of targets only if they have the correct ammo.

Ref

That's interesting because I have no AA shells at all in my mod and the AI does just fine. Perhaps some other modification causing them to act that way even without AA shells.

akdavis
05-15-08, 09:42 AM
Try changing the weapon type from AAgun to Cannon in the weapon sim file, at least in sh3 as long as it has AP/HE and AA shells it opens fire on both surface and air targets.

Ref

Any shell type can be used for this. The important thing is that the Crew AI understands that the gun can be used on either surface or air targets. I was going to do this once but left it out because the shells used in the AA guns were at maximum strength and only used to quickly dispatch annoying aircraft. It would've ended up doing the same for everything else too.

A human player can shoot any type of shell, the AI will only shoot if they have the correct type of shell for the different kind of targets, also if the weapon controller is set to AAgun they'll only shoot to airplanes, if it's set to to cannon they'll shoot at both kind of targets only if they have the correct ammo.

Ref

Sounds like a good place to start. Main problem will be adding AA ammo and squaring that with real ammo types. Can AA ammo be added to a gun in the sim file as well?

ref
05-15-08, 09:58 AM
Try changing the weapon type from AAgun to Cannon in the weapon sim file, at least in sh3 as long as it has AP/HE and AA shells it opens fire on both surface and air targets.

Ref

Any shell type can be used for this. The important thing is that the Crew AI understands that the gun can be used on either surface or air targets. I was going to do this once but left it out because the shells used in the AA guns were at maximum strength and only used to quickly dispatch annoying aircraft. It would've ended up doing the same for everything else too.

A human player can shoot any type of shell, the AI will only shoot if they have the correct type of shell for the different kind of targets, also if the weapon controller is set to AAgun they'll only shoot to airplanes, if it's set to to cannon they'll shoot at both kind of targets only if they have the correct ammo.

Ref

Sounds like a good place to start. Main problem will be adding AA ammo and squaring that with real ammo types. Can AA ammo be added to a gun in the sim file as well?

Yes, open the sim file with s3d, and look into the wpn_Cannon controller in the ammo_storage section, you'll also need to look in the shells dat file for the Id numbers of the ammo.

Ref

akdavis
05-15-08, 11:24 PM
Well, partial success. Changing the id to cannon did in fact allow them to engage surface targets, but now they won't engage air targets. Added AA ammo to all guns as indicated above. And the positions sometimes go wonky and won't allow manual control anymore, only panning view around independent of the gun mount.

If I knew I could consistently man the 40mm/37mm myself, I'd just change those, but without being sure I can turn it against aircraft, that might not be a good idea. :cry:

Snaptrap
05-16-08, 12:29 AM
Well, partial success. Changing the id to cannon did in fact allow them to engage surface targets, but now they won't engage air targets. Added AA ammo to all guns as indicated above. And the positions sometimes go wonky and won't allow manual control anymore, only panning view around independent of the gun mount.

If I knew I could consistently man the 40mm/37mm myself, I'd just change those, but without being sure I can turn it against aircraft, that might not be a good idea. :cry:

That's because it's not the proper method. The actual steps to get the result you're looking for is more of a pain to explain than it is to do. At the moment I'm busy updating my mod, but I can hel you out when I'm done.

You don't need AA shells either because some of the AA guns don't come with AA shells and they still attack air targets. An anti-aircraft shell is just a type of shell, and is not an indication of what it's specifically designed for. The AI will use any round that is selected/highlighted.

akdavis
05-16-08, 12:52 AM
I should have said that I changed the weapon type to cannon, not the ID, if that caused any confusion. Any help would be appreciated, as I see that changing only the weapon type has all sorts of weird side effects.

Snaptrap
05-16-08, 04:29 PM
After looking through the files, I've concluded that the game won't accept more than one controller type per object. I've done things like adding another controller to a weapon with a secondary function and it won't take. Only one of the controllers are accepted at a time.

I imagine this can be done, but when trying the most simple possibilities, I'm guessing it's more work than it's worth. You're probably better off manning the gun yourself.

May I ask why you want this anyway?

akdavis
05-21-08, 12:47 PM
After looking through the files, I've concluded that the game won't accept more than one controller type per object. I've done things like adding another controller to a weapon with a secondary function and it won't take. Only one of the controllers are accepted at a time.

I imagine this can be done, but when trying the most simple possibilities, I'm guessing it's more work than it's worth. You're probably better off manning the gun yourself.

May I ask why you want this anyway?

Oops, missed your answer here. Thanks for looking into it further.

Why: in the case of US submarines in the Pacific, the primary use of small arms and AA cannon on board the sub was not defense against aircraft, but in attacking in attacking boats and ships. I can't even bring to mind a single account of a 40mm being used on a sub with effect against a Japanese plane (no doubt there is one, however). But there are countless accounts of the 12.7mm/20mm/40mm weapons being used in conjunction with the deck gun (or sometimes alone if seas were to rough to man the deck gun) against Japanese shipping, especially coastal craft.

With U-boats, the AA guns were certainly far more important for defense against aircraft, but nonetheless, it was standard procedure to employ both the deck gun and the 37mm gun against a target during a surface (20mm weapons were to be used only with discretion).

But as it stands in SH, your AI gunners will not use any weapon other than the deck gun against an enemy ship. You can of course man an AA gun and use it against a surface target while the AI uses the deck gun, but if you have multiple AA guns, this still leaves some weapons totally unused in an engagement, plus you have to spend your time at the AA gun instead of captaining the ship from the bridge as is both proper and more realistic.

Now this doesn't really have a huge impact in the stock game, as the deck gun is so overpowered that you really need not worry about additional firepower. But if you play with a realism mod like Real Fleet Boat, the deck gun is toned way down, with long reloads and greatly reduced damage. Having all available weapons firing on a target under these circumstances can be decisive (and would be even more so with some improvements to damage models).

And all other considerations aside, it is just really awesome to observe from the bridge of your sub while all your weapons are being used at once against an enemy ship.

Demonizer
08-14-08, 07:37 AM
Well i just thought of this and had to take alook. Im pretty sure this is possible by adding new entries in the .sim files of the weapons. I added in another wpn_cannon entry and nodes etcetc and filled in the bits with the orginal wpn_cannon and made the settings all the same but set it to "AAgun" and the other one for the "Cannon" However it seems that each of the entries points to another set of nodes in the .dat file which i think might also have to be edited but i dont see why ti should... the thing is the game uses the parent id and stuff so you can add nodes together and so on but im not sure that the game allows too differnt nodes the AA fire and Cannon Fire to use the same parent id set in the .dat files. Im going to see what happens if i make a new entry node with the same settings but with a differnt ID then i think it might work as a dual purpose ground + air weapon and this could done for other weapons is well.

But thats if it works. :doh:

On another side of things i have been attempting to add a new sound for the 40mm.
So 20mm and 40mm have two differnt sounds, im not sure how to do this ive been playing about in the .dat files and the other files relating to the 40mm but so far no joy, so if anyone knows a thing or two about how to add a sound entries in would be helpful. Ive added the sound for example 40mm.wav into the sh.sdl but not sure on how to overide or get the game to use a custom selected file.

Will update as if i manage to find a way to have dual purpose weapons.

peabody
08-14-08, 10:39 AM
Ref above is correct, I have done what he said on a Sen Toku. If you just use cannon instead of turret, and it has AA and either HE or AP it will shoot at both. At least it did with the Japanese gun. But it was a 25mm and did pracitcally no damage to a ship. You would probably run out of ammo with it before it did anything.
But, just for your info, while building the Maya it used Japanese 5" Double barrel dual purpose guns, but when I set them to Cannons, when one side of the ship fired at a target, both sides would shoot. I am new at this and may have made a mistake, but it did happen and I didn't find a way to stop it. So one side was shooting at the enemy and the other side was shooting in the directions of friendlies. On a sub it would not be a probelm if it is set so it can point both ways, but if you install one port and one starboard it may end up with the same problem.

Peabody