Log in

View Full Version : [TEC] Some aircraft AI tests/questions


kapuhy
03-14-21, 09:30 AM
Some aircraft AI related tests and questions, in hope they might spark a discussion and lead to somewhat more dangerous planes :)

1. Aircraft vs flank speed:

I made a little test yesterday, posting the results here in case they might be of interest to other modders on Subsim. In short, I was trying to see how the bomb-armed planes will behave in different conditions. This was done in TWoS 2.2.23 with no other mods.

Starting conditions for this scenario: plane is flying a 500m, starting at 5km distance, directly at submarine from bearing 270. I relaunched this with submarine going at different speeds and that's the result:

https://youtu.be/akApBo5IsxM

I also did test with different aircraft types, and all have trouble with aligning for bomb run against target moving at flank speed, though faster planes (especially Mosquito, Dauntless and Fulmar) tended to do better, often hitting sub in second or third pass.

Level bomber AI does not get into this endless "dry run" loop, though it is far less accurate with its aiming. Still, lacking better options, I'd say a plane that drops bombs all over the place is more credible threat than plane that doesn't drop them at all, so switching worst offenders (like Catalina and Swordfish - both do the endless loop with standard AI and both occasionally hit target with level bomber AI) might be a good idea.

2. MAD ideas?

In SH4, setting visual sensors to negative MinSurface value allowed planes to see submerged U-Boat (this was used in OM for Magnetic Anomaly Detector). Unfortunately, it doesn't seem to work in SH5 - I used the same settings as OM and planes just flew over submerged boat without noticing.

I'm looking for a way to simulate MAD in SH5, but so far nothing seems to work (including sonar placed in sensor that is 200 meters under a plane so it can be below water surface). If anyone knows of a way that could work, I'd be happy to try it (one of planes I modeled should have MAD equipped).

EDIT: thanks to Jeff-Groves spotting and correcting my oversight, MAD sensor now is confirmed to work

3. Sinking torpedoes?

I ran the above scenario with torpedo armed Swordfish. It did a perfect torpedo run at low altitude and then dropped a torpedo... which sank to the bottom like a stone. What's the secret behind getting them to work like they did in TDW's screenshots in IRAI thread?

LesBaker
03-14-21, 10:02 AM
Hi Kapuhy,


Have you tried changing the hight for level bombing runs, for instance 250m insteated of 500?


Les

kapuhy
03-14-21, 10:07 AM
Hi Kapuhy,


Have you tried changing the hight for level bombing runs, for instance 250m insteated of 500?


Les

Yes (50m), and it didn't seem to affect accuracy as much as I expected.

gap
03-14-21, 11:13 AM
1. Aircraft vs flank speed

Setting dive bombers as level bombers will lead to unrealistic attack tactics. What if we fit them with some fast-aiming but short-ranged dummy gun, whose muzzle flash effect will spawn a bomb? :hmmm:

2. MAD ideas

Have you checked that visual sensor's detection angle does not prevent if from "seeing" directly below the plane?

3. Sinking torpedoes

Have you tried testing with Swordfish planes (and, indeed, with IRAI installed, no other mod overwriting its files)?

IF they use torpedoes affectively, I would try messing with various parameters (aircraft max speed, position of the torpedo bone, drag coefficients, min height, ect) until I find the one(s) which break their ability to use torpedoes in a prope manner.

kapuhy
03-14-21, 12:07 PM
Setting dive bombers as level bombers will lead to unrealistic attack tactics.

That's true, on the other hand "strafe & perform acrobatic stunts" is not a tactic I've heard of as well :D

Besides, looking at this movie for example:

https://www.youtube.com/watch?v=4L2cMVwKpm8&t=19s&ab_channel=okrajoe

is for planes like Liberator (maybe Catalina as well) attack profile used looks more like fast, low level horizontal approach (of course, these might be just shots staged for propaganda purposes and actual approach might have been more vertical).

What if we fit them with some fast-aiming but short-ranged dummy gun, whose muzzle flash effect will spawn a bomb? :hmmm:

I thought of this and it could be a viable solution (was experimenting with creating a retro-rocket launcher for MAD armed planes, and sure enough you can set a "gun" like this).

2. MAD ideas

Have you checked that visual sensor's detection angle does not prevent if from "seeing" directly below the plane?

Yes. But I have another suspect as to why it didn't work:

Have you tried testing with Swordfish planes (and, indeed, with IRAI installed, no other mod overwriting its files)?

Speaking of IRAI files - in Airplane.aix, there's this fragment:

strategy PlaneNavigate(Plane)
{
precond
{
(Plane:HasTorpedoes() or Plane:HasBombs() or Plane:HasCannons()) and Ship:GetContactDepth() > -8.5
}
strategies
{
BombCourse,
TorpedoCourse,
CannonCourse,
AirToAirCombat
}
}

If I understand correctly, it sets conditions for a plane that must be met in order for it to navigate (fly towards?) detected target:

a) plane must have means to attack (bombs, torpedoes, guns)
b) contact must be at no more than 8.5 meters depth

I wonder what would happen if we set this to 20.0 for example... but to test this, I would have to know how to make edits to .aix file affect the game (just changing it doesn't seem to do anything - maybe it is overwritten by something or requires rerunning file patcher to work?)

Jeff-Groves
03-14-21, 12:26 PM
There are 3 instances of -8.5 in that file.
You might try changing them all.


Found 3 occurrences of '-8.5'.
Line 335 4h " Ship:GetContactDepth() > -8.5 and (Plane:HasTorpedoes() or Plane:HasBombs() or Plane:HasCannons())"
Line 409 4h " (Plane:HasTorpedoes() or Plane:HasBombs() or Plane:HasCannons()) and Ship:GetContactDepth() > -8.5"
Line 766 4h " !Plane:HasCommander() and Plane:HasWaypoints() and ( ( !Ship:ContactPresenceIs(PRESENCE_SENSORS, 0) or ( Ship:ContactPresenceIs(PRESENCE_SENSORS, 0) and Ship:GetContactDepth() <= -8.5 ) ) or ( !Plane:HasBombs() and !Plane:HasTorpedoes() and !Plane:HasCannons() ) )"



010 is excellent for finding this stuff.

gap
03-14-21, 12:45 PM
That's true, on the other hand "strafe & perform acrobatic stunts" is not a tactic I've heard of as well :D

Just lol :rotfl2:

The Ubi guys must have drawn their virtual pilots from the Orlik Aerobatic Team :O:


Besides, looking at this movie for example:

[...]

is for planes like Liberator (maybe Catalina as well) attack profile used looks more like fast, low level horizontal approach (of course, these might be just shots staged for propaganda purposes and actual approach might have been more vertical).

In my previous post I was talking in general but I don't think aircraft of the size and structure of a Liberator or a Catalina could safely perform a dive bombing attack. Looking at this list (https://www.militaryfactory.com/aircraft/ww2-dive-bomber-aircraft.asp) I would say that, with very few exceptions, all the dedicated dive bombers of WWII were more similar to a fighter or heavy fighter than to a medium or heavy bomber :yep:


I thought of this and it could be a viable solution (was experimenting with creating a retro-rocket launcher for MAD armed planes, and sure enough you can set a "gun" like this).

Oh, cool we had the same idea! By the way we already have retro bomb models in game. If you look at historic pictures, they were very similar or identical to Squid projectiles.



Speaking of IRAI files - in Airplane.aix, there's this fragment:

strategy PlaneNavigate(Plane)
{
precond
{
(Plane:HasTorpedoes() or Plane:HasBombs() or Plane:HasCannons()) and Ship:GetContactDepth() > -8.5
}
strategies
{
BombCourse,
TorpedoCourse,
CannonCourse,
AirToAirCombat
}
}

If I understand correctly, it sets conditions for a plane that must be met in order for it to navigate (fly towards?) detected target:

a) plane must have means to attack (bombs, torpedoes, guns)
b) contact must be at no more than 8.5 meters depth

I wonder what would happen if we set this to 20.0 for example... but to test this, I would have to know how to make edits to .aix file affect the game (just changing it doesn't seem to do anything - maybe it is overwritten by something or requires rerunning file patcher to work?)

I don't think so. Aix files are plain ascii files, not hardcoded patch is required to "enable" their tweaks (IRAI itself is a proof of that). As sar as I can say, the code they contain is Python or a Python-like language. It is possible that some other script overrides the line that you are editing, but any tweak you do should immediately take effect (after reloading the game indeed).

Jeff-Groves
03-14-21, 12:59 PM
That file is the only one that contains -8.5 in the scripts folder of IRAI

kapuhy
03-14-21, 01:05 PM
There are 3 instances of -8.5 in that file.
You might try changing them all.

Thanks Jeff! I got so fixated on my find that I forgot to check rest of the file... :oops:

Ok, after a quick test: changing all instances solves issue Tonci87 was writing about in TWoS thread (https://www.subsim.com/radioroom/showpost.php?p=2733574&postcount=13667) - Catalina now continues its attack and drops bombs at a place where U-Boat has disappeared under water. I'll recheck the MAD sensor later and report.

Jeff-Groves
03-14-21, 01:09 PM
Pretty smart for a Village Idiot ain't I?
:har:

gap
03-14-21, 01:25 PM
Ok, after a quick test: changing all instances solves issue Tonci87 was writing about in TWoS thread (https://www.subsim.com/radioroom/showpost.php?p=2733574&postcount=13667) - Catalina now continues its attack and drops bombs at a place where U-Boat has disappeared under water. I'll recheck the MAD sensor later and report.

:Kaleun_Applaud:

Now we must check history books and websites for information on which depth was considered viable for an aiir attack with bombs or depth charges against a submerged submarine. I am sure I have read this information somewhere :hmm2:

Pretty smart for a Village Idiot ain't I?
:har:

...and a professional cunning linguist too, let's not forget that :D

kapuhy
03-14-21, 01:51 PM
Now we must check history books and websites for information on which depth was considered viable for an aiir attack with bombs or depth charges against a submerged submarine. I am sure I have read this information somewhere :hmm2:

...and browse IRAI thread as well as maybe ask SH5 modders active at the time to find why this 8.5 depth was set, so as not to reintroduce an old issue by solving this one.

Speaking of which, in IRAI thread there was talk of problem with planes constantly strafing surface where the boat has dived, perhaps this might be the reason?

Pretty smart for a Village Idiot ain't I?
:har:

:salute:

Jeff-Groves
03-14-21, 02:15 PM
You have a link to the specific pages?

gap
03-14-21, 02:16 PM
...and browse IRAI thread as well as maybe ask SH5 modders active at the time to find why this 8.5 depth was set, so as not to reintroduce an old issue by solving this one.

I was one of them. I don't remember any particular issue related with submarine depth and air raids, but I suppose not many will like being bombed by a Catalina when they think they are safe under 15 or 20 meters of water.

Early in campaign they might still be safe, but after your tweak and after the introduction of air depth charges in campaign, things might change. I have a collection of realistic allied depth bomb models on my hard disc. All my work, so no permission is going to be required for importing them in game. Over the years I have also gathered information on them (year/mont of introduction, blast radii, depth of detonation, etc). Should we join forces for a SH5 Aerial ASW mod?

Muckenberg
03-14-21, 02:20 PM
:Kaleun_Applaud:

Now we must check history books and websites for information on which depth was considered viable for an aiir attack with bombs or depth charges against a submerged submarine. I am sure I have read this information somewhere :hmm2:


The Admiralty introduced a minimum depth of fifty feet (fifteen meters) for deep charges to protect surface vessels dropping charges from explosion. Beginning in the summer of 1941, the Coast Command introduced fifty feet of bombs dropped from aircraft until a hydrostatic detonator was deployed to a depth of twenty-five feet.

I will look for more information. :Kaleun_Salute::Kaleun_Salute:

gap
03-14-21, 02:28 PM
You have a link to the specific pages?

I am afraid the "specific pages" are the whole IRAI thread :roll:
I don't remember any specific post or date that aircraft AI was discussed on, but I remember that at some pome point a "kamikaze" tactic was introduced for when aircraft were fatally damage and they can only choose where they will fall down. Somehow, this tactic made aircraft even more awkward than they are now and lesser likely to drop bombs, so it was removed in a later IRAI version

gap
03-14-21, 02:34 PM
The Admiralty introduced a minimum depth of fifty feet (fifteen meters) for deep charges to protect surface vessels dropping charges from explosion. Beginning in the summer of 1941, the Coast Command introduced fifty feet of bombs dropped from aircraft until a hydrostatic detonator was deployed to a depth of twenty-five feet.

I will look for more information. :Kaleun_Salute::Kaleun_Salute:

Thank you Muckenberg :up:

From my own research I remember that initially depth charges pistols were set too low. Later studies demontrated that in the time elapsed from aircraft dtection to DC dropping, the U-boat couldn't dive that much, and pistol settings were adjusted accordingly.

I can provide dates and figures, but now it is dinner time and I am too hungry to bother checking the file where I gathered the data :salute:

kapuhy
03-14-21, 02:43 PM
You have a link to the specific pages?

I didn't bookmark it at the time, but now I found it again:

https://www.subsim.com/radioroom/showthread.php?p=1620030&highlight=Bombs#post1620030

TDW's post #1144

Should we join forces for a SH5 Aerial ASW mod?

With pleasure!

EDIT: Oh and I just checked: MAD sensor based on SH4:OM now does work in SH5 too. I just got detected sitting still at periscope depth (with periscope down) and accurately bombed by MAD Catalina. It still needs a lot of tweaking to be historically correct, but the capability is there.

Jeff-Groves
03-14-21, 03:54 PM
You can find all available Script commands in SHSim.act
Use 010, open SHSim.act, then do a find strings as a Search.

Mister_M
03-14-21, 04:00 PM
https://youtu.be/akApBo5IsxM


So, nothing has changed since SH3... :k_rofl:

kapuhy
03-14-21, 04:16 PM
You can find all available Script commands in SHSim.act
Use 010, open SHSim.act, then do a find strings as a Search.

Thanks again :) Going to sleep now so I won't test anything today, but just did what you suggested and at least two things immediately caught my eye: there are GetContactSpeed and ContactIsMoving commands, maybe these could be used to differentiate aircraft behaviour based on target speed (to avoid this endless loop from my video).

gap
03-14-21, 06:34 PM
I didn't bookmark it at the time, but now I found it again:

https://www.subsim.com/radioroom/showthread.php?p=1620030&highlight=Bombs#post1620030

TDW's post #1144

That's a bit odd actually. If what TDW had wrote in that old post was true, I would have expected a Ship:IsSubmerged() boolean variable. We have a Ship:GetContactDepth() continuous variable instead, and your test seems to demonstrate that it is working as supposed. I can be wrong, but my suspect is that, at the time of that post, TDW had not a full knowledge of SH5's AI.

Still talking about those scripts, I think we should differentiate preconditions for bombing strategy from the ones set for other strategies; while a bomb attack against a contact below 8.5 m of depth is desiderable, a gun strafing attack run or a torpedo attack in the same conditions wouldn't make any sense :hmmm:


EDIT: Oh and I just checked: MAD sensor based on SH4:OM now does work in SH5 too. I just got detected sitting still at periscope depth (with periscope down) and accurately bombed by MAD Catalina. It still needs a lot of tweaking to be historically correct, but the capability is there.

My all time dream: Jeff's K-class blimp featured in GWX (which for some odd reason has never been imported into SH5) equipped with MAD and armed with retrorockets :arrgh!:

kapuhy
03-15-21, 02:36 AM
That's a bit odd actually. If what TDW had wrote in that old post was true, I would have expected a Ship:IsSubmerged() boolean variable. We have a Ship:GetContactDepth() continuous variable instead, and your test seems to demonstrate that it is working as supposed. I can be wrong, but my suspect is that, at the time of that post, TDW had not a full knowledge of SH5's AI.

That's my thought too - he's writing that he set having ammo as condition and thet he has no way of adding depth to it, yet in latest IRAI version depth contition is there - TDW probably didn't know of it at the time.

And just a thought about this command - it might also be used to simulate British lack of knowledge about U-Boat maximum diving depth and consequently setting their depth charges too shallow (although I'm not sure whether it wouldn't be sacrificing gameplay for historical accuracy too much - unlike the player, Germans didn't know how deep British can set their depth charges) EDIT: plus, there's no way in script commands to end this "lack of knowledge" at specific date... so no, it can't.

My all time dream: Jeff's K-class blimp featured in GWX (which for some odd reason has never been imported into SH5) equipped with MAD and armed with retrorockets :arrgh!:

As long as Jeff agrees, I'll be happy to make it happen :)

gap
03-15-21, 05:11 AM
And just a thought about this command - it might also be used to simulate British lack of knowledge about U-Boat maximum diving depth and consequently setting their depth charges too shallow (although I'm not sure whether it wouldn't be sacrificing gameplay for historical accuracy too much - unlike the player, Germans didn't know how deep British can set their depth charges) EDIT: plus, there's no way in script commands to end this "lack of knowledge" at specific date... so no, it can't.

I am afraid it was the other way around. Remember that most of the times an U-boat was intercepted by an enemy aircraft, she was sailing on the surface. Due to aircraft's speed, the submarine had a short time for submerging and avoiding the attack, so reaching max diving depth was out of question. Actually, one of the problem of early air depth charges is that their pistol was set too deep; they exploded too far below U-boat's keels and little damage was done. Experience and more accurate calculations led the British to reduce this depth setting. Let me find the source(s) that I took this information from and I will post the link here.

In game, this can be simulated without need of messing too much with AI scripts. Unlike ship-borne depth charges, air depth charges have their depth settings working. We can set up two or more copies of each DC with different detonation depth settings and then - according to historic data and gameplay convenience - we can switch from one to the other by use of date settings in each aircraft eqp file :yep:


As long as Jeff agrees, I'll be happy to make it happen :)

I think I has already agreed loooong ago, and I think someone had tested his blimp in game. IIRC the plan was to make K-calss blimps part of OHII's campaign as convoy escort, but then they were given up because it was found that they fell down when they were made to follow surface units.

More recently Jeff has talked about a better blip model he had in his hands, but then again the discussion about importing that model in game faded down, but in the first instance let's wait for Jeff's feedback on this topic. :salute:

kapuhy
03-15-21, 05:42 AM
I am afraid it was the other way around. Remember that most of the times an U-boat was intercepted by an enemy aircraft, she was sailing on the surface. Due to aircraft's speed, the submarine had a short time for submerging and avoiding the attack, so reaching max diving depth was out of question. Actually, one of the problem of early air depth charges is that their pistol was set too deep; they exploded too far below U-boat's keels and little damage was done. Experience and more accurate calculations led the British to reduce this depth setting. Let me find the source(s) that I took this information from and I will post the link here.

I know, sorry for being unclear: this remark about simulating shallow settings was about shipborne DCs at beginning of the war (I remember players complaining in the past that in 1939 British destroyers can sink their boat even at 150-200m, despite in real life British having at this point no idea German boats can dive that deep). But again, thinking about this: simulating enemy lack of knowledge while player does have hindsight is not entirely fair :)

gap
03-15-21, 06:31 AM
I know, sorry for being unclear: this remark about simulating shallow settings was about shipborne DCs at beginning of the war (I remember players complaining in the past that in 1939 British destroyers can sink their boat even at 150-200m, despite in real life British having at this point no idea German boats can dive that deep).

No matter how many complain about that, all the SH shipborne DCs since at least SHIII don't get their maximum detonation depth parameter applied; they behave as if they were proximity fuzed, and without access to the game code there is little we can do about it.


But again, thinking about this: simulating enemy lack of knowledge while player does have hindsight is not entirely fair :)

Well, in the case of air DC's I don't think this initial lack of knowledge by the British can be exploited by the player. Unless you cheat with the external camera, when you see an aircraft on the horizon you never know its armament. It might carry depth charges, regular bombs, torpedoes, guns, cannons and rockets in various combinations so, no matter how wrong were initial British calculations on depth bombs' most effective detonation depth, if you don't want to risk a too erly patrol end or, even worse, an abrupt campaign end, your best strategy won't change: dive as fast as you can!

Jeff-Groves
03-15-21, 11:50 AM
This is where I got the K-Ship 3D model a ways back.
I got written permission at that time and have the original files and textures.
http://www.alteredearth.com/airship.htm

I believe even in GWX the K-ship will fall out of the sky if it drops below a certain speed.
Took me quite a while to get it working as it does for SH3.
It was the mod I was working on at the time that got me invited to join The Grey Wolves Team.

gap
03-15-21, 12:03 PM
This is where I got the K-Ship 3D model a ways back.
I got written permission at that time and have the original files and textures.
http://www.alteredearth.com/airship.htm

Amazing model indeed, but having only seen the renders I would say that it is way too high on poly count for our game. I am afraid that making that model "game-ready" would involve more work than it is worth.

What do you think Jeff? Shouldn't we stick to your own model instead? And if yes, after more than ten a decade from when you created it, is there any field where we could improve it, maybe taking inspiration from the K-74 model by Farley & Skinner?

Jeff-Groves
03-15-21, 12:15 PM
It's actually not that bad for poly count!
Most of the high counts are internal parts that can be removed as You will never see those parts.
A rough test model with some internals removed reduced the polys to 63238 or so.
That can be reduced further by selective remove of more unneeded parts.
The basic out side stuff is really not that bad.

gap
03-15-21, 12:27 PM
I believe even in GWX the K-ship will fall out of the sky if it drops below a certain speed.
Took me quite a while to get it working as it does for SH3.

I can imagine that. After all SH's AI was not done for handling airships and, for that matter, even more traditional aircraft fall down at times with no reasonable reason lol


It's actually not that bad for poly count!
Most of the high counts are internal parts that can be removed as You will never see those parts.
A rough test model with some internals removed reduced the polys to 63238 or so.
That can be reduced further by selective remove of more unneeded parts.
The basic out side stuff is really not that bad.

:up:

Jeff-Groves
03-15-21, 01:00 PM
Also. Seeing as a LOT of GR2 files are modded with a Loose import?
(Which We all know does incredible file size growth.)
Is it really that much of a difference on file size?
You also have to consider I can BY PASS the loose import for a better fit and thus a smaller file.

If I'm not mistaken? The K-ship in GWX is the largest dat in the Air folder.

kapuhy
03-15-21, 02:04 PM
I believe even in GWX the K-ship will fall out of the sky if it drops below a certain speed.

I can imagine that. After all SH's AI was not done for handling airships and, for that matter, even more traditional aircraft fall down at times with no reasonable reason lol

If there was one situation where SH5 weird physics can be of some help, this is it:

https://youtu.be/PBhvrmdaXOs

gap
03-15-21, 03:19 PM
If there was one situation where SH5 weird physics can be of some help, this is it

According to Wikipedia, K-class blimps had a cruise speed of 93 km/h (50 kn) and a maximum speed of 125 km/h (68 kn). What was PBY's speed during your tests?

EDIT: I wonder if wing shape and area have an effect on SH5's aircraft physics :hmmm:

Jeff-Groves
03-15-21, 03:56 PM
In GWX, there are hidden wings.

gap
03-15-21, 04:26 PM
In GWX, there are hidden wings.

Yes, I suppose that invisible wings will be needed in SH5 as well.

kapuhy
03-15-21, 04:28 PM
According to Wikipedia, K-class blimps had a cruise speed of 93 km/h (50 kn) and a maximum speed of 125 km/h (68 kn). What was PBY's speed during your tests?

I randomly set 30 kn as maximum speed and 10 kn as minimum speed. I don't see a reason why you couldn't set, say, 1 kn as minimum.

EDIT: I wonder if wing shape and area have an effect on SH5's aircraft physics :hmmm:

I don't think so, considering that defining one of plane's machine gun barrels as left wing in Goblin does absolutely nothing to its ability to stay in the air.

EDIT: From what I see, it seems to be very simple: engine power and mass affect speed, so does turning and damage. If speed falls below stall speed ("minimum speed"), plane falls. If hitpoints drop to zero, it explodes and falls.

gap
03-15-21, 05:51 PM
I randomly set 30 kn as maximum speed and 10 kn as minimum speed. I don't see a reason why you couldn't set, say, 1 kn as minimum.

I don't think so, considering that defining one of plane's machine gun barrels as left wing in Goblin does absolutely nothing to its ability to stay in the air.

EDIT: From what I see, it seems to be very simple: engine power and mass affect speed, so does turning and damage. If speed falls below stall speed ("minimum speed"), plane falls. If hitpoints drop to zero, it explodes and falls.

Yes, it all makes sense. Engine damage might decrease speed; wing damage might increase minimum speed. If that was true, we should set the gondola as the main fuselage, and the balloon itself as the wing with a disproportionately high hitpoint value, so that damaging it will decrease blimp's buoyancy (but making it to fall down would take an impossible amount of AA bullets).

EDIT:

After all, it shouldn't be impossible for an U-boat to set those hard-asses of fire, thus making them to collapse into the sea:



One of the airships’ most famous battles came on the coast of Florida when the K-74 spotted a German sub [...].

Unfortunately, the submarine crew spotted the attacking airship and lit the low-flying vessel up with the sub’s anti-aircraft guns while the airship dropped two depth charges.

The consequences were immediate and severe for the blimp. The air envelope was severely damaged and set on fire by the German guns. The crew was able to extinguish the fire, but they could not maintain altitude and slowly settled into the sea.

The envelope shouldn't explode though since, as with every US airship, it was filled with helium rather than with the highly explosive hydrogen.

kapuhy
03-16-21, 02:55 AM
Yes, it all makes sense. Engine damage might decrease speed; wing damage might increase minimum speed. If that was true, we should set the gondola as the main fuselage, and the balloon itself as the wing with a disproportionately high hitpoint value, so that damaging it will decrease blimp's buoyancy (but making it to fall down would take an impossible amount of AA bullets).

Good idea :up:

Only thing that I don't know how to solve as far as blimp is concerned is turning - planes in SH5 pitch and roll when turning, and while my modified super-slow Catalina pitched and rolled a lot less at these speeds, it might still look a bit weird with a blimp (that said, I've never seen a blimp maneuvering at full speed...)

It's actually not that bad for poly count!
Most of the high counts are internal parts that can be removed as You will never see those parts.
A rough test model with some internals removed reduced the polys to 63238 or so.
That can be reduced further by selective remove of more unneeded parts.
The basic out side stuff is really not that bad.

Well SH5 can handle PB4Y with its 124k polys, I don't see why it wouldn't be able to handle the blimp (although, as a fan of simplicity I'd certainly cut from it everything that's not going to be visible in game anyway).

gap
03-16-21, 02:59 AM
Only thing that I don't know how to solve as far as blimp is concerned is turning - planes in SH5 pitch and roll when turning, and while my modified super-slow Catalina pitched and rolled a lot less at these speeds, it might still look a bit weird with a blimp (that said, I've never seen a blimp maneuvering at full speed...)

Have you tried playing with drag values?

kapuhy
03-16-21, 03:20 AM
Have you tried playing with drag values?

Not yet, but I will - not just for the blimp, but also I hope it might be one of things that would affect planes' ability to adjust their position so that AI does drop bombs on faster targets. EDIT - because it seems to me that what happens is: AI doesn't know how to lead the target, so the closer it gets, the tighter it has to turn, ultimately either hiting stall speed or "terrain ahead" warning and breaking off to recover.

gap
03-16-21, 05:21 AM
Not yet, but I will - not just for the blimp, but also I hope it might be one of things that would affect planes' ability to adjust their position so that AI does drop bombs on faster targets. EDIT - because it seems to me that what happens is: AI doesn't know how to lead the target, so the closer it gets, the tighter it has to turn, ultimately either hiting stall speed or "terrain ahead" warning and breaking off to recover.

I am trying to find the video of a turning blimp. In the meanwhile, if you are into technical stuff you could have a look into this 1941 document by US War Department on airship physics (you can skip directly to p. 47):

https://www.faa.gov/regulations_policies/handbooks_manuals/aviation/media/airship_aerodynamics.pdf

Drag is one of the few physic parameters affecting SH planes. Adjusting them wisely might be required not only for improving their general airworthiness and their bombing accuracy, but also - within reasonable limits - for differentiating one aircraft from the other.

kapuhy
03-16-21, 06:43 AM
Drag is one of the few physic parameters affecting SH planes. Adjusting them wisely might be required not only for improving their general airworthiness and their bombing accuracy, but also - within reasonable limits - for differentiating one aircraft from the other.

I'll start worrying about differentiating planes after they stop flying backwards and dropping bombs while upside down :03: but point taken, and from what I've seen so far there's an awful lot of copy-paste approach in the way these parameters are set in SH5 planes (not gonna lie, I copied drag and similar stuff from stock planes too, leaving fine-tuning for later).

gap
03-16-21, 08:06 AM
I'll start worrying about differentiating planes after they stop flying backwards and dropping bombs while upside down :03: but point taken, and from what I've seen so far there's an awful lot of copy-paste approach in the way these parameters are set in SH5 planes (not gonna lie, I copied drag and similar stuff from stock planes too, leaving fine-tuning for later).

Exactly my point. All the aircraft seem to have more or less the same physic settings, and they all might be awfully wrong :yep:

Jeff-Groves
03-16-21, 08:11 AM
flying backwards and dropping bombs while upside down
:o
THAT I want to see!
:har:

Jeff-Groves
03-16-21, 10:20 AM
as a fan of simplicity I'd certainly cut from it everything that's not going to be visible in game anyway.
Took another look at the model and there is still a lot that can be removed.
As an example. Do we really need the coffee pot on the stove?
:hmmm:
:har:

kapuhy
03-16-21, 10:25 AM
As an example. Do we really need the coffee pot on the stove?
:hmmm:
:har:

Do we really need the stove? :)

Jeff-Groves
03-16-21, 10:39 AM
Do we really need the stove? :)
Only if we keep the coffee pot.
:03:

gap
03-16-21, 11:47 AM
Do we really need the stove? :)

Are you worried about file size or about the extra weight onboard?
If the former is true, a stove can be composed of only eight triangles, or little more.
Aren't eight triangles worth the joy of free cam geeks? :D

Jeff-Groves
03-16-21, 12:34 PM
Don't think you can get that close in Free Cam to see details like that.
:hmmm:

Weight is no issue as We will be tossing a bunch of stuff out the windows.
:har:

There are parts you'd never see that we can cut just for being a waste of Game resources.
I absolutely hate throwing parts in a Unit that have no reason being there!

gap
03-16-21, 01:26 PM
Don't think you can get that close in Free Cam to see details like that.
:hmmm:

Though, I remember you placing an Easter egg inside your blimp :03:


Weight is no issue as We will be tossing a bunch of stuff out the windows.
:har:

Furniture as well as bombs :haha:


There are parts you'd never see that we can cut just for being a waste of Game resources.
I absolutely hate throwing parts in a Unit that have no reason being there!

Talking about airships and details that no one will see, this is my unfinished Zeppelin II (only the gondola plus texture stuff missing):

https://i.imgur.com/VfI1yUs.png

...and here is a detail of one of its engine nacelles (extenal faces hidden to reveal the interior :D

https://i.imgur.com/8sfzvvW.png

I thought that after stripping it down of all the unneeded stuff, it would be cool having it early in campaign to fly over German ports, playing the Horst-Wessel-Lied at deafening volume and dropping nazi propaganda fliers :O:

Jeff-Groves
03-16-21, 01:31 PM
Though, I remember you placing an Easter egg inside your blimp :03:

Yes I did.
Sadly that was a tribute to Babe.
She was my best 4 legged friend and passed away from snapping her spine.
Was it really that long ago?
:o

I still have her picture next to me so I see her everyday.
:wah:
https://www.subsim.com/radioroom/picture.php?albumid=1069&pictureid=11864

gap
03-16-21, 01:45 PM
Yes I did.
Sadly that was a tribute to Babe.
She was my best 4 legged friend and passed away from snapping her spine.
Was it really that long ago?
:o

I still have her picture next to me so I see her everyday.
:wah:

So do I with my departed Maremma sheepdog, Martina. I always thought of her as a better me.

Jeff-Groves
03-16-21, 01:53 PM
Perhaps We include Martina and my other Best friend, Storm, in the new K-Ship.

Babe has been flying since 2008 all over the World!
:yeah:

Mister_M
03-17-21, 02:19 AM
Talking about airships and details that no one will see, this is my unfinished Zeppelin II (only the gondola plus texture stuff missing):

https://i.imgur.com/VfI1yUs.png

...and here is a detail of one of its engine nacelles (extenal faces hidden to reveal the interior :D

https://i.imgur.com/8sfzvvW.png

I thought that after stripping it down of all the unneeded stuff, it would be cool having it early in campaign to fly over German ports, playing the Horst-Wessel-Lied at deafening volume and dropping nazi propaganda fliers :O:

My God, it's so beautiful ! :o
I've always been a fan of Zeppelins airships ! :yeah:
I strongly hope that you will finish this model one day, so we can enjoy watching to these great machines in the sky ! :ping: :arrgh!:

gap
03-17-21, 04:32 AM
Perhaps We include Martina and my other Best friend, Storm, in the new K-Ship.

Babe has been flying since 2008 all over the World!
:yeah:

Good idea!

Yesterday I tried to upload Martina's picture, but for some odd reason my smartphone and my laptop didn't want to cooperate... I won't try again today, in fear to derail kapuhy's thread :)

My God, it's so beautiful ! :o
I've always been a fan of Zeppelins airships ! :yeah:
I strongly hope that you will finish this model one day, so we can enjoy watching to these great machines in the sky ! :ping: :arrgh!:

My model is based on actual plans of the LZ 130 Graf Zeppelin II, an Hindemburg-class rigid airship; the last and one of the two largest airships built by the Germans.

During its short service, the LZ 130 carried out thirty flights, many of which were for propaganda. The last trip took place on 20 August 1939, only 11 days before WWII broke out. The following year, on 29 February, Göring issued an order to scrap it together with the LZ 127 (the firts airship to bring the name of Graf Zeppelin) and with the unfinished LZ 131, their metal being needed by the war industry.

Mister_M
03-17-21, 08:10 AM
My model is based on actual plans of the LZ 130 Graf Zeppelin II, an Hindemburg-class rigid airship; the last and one of the two largest airships built by the Germans.

During its short service, the LZ 130 carried out thirty flights, many of which were for propaganda. The last trip took place on 20 August 1939, only 11 days before WWII broke out. The following year, on 29 February, Göring issued an order to scrap it together with the LZ 127 (the firts airship to bring the name of Graf Zeppelin) and with the unfinished LZ 131, their metal being needed by the war industry.

Thank you for this reply. So bad that they finished this way... :wah:

On a side note, the engines look very small compared to the balloon and I know that in SH3, aircrafts' propeller is always much smaller than in reality... :hmmm:

gap
03-17-21, 10:50 AM
Thank you for this reply. So bad that they finished this way... :wah:

Hydrogen being so dangerous, and helium being in such a short supply, their usage in the military field was out of question and their withdrawal from civil service inevitable. Pity that none of them was preserved.


On a side note, the engines look very small compared to the balloon and I know that in SH3, aircrafts' propeller is always much smaller than in reality... :hmmm:

Everything in my model, including engine gondolas and propellers, was modelled after detailed plans so I am 100% sure about the proportions.
Talking about airships, don't forget that all the propulsion went into actually moving them, as opposed to winged aircraft, where a big part of the power is used for keeping them afloat in the air.

Anyway I am afraid this discussion is going beyond the purposes of this thread. When the time comes I will start a WIP thread for my Zeppelin, and we will discuss it there :salute:

Mister_M
03-18-21, 04:58 AM
Hydrogen being so dangerous, and helium being in such a short supply, their usage in the military field was out of question and their withdrawal from civil service inevitable. Pity that none of them was preserved.

Talking about airships, don't forget that all the propulsion went into actually moving them, as opposed to winged aircraft, where a big part of the power is used for keeping them afloat in the air.

That makes sense ! :yep:

Everything in my model, including engine gondolas and propellers, was modelled after detailed plans so I am 100% sure about the proportions.

When the time comes I will start a WIP thread for my Zeppelin, and we will discuss it there :salute:

:up:

kapuhy
03-20-21, 06:25 AM
I won't try again today, in fear to derail kapuhy's thread :)

I won't mind, and neither will my best 4 legged friend :)

Talking about airships and details that no one will see, this is my unfinished Zeppelin II (only the gondola plus texture stuff missing):

...and that's a lovely Zeppelin :up:

---

So, I did some more tests and messed with various parameters this week, and I have some progress with the flank speed bombing issue. Namely, I tried ordering AI to Strafe instead of SetCourseBombs for last phase of the attack, and results were encouraging.

Out of 8 different planes I tested with this setting:

- 3 managed to kill U-boat sailing at flank speed
- 1 dropped bombs but missed
- 2 killed both U-boat and themselves (one by kamikazing and other by getting blown up by its own bomb)
- 2 crashed into sea while trying to attack

The same 8 planes with standard TWoS AI:

- 6 went into endless loop like in my video
- 2 (level bombers) dropped bombs but missed

So, as far as lethality of attack goes, not bad: from 0/8 to 5/8 succesful and from 2/8 to 6/8 overall bomb attacks.

There are serious drawbacks though: told to strafe, planes behave differently. Instead of making a pass, flying away and returning for another attack, they keep very close to U-boat making narrow circles around it, while blazing away with turrets. This makes for very dramatic action if you choose to man AA guns and duke it out, but unfortunately also makes plane lose speed quickly. This is the cause of frequent crashes in tests described above - esentially, either the plane will drop bombs (and then fly away since it has no bombs left) in first several circles, or it will lose all speed and crash into ocean.

There's a "Avoid impact with water" routine in AI scripts, but it doesn't seem very effective. We'll have to find another way to make AI pilots call off the attack if their speed/altitude drops too low. Perhaps it is here that drag values will make some difference (because for atandard AI they made none, I tried setting even extreme values to no avail, still no bombs were dropped).

Another drawback is very frequent altitude changes during strafing - with fast planes it's even kinda cool (and makes hitting them with AA difficult) but with slower ones it just looks dumb. Like drunk pilot kinda dumb.

Yet another drawback - distinction between level bombers and dive bombers seem to be a part of SetCourseBombs command, because replacing SetCourseBombs with Strafe makes all aircraft, no matter their classification, behave in the same way.

Since it seems possible to make AI check target speed as well as depth, I think now that best approach would be to create two bombing "strategies" - one, for slow/stationary targets, will be esentially unchanged IRAI approach, and second, for fast targets, will involve changing to strafing behaviour on last leg of attack, to allow for dropping bombs while minimizing time spent on sucidally narow turns.

gap
03-20-21, 12:03 PM
As far as the strafe strategy will only be used in certain circumstances, I think we can live with the involved oddities. Some of them are not even so impossible; for one thing, I am sure I have read reports of ASW aircraft killing themselves with their own bombs dropped at too a low altitude.

That said, I will add a couple of quick thoughts:

- is the min_height parameter in cmdr_AIAirplane controller doing anything?

- Is there in SHSim.act anyhing that can be used to get aircraft altitude so that, when their height drops too much they can switch to normal flight or to any other tactic that won't result in a suicidal conduct?

Else, is it possible to differentiate strategies by aircraft unit type? :hmm2:

kapuhy
03-20-21, 01:44 PM
- is the min_height parameter in cmdr_AIAirplane controller doing anything?

To my utmost surprise, yes it does :up: (I'm surprised because with previous behaviour, SetCourseBombs, it seemed inconsequential)

Setting it high (like really high, 200 m or more) prevents even B-18, the worst offender so far, from crashing into ocean. It still flies like pilot just downed a case of beer by himself, but it does so at higher altitude.

Now, all that's needed is:

- make planes fly more stable
- make them, if possible, drop bombs on first pass (now, even with Strafe behaviour, they usually make several circles and turns before they find a good position to drop bombs)

First I hope can be achieved with fine-tuning wings/rudders drag and engine parameters. For second, no clue now but perhaps something will click if we keep changing all values...

Jeff-Groves
03-20-21, 05:37 PM
Depending on distance to target?
There is a AI Command.
StrafingTooClose

There's A LOT of Commands TDW didn't use.
NeedToDescend
LaunchTorpedoesStrafe
MoveAroundCannonTarget

Etc.

Muckenberg
03-21-21, 01:47 AM
As far as the strafe strategy will only be used in certain circumstances, I think we can live with the involved oddities. Some of them are not even so impossible; for one thing, I am sure I have read reports of ASW aircraft killing themselves with their own bombs dropped at too a low altitude.




Good day
So I know one confirmed case. It's an attack by Skua aircraft from Ark Royal on the U-30. Here the bombs bounced off the surface and exploded in front of the planes. :k_confused::k_confused:

kapuhy
03-21-21, 05:51 AM
Depending on distance to target?
There is a AI Command.
StrafingTooClose

This one is used by "avoid impact with water" routine, so I think (might be wrong though) "TooClose" in this case refers to distance to water, not target.

For distance to target, GetContactRelDistOnWater works fine.

There's A LOT of Commands TDW didn't use.
NeedToDescend
LaunchTorpedoesStrafe
MoveAroundCannonTarget

Etc.

True, and it's my intention to test them all to determine how will units react to them, then report results here so that either myself or other modders can improve plane AI as much as possible.

-----
If any players who are currently playing a campaign using TWoS are reading this thread - Coastal Commma... wait, uhm, BdU Training Division would find it very helpful if you share your experiences with planes in game currently: how dangerous do you consider them to be, what are your usual reaction/tactic in dealing with them, what types of planes are most common in your game (my tests are very "clinical" and may not reflect real combat engagements).

kapuhy
03-21-21, 02:35 PM
Umm... guys?

So, this is a little side effect of meddling with AI scripts today. It is in no way related to aircraft behaviour, but I hope you'll like it anyway:

https://youtu.be/nFYryWEduzU

Jeff-Groves
03-21-21, 02:42 PM
Is that AI Subs firing deck guns?

kapuhy
03-21-21, 02:49 PM
Is that AI Subs firing deck guns?

Yes.

I added Ship:CanFireCannons as additional condition to hitherto non-functional surface attack strategy and AI subs started firing both AA and deck guns.

Jeff-Groves
03-21-21, 02:56 PM
Now you need to add crew to those Guns!

Jeff-Groves
03-21-21, 02:58 PM
Here's the complete list of AI commands.
I didn't take time to make it all pretty.

GetContactWeight
GetDepth....Dive....
CheckDepth..GetD
amage...InSpotLi
ght.GetCrewRatin
gSub....ContactD
etected.WaitActi
on..PeriscopeRai
sed.RaisePerisco
pe..GetContactAv
oidDist.GetConta
ctRelDist...GetS
ubMaxSpeed..GetC
ontactSpeed.CanF
ollowWaypoint...
ContactIsMoving.
SubInFrontOfCont
act.PersuingTarg
et..CanFire.Faci
ngTargetTrajecto
ry..FireTorpedoe
s...FireCannons.
ContactIs...AreE
nemiesPresent...
SetThrottleRatio
....IsDay...Turn
ToFaceTargetTraj
ectory..MoveOuts
ideDetectionArea
....MoveIntoPosi
tion....MoveNear
DetectionArea...
ApproachStillTar
get.MoveAroundCa
nnonTarget..SetT
hrottle.FollowWp
....CanFireTorpe
does....HasBombs
....HasTorpedoes
....CanFireBombs
....NeedToDescen
d...StrafingTooC
lose....FiredTor
pedo....LaunchTo
rpedoesStrafe...
ShouldPrepareToL
aunch...MoveToFi
reTorpedo...HasW
aypoints....HasC
annons..CanFireC
annons..HasGroup
....HasCommander
....HasSameConta
ctAsCommander...
FireBombs...SetC
ourseBombs..Stra
fe..AvoidWaterIm
pact....SetOnTar
get.ShouldSetOnT
arget...SetCours
eWaypoint...Floc
k...GetContactRe
lDistOnWater....
GetRole.IsType..
IsCommander.SetT
actic...EndCurre
ntTactic....CanC
ontinueCurrentTa
ctic....GetShips
DestroyedRecentl
yInGroup....Idle
ThisShip....AddR
ole.IsRoleInCurr
entTactic...SetL
ineFormation....
AssignRole..GetC
urrentTacticID..
GetCurrentTactic
MinShips....Wait
ForFormation....
GetShipCountInGr
oup.Random..Cont
actIsInsideGroup
Area....SetGotoF
orwardDist..SetG
otoDestRelToCont
act.SetGotoDestR
elToContactKeepF
ormationOrientat
ion.SetGotoDestR
elToGroupCenterA
longGroupHeading
....SetGotoDestR
elToGroupCenter.
StartFiringDCs..
StopFiringDCs...
EnableStarshells
....ShipWaitActi
on..GetMyWeight.
TimeEventHappen.
GetContactLostTi
me..CanFireDCRac
ks..CanFireHHogs
....CanFireDCThr
owers...TorpedoD
etected.CanFireS
tarShells...GetC
ontactDepth.GetC
ontactBearing...
ContactPresenceI
s...GetCurrentSp
eed.GetCurrentSp
eedKnots....Fire
DCRacks.FireDCTh
rowers..FireHHog
s...FireStarShel
ls..AvoidTorpedo
es..FollowWaypoi
nts.Spiral..Pine
appleFlares.Goto
....TurnToHeadin
g...TurnFormatio
nToHeading..GetC
urrentHeading...
GetCurrentFormat
ionHeading..GetF
ormationContactB
earing..GotoActi
on..SetRamDestin
ation...SetSenso
rFactor.IsNeutra
l...IsDocked....
HasContacts.GetC
rewRating...Chan
geStatusIcon....
IsAlone.

kapuhy
03-21-21, 03:57 PM
Here's the complete list of AI commands.
I didn't take time to make it all pretty.


Thanks :) In fact I already noted most of these down after doing, as you've suggested before, a string search in ShSim.act with 010 Editor.

GrenSo
03-22-21, 01:49 AM
Umm... guys?

So, this is a little side effect of meddling with AI scripts today. It is in no way related to aircraft behaviour, but I hope you'll like it anyway:

https://youtu.be/nFYryWEduzU




Nice. :Kaleun_Applaud:

I didn't see any AI sub firing anything. No matter if German or allied subs they have only been driving past and do nothing else.

kapuhy
03-23-21, 05:48 PM
Ok, little update on subs (see, I'm now derailing my own thread :D )

- They can fire at other subs as well if ordered, so no easy sinking British and Polish U-class subs with deck gun anymore. They will defend themselves :D

- I can't get them to fire AA at planes, sadly (even though they do fire AA guns at other ships). In this case, script debugger shows CanFireCannons condition as false even is targeted plane is clearly within field of fire. Maybe if I find parts of script that order surface ships to attack planes I could learn something from them... if we could get this to work, we could have functional UFlak escorts in game.

Edit: And if placed right next to surface vessel, surface ship has CanFireCannons=true and sub has CanFireCannons=false when enemy aircraft appears, while bothe have CanFireCannons=true when enemy ship appears. Seems like they really don't want to fight planes.

Jeff-Groves
03-24-21, 11:43 AM
TDW included an AI Cannon for Subs but there is no AI AA gun for Subs.
Check the files.
Do a copy of the 20mm and follow what he did for the Deck gun.
Then check the Subs eqp files and adjust.

You have 010 so COMPARE the AI deck gun to the stock Deck gun!
Notice names are changed so ID's will change!
Adjust the SIM with Goblin (Or S3D if you have the SH5 files for it) to match ID's.

Should you want the CRC in the new edited GR2 file to be correct?
I have a script for 010 that will do that.

Jeff-Groves
03-24-21, 03:21 PM
One thing that still bothers me.
How exactly are ID's being generated?
Sergbuto posted about it years ago but I still have not figured out how it's done!

Finding the key to THAT would make editing files SO MUCH faster!

kapuhy
03-24-21, 03:48 PM
TDW included an AI Cannon for Subs but there is no AI AA gun for Subs.
Check the files.
Do a copy of the 20mm and follow what he did for the Deck gun.
Then check the Subs eqp files and adjust.

You have 010 so COMPARE the AI deck gun to the stock Deck gun!
Notice names are changed so ID's will change!
Adjust the SIM with Goblin (Or S3D if you have the SH5 files for it) to match ID's.

Should you want the CRC in the new edited GR2 file to be correct?
I have a script for 010 that will do that.

I just tried this, but unfortunately it didn't work. There's a chance I bungled up something and I'll double-check it later, but for now I feel lack of AI AA gun for subs is not the cause for this problem. Why? Because for surface targets, ANY gun works - AI 88, normal 88, I can even mount a Bismarck turret and my Surcouf-VIIc will happily engage any surface target:

https://i.imgur.com/JVKDwwC.jpg

It will also fire at surface targets with its AA gun (and with any gun I tell it to mount on AA station), but refuse to use anything against planes.

So, no progress with AA for now. On the bright side, thanks to you I learned how to compare files with 010 today, something I feel will come in handy more than once :salute:

Jeff-Groves
03-24-21, 04:10 PM
You know Ships have this.
WNOperationAirContactComm

Now before anyone freaks about playing with the AI Files from TDW?
This is from the readme released with the Mod.
NOTE: this mod can be customized by editing the \data\Scripts\AI\init.AIX. I went to great lengths to make it user customizable and for testing different setups/configurations (testing)

kapuhy
03-25-21, 04:17 AM
You know Ships have this.
WNOperationAirContactComm

Ok, I looked into it but fail to grasp how I can use this. It seems to be a strategy for warships for maneuvers when air contact is detected - three different maneuver patterns depending on distance to the plane (no threat, threat and critical). Granted I don't understand half these commands but nothing I saw seem to affect firing any cannons.:hmmm:

In other news, I did have a little progress yesterday. Since ship can fire AA, I thought I'd change relevant conditions and commands in Sub-Attack AI file from Sub: (command) to Ship: (command).

That got U-boats to fire AA guns at planes, but the fire was very intermittent (couple shots, back to ignoring planes, again couple shots after some time) and accuracy looks like they have gunner's mate first class Philip A. from Spaceballs manning the gun.

Edit: in general, something that can be looked into by modders re: sh5 scripting, is that it seems while various AI commands only work when used by "ship" "sub" or "plane", game seems to accept if we put "ship: do thing x" in plane ai file or vice versa. TDW already used this in his plane strategies, now it seems to allow subs to fire guns, perhaps there are more situations where using "someone else's" command can be beneficial

kapuhy
03-27-21, 10:52 AM
Else, is it possible to differentiate strategies by aircraft unit type? :hmm2:

- Possibly (haven't tested yet) by IsType() boolean - if "type" here refers to aircraft/ship type as defined in Names.cfg
- Other than that, by GetMyWeight which returns own weight in tons - while that doesn't directly differentiate by type, it can be used to sort out light bombers and fighters from heavy bombers for example.

Jeff-Groves
03-27-21, 11:06 AM
Possibly IsType?
For example:
Ship:IsType(ESCORT) or Ship:IsType(BATTLESHIP)

Then see about GetMyWeight?

kapuhy
08-03-22, 02:19 AM
Returning to meddling with plane AI after a long break. As a little recap, I made a video showing difference between airplane AI as it is in TWoS and what happens if we tell planes to strafe, not bomb, fast moving targets:

https://www.youtube.com/watch?v=2Yxd_EPaDKI&ab_channel=kapuhy

In the above, I set 6 planes starting at 6 km distance (Sunderland, B-17, Liberator, Swordfish, Martlet, Catalina) to bomb our boat which is simply sailing in straight line at flank speed.

Results:

- unmodified AI: only level bombers even drop bombs, and after 3 minutes U-Boat is more or less intact (only light damage from guns).
- "strafing" planes: two planes crash into sea, but remaining ones score several hits in 3 minutes sending U-Boat to the bottom.

Edit:
- Behaviour is only modified for targets moving over 5 kts. For static/slow targets planes use SetCourseBomb approach which is much safer.
- I tried to add condition checking plane's own speed to break off the attack if in danger of stalling, but to my suprise GetCurrentSpeed() function returns unit's maximum, not current speed so it proved useless for this. Only thing that somewhat reduces stalling is increasing plane minimum height, but this has to be done on plane-by-plane basis.

gap
08-03-22, 05:22 PM
Brilliant!

Other than increased stalling chances for strafing planes, have you noticed any other undesired side effect?

On a partly unrelated note: as you probably know coastal defenses featured in TWoS are in reality floating gun platforms. This is the only workaround I and Vecko found to land units not being able to shoot their guns. IIRC in stock game coastal batteries can aim and follow targets, but they never fire. Do you think we can fix them by editing their AI routines, the way you did with AI sub's deck guns?

Edit: have you tried if the GetCurrentSpeedKnots() function works as supposed?

kapuhy
08-04-22, 11:11 AM
Other than increased stalling chances for strafing planes, have you noticed any other undesired side effect?

Not really, I mean they do pull off unrealistically looking maneuvers but that's just SH5 physics. Also, slower planes do seem to follow a sinusoidal flight path sometimes for whatever reason.

On a partly unrelated note: as you probably know coastal defenses featured in TWoS are in reality floating gun platforms. This is the only workaround I and Vecko found to land units not being able to shoot their guns. IIRC in stock game coastal batteries can aim and follow targets, but they never fire. Do you think we can fix them by editing their AI routines, the way you did with AI sub's deck guns?

I don't know. Currently land units don't use any AI file, the question is if we create an AI script for land units will they even recognize it?

Edit: have you tried if the GetCurrentSpeedKnots() function works as supposed?

Different units, same problem - if returns unit's maximum speed in knots.

By the way, ship-weapons.aix script uses the same function to ensure an escort is not going too slow before dropping DC's. I bet this is bugged too and related to destroyers blowing themselves occasionally.

propbeanie
08-04-22, 04:42 PM
What CrewRating do you have the planes or AirBase set to kapuhy? We found in SH4 that they have to be set to Elite to even begin to look like airplanes flying, and even then, they will attempt 90 degree climbs, and even appear to stall-out and fall backwards after dive-bombing. Of course, we don't have scripting in SH4, therefore that CrewRating is very important.

Jeff-Groves
08-04-22, 04:54 PM
One would need to release the scripts for others to check.
Just saying something means nothing so gives us nothing to work with.
I'm also wondering about any other attempts to do such things.
I don't recall details of HOW one did thimgs.

Jeff-Groves
08-05-22, 01:27 PM
Just a quick look at the Scripting for AI Units?
I can't find any reason one could not do Scripts for the Land Units.
Even scanning the base files in SH5 leads me to believe it can be done.

kapuhy
08-05-22, 02:18 PM
What CrewRating do you have the planes or AirBase set to kapuhy?

Default setting (that I used in video above) is Veteran. I've tested it again with Elite today, with mixed results:

Try 1: 1 plane crashed (Liberator), 1 minute to kill U-Boat
Try 2: 2 planes ran into each other and fell on U-Boat, killing it
Try 3: 1 plane crashed (Liberator), 2 minutes to kill U-Boat

So, mostly better in my first test but very inconsistent. I don't know what to make of it.

Also, some planes (Liberator for example) crash a lot more than others.

One would need to release the scripts for others to check.
Just saying something means nothing so gives us nothing to work with.
I'm also wondering about any other attempts to do such things.
I don't recall details of HOW one did thimgs.

I agree and the only reason I didn't simply attach files to this thread for anyone to test is I'm not sure I can, copyright-wise - after all, I just changed a bunch of lines in TDW's scripts, wouldn't uploading modified files on forum require his permission first?

That said, I'm pretty sure I can post exact changes I made. In Airplane.aix there's a strategy "BombCoursePopUp". I replaced it with this:

strategy BombCourseStrafe(Plane)
{
precond
{
Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() > 5
}
action
{
Plane:Strafe(1.0);
}
}

strategy BombCourseSlow(Plane)
{
precond
{
Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() <= 5
}
action
{
Plane:SetCourseBombs();
}
}

By the way, I have no idea what does the number in brackets after Strafe stand for. Tried various values here and plane behaviour seemed similar.

Just a quick look at the Scripting for AI Units?
I can't find any reason one could not do Scripts for the Land Units.
Even scanning the base files in SH5 leads me to believe it can be done.

Then it is certainly worth trying :up:

Jeff-Groves
08-05-22, 02:46 PM
His Copyright stuff really means nothing as He broke the License of the Game to start with and I'd doubt he'd even stand a chance inforcing anything.

As to uploading? He went 'POOF' years ago and does not respond to messages so it's fair Game to modify anything.

Of course I will state that IF you use his work? Credit it! Been enough of that issue going on.

Now. There's a lot of things in the Scripts one needs to understand and look at.
One can create different actions that you'll not find in the Scripts.

Jeff-Groves
08-05-22, 03:01 PM
As to Land Units?
I ask what gap and others tried to get them working.

I'm not about to start from scratch if other methods were tried.

Jeff-Groves
08-05-22, 03:54 PM
On Plane Strafe?
I'm not finding a definition on that.
Any Action needs a defined definition.

So one would need to declare the Strafe Action.
That was never done in TDW's stuff so guess what?
It is a NULL action.
Should one write a Strafe Action for Planes?
You could control speeds based on different conditions.

kapuhy
08-06-22, 01:07 PM
On Plane Strafe?
I'm not finding a definition on that.
Any Action needs a defined definition.

So one would need to declare the Strafe Action.
That was never done in TDW's stuff so guess what?
It is a NULL action.
Should one write a Strafe Action for Planes?
You could control speeds based on different conditions.

Umm, newbie question time... Could you point me to an example of such definition (for any action)? I'd like to learn how these definitions work but was unable to find one.

Jeff-Groves
08-06-22, 01:43 PM
Ok. Let me open some files and I'll post back ASAP.

Jeff-Groves
08-06-22, 03:47 PM
Ok. Are you playing with TDW's Script for Planes?

kapuhy
08-06-22, 03:49 PM
Ok. Are you playing with TDW's Script for Planes?

Yes, Airplane.aix file as it is is TWoS 2.2.24

Jeff-Groves
08-06-22, 04:00 PM
OK. So We are on the same page then.
One thing I see missing is

precond
{
Plane:CanFireCannons()
}

So not sure how the Strafe command will work with out that.

Now Strafe is listed as a valid command in the sim file.
No notes on the value after the call but I suspect a precentage of chance of firing.

You may need to set it like so,

precond
{
Plane:HasCannons(),
Plane:CanFireCannons()
}

kapuhy
08-06-22, 04:37 PM
Ok, so I just set it like this:

strategy BombCourseStrafe(Plane)
{
precond
{
Plane:HasCannons() and Plane:CanFireCannons() and Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() > 5
}
action
{
Plane:Strafe(1.0);
#Ship:SetThrottle(1.0);
}
}

In game, not seeing any difference (repeating the same test, I had as before Liberator crashing into sea and other planes delivering accurate bomb drops). As for bolded value after Strafe: whatever it means, I tend to see better results with this value being lower. When I set it to 100.0, planes started to crash into each other and into sea more often.

Jeff-Groves
08-06-22, 05:26 PM
That's kind of why I think We may need to create a new strategy,
then call it when needed.
Look at how TDW did the Ship strategies.
If you really look at his AirPlane.aix?
It seems pretty lame for some reason. Not saying it's wrong but to me?
It seems lacking in many areas.
I'm only looking at the files included in TWOS

Jeff-Groves
08-06-22, 05:28 PM
Another thing is I'm not certain the way you've coded is correct or will work.

kapuhy
08-06-22, 06:00 PM
That's kind of why I think We may need to create a new strategy,
then call it when needed.
Look at how TDW did the Ship strategies.
If you really look at his AirPlane.aix?
It seems pretty lame for some reason. Not saying it's wrong but to me?
It seems lacking in many areas.
I'm only looking at the files included in TWOS

It is much less complex than ships strategies to be sure (on the other hand, aircraft tactics against U-Boats boils down to "beeline towards target and hope it doesn't dive before you reach it")

Another thing is I'm not certain the way you've coded is correct or will work.

That makes two of us :-) I'm pretty much using old point-and-click games method of using everything on everything until something works.

Jeff-Groves
08-06-22, 06:11 PM
aircraft tactics against U-Boats boils down to "beeline towards target and hope it doesn't dive before you reach it"

And may be why one needs to increase the speed of the Plane in some situations.

kapuhy
08-07-22, 04:55 AM
And may be why one needs to increase the speed of the Plane in some situations.

It would be even better if one could order the plane to lead the target. Now there's a TurnToFaceTargetTrajectory function but when I tried to apply it to planes game kept crashing on me.

As for land units, gap certainly can elaborate on this but from what I see, the workaround used by them was to assign ship AI commander controller to land unit, which allows it to use ship strategies (and since it cannot move, only ship strategy that's available to it is shooting at any detected target that moves into range). That works very well, only downside being that bunkers bounce up and down as if they were floating on waves.

I tried to add another .aix file with instructions for CoastalDefense AI "commander":

strategy CoastalDefense(CoastalDefense)
{
precond
{
Ship:IsType(LANDUNIT) and Plane:HasCannons() and Ship:CanFireCannons()
}
action
{
Ship:FireCannons();
}
}

Game accepts it (as in, does not CTD on me. When I added the file including obvious syntax errors just to see if game even "sees" the file, it CTD'd on loading the mission) but after checking with AI script debugger - land units using CastalDefense AI do not use the strategy from that file.

EDIT: it just occured to me that unlike modified "ship" bunker from TWoS, stock land units don't have any sensors so they might not fire cannons because they cannot detect any target...

Mad Mardigan
08-07-22, 01:26 PM
It would be even better if one could order the plane to lead the target. Now there's a TurnToFaceTargetTrajectory function but when I tried to apply it to planes game kept crashing on me.

As for land units, gap certainly can elaborate on this but from what I see, the workaround used by them was to assign ship AI commander controller to land unit, which allows it to use ship strategies (and since it cannot move, only ship strategy that's available to it is shooting at any detected target that moves into range). That works very well, only downside being that bunkers bounce up and down as if they were floating on waves.

I tried to add another .aix file with instructions for CoastalDefense AI "commander":

strategy CoastalDefense(CoastalDefense)
{
precond
{
Ship:IsType(LANDUNIT) and Plane:HasCannons() and Ship:CanFireCannons()
}
action
{
Ship:FireCannons();
}
}

Game accepts it (as in, does not CTD on me. When I added the file including obvious syntax errors just to see if game even "sees" the file, it CTD'd on loading the mission) but after checking with AI script debugger - land units using CastalDefense AI do not use the strategy from that file.

EDIT: it just occurred to me that unlike modified "ship" bunker from TWoS, stock land units don't have any sensors so they might not fire cannons because they cannot detect any target...

Stock, land units... like cannons or artillery pieces, may not... but... there must be some means to make the stock ones have the sense to fire at targets at sea. :yep:


Just as an example... I recall with FotRS-U or was that... TMOverhauled v2.5 BH edition, was patrolling near a small island making way for... the Sulu Sea, after passing through that narrow passage on the west side of Borneo... I believe... :hmmm: Got tagged by shell fire, &... I was like... 9-10 nm's away from that sucker. As I best recall the day hours, was like... just around dusk/twilight... as I recall.


Now, I know that is pertaining to SH4... & may... or may NOT be, applicable here... what with it being SH5... but, wouldn't hurt to look into & see if there aren't similarities there, that could be used... here, in SH5 land. :shucks:


Hope this info.... helps... as always. :shucks: :yep: :up:






:Kaleun_Salute:


M. M.

Jeff-Groves
08-07-22, 01:33 PM
There is an obj_sensor in the sim file of the stock land units.
I assume it's a Visual sensor as I've not really checked the ID's
The Land units use AICostalDefense. Note the spelling.

I'm wondering about a strange thing in the GR2 files on them though.
GrannyViewer lists 3 Bones but only 2 appear and there seems to be no connection to the missing Base Bone?
:hmmm:

gap
08-07-22, 07:02 PM
Hi Maciej and Jeff, during the last few days I have been following the discussion on this thread but private life duties prevented me from replying before. Sorry for that. My notes below:

- Unfortunately I can't provide any detail on what was done in the past for fixing stock land units. To be totally honest my commitment in that field was marginal, to say the least. TDW dealt with that. My only contribution was carrying out a few tests. At that time I thought TDW had tried every possible tweak for fixing the buggy stock AI, but the 'recent' discovery by Maciej on how to fix AI sub's deck gun, has proved me wrong and gives me new hopes.

- IIRC, my (unsuccessful) tests were carried out on a tweaked version of stock land units with sensors added. Indeed, any new tweak should be tested on a set of similarly modified units.

- The "floating coastal defenses" weren't my idea either. Vecko proposed them. I only helped him setting up the files and providing 3D models. The bunker currently featured in TWoS is my elaboration of a SHIII or SHIV model. It is more correct for German coastal defenses than for British ones though. In the meanwhile I have created the model of a typical British gun emplacement that I will be glad to share with the community if we find a proper way to implement coastal defenses in game.

- Talking bout the aforementioned floating coastal defenses, yes they are basically land units with the ship AI commander controller in place of the regular AICostalDefense controller. We gave them a huge mass and very high drag coefficients and we lowered their center of mass so to minimize pitch and roll, but this is not perfect. Other inconveniences are that they need to be placed unrealistically close to coasts, and that water depth under them can't be too shallow, otherwise they get 'stuck' just like regular sea units and they fail to shoot their guns.

- Talking about 'copyright' issues, I totally agree with Jeff. At this point, the release of single IRAI files tweaked conveniently, shouldn't be a taboo as long as all the due credit is given to their original author. If that wasn't possible, many mods based on New UIs, Fx Updates, etc, wouldn't ever been released :salute:

Jeff-Groves
08-07-22, 07:25 PM
I haven't looked at the 'Land Units' in TWoS.

Don't think they would help to be honest as We are looking at getting the Stock Land Units working.

TDW, as good as he was? Is not the end all be all.
And yes I will admit he and I did not see eye to eye.
But that does not make him nor I right or wrong.

I can tell you TDW did NOT share much as to AI Scripting.
And when he did? It was with a worthless copyright BS included.

gap
08-08-22, 04:53 AM
I haven't looked at the 'Land Units' in TWoS.

Don't think they would help to be honest as We are looking at getting the Stock Land Units working.

I am afraid not, sorry. Anyway I was never satisfied with those lame floating gun platforms. Hopefully one day we will replace them with proper coastal defenses :up:

kapuhy
08-08-22, 03:59 PM
Happy to report some progress :)

I figured out the culprit behind constant crashing into water. Planes have the "Avoid Impact" strategy which should prevent them from crashing, but other strategies did not have a condition preventing them from being applied when plane is "avoiding impact", which caused planes to try to follow two different strategies at once.

Adding and !Plane:StrafingTooClose() to bombing/strafing strategy solves the crashing problem - I ran my 6-plane test mission 10 times and only had two instances of plane crashing into water, when before I had on average 2 crashes per single test:

strategy BombCourseStrafe(Plane)
{
precond
{
Plane:HasCannons() and Plane:CanFireCannons() and Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() > 5 and !Plane:StrafingTooClose()
}
action
{
Plane:Strafe(1.0);
Ship:SetThrottleRatio(1.0);
}
}

strategy BombCourseSlow(Plane)
{
precond
{
Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() <= 5 and !Plane:StrafingTooClose()
}
action
{
Plane:SetCourseBombs();
#Ship:SetThrottle(1.0);
}
}

Downside (there's always one) is that planes occasionally break off the attack without dropping bombs like in original IRAI script. This seems to be dependent on plane characteristics now, though: for example Swordfish never finishes the run, but Catalina almost always does drop bombs. So the next thing to do is figuring out how to tweak "reluctant" planes to be more agressive.

Overall, for 10 attacks:
- 2 out of 60 planes crashed
- 7 out of 10 Uboats destroyed (most effective planes: Catalina, Sunderland, Martlet. B17 mostly misses, Swordfish and Liberator break off the attack)
- 3 Uboats survived, 1 with heavy damage but able to limp back to base

Jeff-Groves
08-08-22, 04:05 PM
Good job Mate!!
:yeah:

Just as I stated before? TDW didn't have everything right.

Now.
Catalina is a Type=304
SwordFish is a Type=303
Try changing that

gap
08-08-22, 05:01 PM
Good job Mate!!
:yeah:

I second that :up:


Now.
Catalina is a Type=304
SwordFish is a Type=303
Try changing that

My bet: minimum height, engine HP, aircraft mass, maximum speed. If flight physics were more accurate I would have mentioned drag coefficients as well, but I think those have little effect on SH aircraft.

gap
08-09-22, 04:50 AM
strategy BombCourseStrafe(Plane)
{
precond
{
Plane:HasCannons() and Plane:CanFireCannons() and Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() > 5 and !Plane:StrafingTooClose()
}
action
{
Plane:Strafe(1.0);
Ship:SetThrottleRatio(1.0);
}
}

strategy BombCourseSlow(Plane)
{
precond
{
Plane:GetContactRelDistOnWater() <= 3500 and Ship:GetContactSpeed() <= 5 and !Plane:StrafingTooClose()
}
action
{
Plane:SetCourseBombs();
#Ship:SetThrottle(1.0);
}
}

Probably I am going to ask some silly questions but...


Does the question mark before a precondition, work the same way as the logical operator 'not' in other programming languages?


Why 'Plane:HasCannons() and Plane:CanFireCannons()'? Wouldn't 'Plane:HasBombs() and Plane:CanFireBombs()' be more logical preconditions for the 'BombCourseStrafe(Plane)' and 'BombCourseSlow(Plane)' strategies?


Do the 'Ship:SetThrottleRatio(1.0)' commands apply to the attacking aircraft or to the attacked sea unit? In the latter case, shouldn't them be part of ship, rather than aircraft, AI strategies?

kapuhy
08-09-22, 05:01 AM
Does the question mark before a precondition, work the same way as the logical operator 'not' in other programming languages?

Exclamation mark? Yes, that's exactly what it does.


Why 'Plane:HasCannons() and Plane:CanFireCannons()'? Wouldn't 'Plane:HasBombs() and Plane:CanFireBombs()' be more logical preconditions for the 'BombCourseStrafe(Plane)' and 'BombCourseSlow(Plane)' strategies?

Jeff's wrote above that Strafe action might not work well without these conditions. I don't see difference in behaviour but added them just in case. As for Plane:HasBombs() and Plane:CanFireBombs(), they are already preconditions to this strategy's parent strategy.

Do the 'Ship:SetThrottleRatio(1.0)' commands apply to the attacking aircraft or to the attacked sea unit? In the latter case, shouldn't them be part of ship, rather than aircraft, AI strategies?
[/LIST]

In this case they apply to the plane.

In SH5, command syntax is:

UnitType:Command(parameters) where unit type might be Plane, Sub or Ship (edit: and, possibly, CostalDefense - it's not used by any scripts but has its own AI commander so... possibly). Now, commands only work with certain types so if you try to write Plane:SetThrottleRatio, game will CTD or ignore command. But if you put Ship:SetThrottleRatio in a strategy used by the plane, game will happily accept it and apply to the plane. I don't know why it works like this, but it does. It was similar with submarine deck guns, which started working after putting "Ship" type condition in their script.

EDIT: by the way,I attach the airplane script as it is now if you or someone else would like to take a look.

gap
08-09-22, 06:52 AM
Exclamation mark? Yes, that's exactly what it does.

Ops, sorry, exclamation mark is what I meant :doh:


Jeff's wrote above that Strafe action might not work well without these conditions. I don't see difference in behaviour but added them just in case. As for Plane:HasBombs() and Plane:CanFireBombs(), they are already preconditions to this strategy's parent strategy.

Well, in common language, 'strafing' is done by attack aircraft when they shoot their cannons while flying low in the sky toward their target. This strategy doesn't encompass the usage of bombs, but apparently this is not the case in SH5. The only shortcoming I see in keeping those preconditions is that, if an aircraft has finished its bullets, it won't attack even though it still has plenty of bombs. Stock aircraft have a nearly endless bullet storage, but we might face a similar problem if we give them a more realistic ammo outfit.
All in all, I think that using Plane:HasBombs() and Plane:CanFireBombs() OR Plane:HasCannons() and Plane:CanFireCannons() as precondition of the parent strategy, might be preferable :hmmm:


In this case they apply to the plane.

In SH5, command syntax is:

UnitType:Command(parameters) where unit type might be Plane, Sub or Ship (edit: and, possibly, CostalDefense - it's not used by any scripts but has its own AI commander so... possibly). Now, commands only work with certain types so if you try to write Plane:SetThrottleRatio, game will CTD or ignore command. But if you put Ship:SetThrottleRatio in a strategy used by the plane, game will happily accept it and apply to the plane. I don't know why it works like this, but it does. It was similar with submarine deck guns, which started working after putting "Ship" type condition in their script.

Maybe devs wanted to implement different throttle commands for different unit types, but at the end they only implemented one for all of them.


EDIT: by the way,I attach the airplane script as it is now if you or someone else would like to take a look.

I will :up:

kapuhy
08-09-22, 07:08 AM
Well, in common language, 'strafing' is done by attack aircraft when they shoot their cannons while flying low in the sky toward their target. This strategy doesn't encompass the usage of bombs, but apparently this is not the case in SH5.

Note on this one: regardless of real word meanings, in SH5 either Strafe or SetCourseBombs are part of Lead strategy telling plane how to fly, and neither causes or denies plane from using its weapons. There is completely separate strategy for this which basically boils down to "If you have weapon X and can fire it - fire it!". So no matter which maneuver the plane is doing at the moment, if it somehow finds itself seeing target in its crosshairs, it should fire.

The problem with SetCourseBombs is, as I see it, that despite its name it does not put the plane in position that is considers correct to drop bombs (unless target is motionless, which leads me to believe problem is connected to not leading the target). So the maneuver part of the script is executed over and over while shooting part waits for target to enter the crosshairs. Strafe behaviour works because it (by pure accident) repeatedly puts the plane in position where it thinks it has a chance to hit.

Jeff-Groves
08-09-22, 07:32 AM
if you try to write Plane:SetThrottleRatio, game will CTD or ignore command. But if you put Ship:SetThrottleRatio in a strategy used by the plane, game will happily accept it and apply to the plane. I don't know why it works like this, but it does.


Maybe this?
https://www.subsim.com/radioroom/picture.php?albumid=1069&pictureid=12670

gap
08-09-22, 08:33 AM
Note on this one: regardless of real word meanings, in SH5 either Strafe or SetCourseBombs are part of Lead strategy telling plane how to fly, and neither causes or denies plane from using its weapons. There is completely separate strategy for this which basically boils down to "If you have weapon X and can fire it - fire it!". So no matter which maneuver the plane is doing at the moment, if it somehow finds itself seeing target in its crosshairs, it should fire.

The problem with SetCourseBombs is, as I see it, that despite its name it does not put the plane in position that is considers correct to drop bombs (unless target is motionless, which leads me to believe problem is connected to not leading the target). So the maneuver part of the script is executed over and over while shooting part waits for target to enter the crosshairs. Strafe behaviour works because it (by pure accident) repeatedly puts the plane in position where it thinks it has a chance to hit.

Okay, I see your point.

Plane:SetCourseBombs tells aircraft to follow a trajectory which in theory should be optimal either for level or dive bombing (depending on sim file setting), but apparently it is bugged and it won't work on moving targets.
Plane:Strafe, on turn, should be more appropriate for cannon strafe runs, but due to the above limitations it happens to increase bombing accuracy over the previous command.

My point is: seeing that Plane:Strafe is the most effective command against moving targets, no matter the weapon used, game AI should trigger the relative strategy if the attacking plane has either gun bullets OR bombs left. With your current script, aircraft won't strafe if they have no cannon / cannon bullets, no matter if they can still drop bombs. That would be correct if strafing was used in game as in real life, and it still is if you want to set up distinct gun strafing and bombing strategies against stationary targets, but it is not according to the new usage you are doing of the said command against fast-moving targets.

I hope I made myself clearer this time. :salute:

Maybe this?
https://www.subsim.com/radioroom/picture.php?albumid=1069&pictureid=12670

:up:

Jeff-Groves
08-09-22, 12:22 PM
I'd think the structure is like this.........

AirPlane.aix is used by the Airplanes.
So Plane:statement checks the Plane for bombs and such.
In there is Ship:command or whatever..... That seems to be jumping to what I pointed out in the Sim settings.
:hmmm:

kapuhy
08-09-22, 01:24 PM
I'd think the structure is like this.........

AirPlane.aix is used by the Airplanes.
So Plane:statement checks the Plane for bombs and such.
In there is Ship:command or whatever..... That seems to be jumping to what I pointed out in the Sim settings.
:hmmm:

Or, even:

https://i.imgur.com/or9Y2Cx.png

If AI is governed by AIcommander controllers (which would be logical, wouldn't it?) then Submarine or Plane AI contains ship AI but not vice versa. Kinda explains why I could get AI sub guns working but similar trick didn't work with torpedoes on surface ships...

Jeff-Groves
08-09-22, 01:35 PM
Maybe the torpedos on suface Ships are looking for the
wpn_SubTorpedoSys Controller?
The AI Subs have that.

I also wonder if we couldn't use the DIVE on AirPlanes and set it to say +5 meters above the water?

gap
08-09-22, 01:47 PM
Or, even:

https://i.imgur.com/or9Y2Cx.png

If AI is governed by AIcommander controllers (which would be logical, wouldn't it?) then Submarine or Plane AI contains ship AI but not vice versa. Kinda explains why I could get AI sub guns working but similar trick didn't work with torpedoes on surface ships...

It makes sense. Besides the ones that we already know, we might find more 'ship' commands which work on ships as well as on other unit types.

Changin of topic, while looking into Airplane.aix I have noticed that several commands accept numeric parameters. Some of them are pretty obvious, e.g. Ship:SetThrottle() where 1.0 means full throttle and 0.0 means engine off, or Ship:TurnToHeading() whose arguments are likely to be angles in degrees, but in most cases their meaning is not so clear. I am under the impression that the parameters accepted by some commands are chances that those commands will be run, but that should be tested. Any ideas? :hmm2:

Jeff-Groves
08-09-22, 01:52 PM
You mean the Random?
I'm thinking the Random numbers are start and final
So if Random(15, 20)
The numbers are drawn from 15 to 20
:hmmm:

gap
08-09-22, 02:17 PM
You mean the Random?
I'm thinking the Random numbers are start and final
So if Random(15, 20)
The numbers are drawn from 15 to 20
:hmmm:

No, Ship:Random is one of those commands whose arguments are pretty obvious. I mean the parameter of commands like Ship:ShipWaitAction, or the second parameter of Ship:TurnToHeading. They seem to always be in the range 0-1 :hmmm:

Else, Plane:Strafe is another of those commands that accept a numeric parameter, but all the instances I found of it go from -20 to 100. Could that be an angle relative to current aircraft heading? :doh:

gap
08-09-22, 02:23 PM
Maybe the torpedos on suface Ships are looking for the
wpn_SubTorpedoSys Controller?
The AI Subs have that.

Do you mean that if we added the wpn_SubTorpedoSys controller to surface units and if we updated ship's .aix file, we could make ships to launch topedoes without using the dummy guns workaround?

Jeff-Groves
08-09-22, 02:27 PM
# void ShipWaitAction(fMinutes) -- action -- ship waits for given time [minutes]
TurnToHeading(newHeading, fThrottle) -- action -- turns ship to a new heading given by "newHeading" [deg] using given throttle (0..1];
# can be used with getbearing/heading functions;

gap
08-09-22, 02:31 PM
# void ShipWaitAction(fMinutes) -- action -- ship waits for given time [minutes]
TurnToHeading(newHeading, fThrottle) -- action -- turns ship to a new heading given by "newHeading" [deg] using given throttle (0..1];
# can be used with getbearing/heading functions;

:yeah:

what about Plane:Strafe, and btw where do you get that information from? :O:

Jeff-Groves
08-09-22, 02:32 PM
It's all listed in the Stock Ship.aix file

But things like Strafe and Flock? No definitions I have found.

gap
08-09-22, 02:37 PM
It's all listed in the Stock Ship.aix file

Okay, I thought you had performed one of your wizard tricks :D

Unfortunately I have not the game installed and I can't check that file. Could you please copy/paste those command syntax instructions for me? :)

Jeff-Groves
08-09-22, 02:39 PM
:/\\!!
:haha:
Give me a minute.

OK. Here it all is,



################################################## #################################################
#
# Ship main:
#
################################################## #####################
################# Tactics methods #####################
################################################## #####################

# void AddRole(RoleID, MinShips, MaxShips)
#
# Adds a role with the given RoleID to the current tactic
#
# MinShips: minimum number of ships that need to be assigned the role
# MaxShips: maximum number of ships that need to be assigned the role

# void AssignRole(RoleID, ShipType, ShipMinSpeed, Option)
#
# Tries to assigns given role to ships of given type which can achieve speeds greater than ShipMinSpeed;
# ships are selected in the order given by Option.
# (ship count is bounded by AddRole params; it tries to add the maximum number of ships given in AddRole)
# If there aren't enough ships in this group, it borrows ships from roles with redundant ships. If there still aren't
# enough ships, the current tactic ends
#
# Option can have one of the values
# ASSIGN_CLOSEST_TO_CONTACT: assigns ships in increasing
# order of distance to contact
# ASSIGN_ANY: assigns ships in no particular order

# int CanContinueCurrentTactic()
#
# Verifies if there are enough ships left in each role for the current tactic;
# returns true if all roles in current tactic have enough ships;
# should be called by the commander of the group

# void EndCurrentTactic()
#
# Terminates current operation (tactic) for all involved ships

# int GetCurrentTacticID()
#
# Returns the current tactic(operation) ID

# int GetCurrentTacticMinShips()
#
# Retrieves the minimum number of ships required by the current tactic

# int GetRole()
#
# Retrieves the role of the current ship.

# bool IsCommander()
#
# True if the current ship is the commander of a group (or is not part of a group)

# int IsRoleInCurrentTactic(RoleID)
#
# Determines if the role given by RoleID is a role of the current tactic.


# void SetLineFormation(RoleID, MaxSlotCount, SpanDist, Orientation) // MaxSlotsCount = 0 => no limit
#
# Sets formation for RoleID as a line consisting of a maximum of MaxSlotCount slots
# that can be occupied by ships in that role, spanning over a distance of Dist meters, and
# the orientation given by Orientation.
#
# RoleID: role for which the formation is configured
# MaxSlotCount: maximum number of ships that can be part of the formation
# (if 0, there can be any number of ships in the formation)
# SpanDist: spanning distance of the formation (total length of the line of ships)
#
# Orientation: can have one of these values
# LINE_ORIENTATION_ACROSS: ships in formation will position themselfes
# perpendicular to the formation's heading
# LINE_ORIENTATION_ALONG: ships in formation will position themselfes
# along the formation's heading (parallel to the heading)

# void SetTactic(TacticID, MinShips)
#
# Sets a tactic (represented by TacticID) as the current tactic followed by this group
# MinShips: minimum number of ships requiered by the tactic; if there aren't at least MinShips ships in the group,
# the tactic is not started

# void WaitForFormation()
#
# Makes current ship wait for its formation to reach destination

################################################## #################
####################### Utility methods ########################
################################################## #################

# void AvoidTorpedoes() Ship tries to avoid torpedoes
# bool CanFireCannons() True if the ship can fire its cannons
# bool CanFireDCRacks() True if DCs can be thrown from DC Racks
# bool CanFireDCThrowers() True if DCs can be thrown from DC Throwers
# bool CanFireHHogs() True if the ship can fire HHogs
# bool CanFireStarShells() True if the ship can fire star shells
# bool CanFollowWaypoint() True if this ship may follow waypoints
# bool ContactDetected() True if a contact has been detected
# bool ContactIs(Type) Returns 1 if contact is the specified type.
# bool ContactIsInsideGroupArea() True if the contact is positioned somewhere between or below merchants in the group
# bool ContactPresenceIs(PresenceType, bOldPresence)
# Returns true if contact has presence of PresenceType.
# If bOldPresence is 1, it will return the old contact presence, else if it is 0, it will return the current contact presence.
# PresenceType can be:
# PRESENCE_LOOKOUT = 0
# PRESENCE_RADAR = 1
# PRESENCE_HYDROPHONE = 2
# PRESENCE_SONAR = 3
# PRESENCE_SENSORS = 15
# PRESENCE_LOOSING = 16
# PRESENCE_NEW = 32
# PRESENCE_PROCESSED = 64
# void FireCannons() Fires cannons
# void FireDCRacks() Fires DC Racks
# void FireDCThrowers() Fires DC Throwers
# void FireHHogs() Fires HHogs
# void FireStarShells() Fires star shells
# void FollowWaypoints(fPatrolRate) The ship follows given waypoints; fPatrolRate dictates how often
# the ship searches around the given waypoint path for threats
# usually, fPatrolRate = SHIP_PATROL_RATE (used in a rate event happen method)
# float GetContactBearing() 0-360 clockwise, 0 = north
# float GetContactDepth() Retrieves contact depth [m]
# float GetContactLostTime() Returns the lost time of our contact. Recomended to use it with ContactPresenceIs(PRESENCE_LOOSING).
# float GetContactRelDist() Distance from ship to contact [m]
# float GetContactSpeed() Returns contact speed [kts]
# int GetCrewRating() Returns crew rating for current ship
# returned values may be:
# CREW_POOR
# CREW_NOVICE
# CREW_COMPETENT
# CREW_VETERAN
# CREW_ELITE
# float GetCurrentHeading() 0-360 clockwise, 0 = north
# float GetCurrentFormationHeading() 0-360 clockwise, 0 = north
# float GetCurrentSpeed() [m/s]
# float GetDamage() Returns the amount of damage inflicted to the ship as a float in [0.0, 1.0]
# 1.0 corresponding to the maximum amount of damage a ship can take
# float GetFormationContactBearing() Retrieves contact bearing relative to the center of the formation
# this ship is part of
# float GetMyWeight() Retrieves ship weight in tons
# int GetShipCountInGroup(ShipType) Returns the number of ships with given type in this ship's group
# int GetShipsDestroyedRecentlyInGroup() Returns the number of ships destroyed in this ship's group since last call or since tactic creation
# if this is the first call of this method

# void Goto(fThrottleRatio, bZigZagOn) Goes forward with given throttleRatio (optionally zigzagging)
# void GotoAction(bZigZag, bUseBreaks, fEpsilon) -- action -- goes forward(optionally zigzagging and/or breaks to
# Achieve desired speed and arrival time) to current destination
# fEpsilon is the acceptable error to destination ( in meters )
# bool HasContacts() True if the ship has enemy contacts
# bool IsDocked() True if the ship is docked
# bool IsNeutral() True if the ship is neutral
# bool IsType(ShipType) True if current ship is of given type
# float Random(a, b) A random real number between a and b
# void SetGotoForwardDist(fDist) Sets destination used by GotoAction at fDist meters in front of the ship; (works with formations)
# void SetGotoDestRelToContact(fDist) Sets destination used by GotoAction; it is relative to main contact (works with formations)
# void SetGotoDestRelToContactKeepFormationOrientation(fD ist) Sets destination at fDist meters from the line that passes through the
# contact's position and perpendicular to current ship/formation heading
# void SetGotoDestRelToGroupCenter(fDist) Sets destination at fDist meters from the center of merchant group center(if no merchants in group,
# destination is set relative to the group commander)
# void SetGotoDestRelToGroupCenterAlongGroupHeading(fDist ) Sets destination at fDist meters from the center of merchant group center(if there
# are no merchants in group, destination is set relative to the group commander)
# void SetRamDestination() Sets destination at contact position for ramming
# void SetSensorFactor(sensorType, factor) Sets a modifier for given sensor type (factor in (0, 1]
# sensorType can have one of the following values:
# SENSOR_LOOKOUT
# SENSOR_RADAR
# SENSOR_HYDROPHONE
# SENSOR_SONAR
# void SetThrottleRatio(fThRatio) Value in [-1, 1]
# void SetThrottle(fThrottle) Value in [-1, 1]

# void ShipWaitAction(fMinutes) -- action -- ship waits for given time [minutes]
# void Spiral(fThrottle, maxSpiralTime, float fStartRudder, float fStopRudder) -- action --
# Spirals around current position with given throttle, for at most maxSprialTime seconds.
# It will interpolate between StartRudder and StopRudder in maxSpiralTime time.
# void StartFiringDCs() Starts firing DCs regardles of distance to contact or contact presence
# void StopFiringDCs() Stops firing DCs unless ships are near contact
# void TimeEventHappen(Minutes) Used to trigger events at given interval of time
# bool TorpedoDetected() True if a torpedo has been detected nearby
# void TurnToHeading(newHeading, fThrottle) -- action -- turns ship to a new heading given by "newHeading" [deg] using given throttle (0..1];
# can be used with getbearing/heading functions;
# void TurnFormationToHeading(newHeading, fThrottle) -- action -- turns the whole formation to a new heading given by "newHeading" [deg] using given throttle (0..1];
# can be used with getbearing/heading functions;

kapuhy
08-09-22, 02:43 PM
Maybe the torpedos on suface Ships are looking for the
wpn_SubTorpedoSys Controller?
The AI Subs have that.

If they were, they would have found one on my test ship :)

No, Ship:Random is one of those commands whose arguments are pretty obvious. I mean the parameter of commands like Ship:ShipWaitAction, or the second parameter of Ship:TurnToHeading. They seem to always be in the range 0-1 :hmmm:

Else, Plane:Strafe is another of those commands that accept a numeric parameter, but all the instances I found of it go from -20 to 100. Could that be an angle relative to current aircraft heading? :doh:

Some of these commands are luckily explained in comments to Ship.aix file. For example, for ShipWaitAction:

# void ShipWaitAction(fMinutes) -- action -- ship waits for given time [minutes]

Unfortunately there are a lot of commands that are not explained anywhere, Strafe being one of them (that's why I asked for meaning of the same numbers earlier in this thread). For those commands I'm afraid we can only find what parameters mean by testing different values and noting what happens.

Edit: ninja'ed :)

Jeff-Groves
08-09-22, 02:52 PM
There are other valid commands NOT listed.
I'm working on a complete listing.
Bad part is there are no details on them.
Now the Dive command is pretty easy to figure out from the Sub files.

I'm also pretty sure CostalDefense will not work as a seperate aix file for a couple reasons.
Doing more digging? Only 3 appear to be stated. Ship, Sub, Plane.
I've also looked at the Land Units in TWoS.
I'll not comment on those at this time. It would end up being like this.
https://www.youtube.com/watch?v=NBGOryiqZZI

kapuhy
08-09-22, 03:01 PM
There are other valid commands NOT listed.
I'm working on a complete listing.
Bad part is there are no details on them.
Now the Dive command is pretty easy to figure out from the Sub files.

To think that somewhere in basement of Ubisoft Romania offices, there probably is a forgotten backup drive with a copy of developer notes explaining all of it... :damn:

Jeff-Groves
08-09-22, 03:04 PM
I'd be surprised if ANYONE knows the whole thing!
There's stuff from SH3, And SH4 still in the files!
:o

gap
08-09-22, 03:29 PM
Thank you both, kapuhy and Jeff, for your patient replies :salute:



I'm also pretty sure CostalDefense will not work as a seperate aix file for a couple reasons.
Doing more digging? Only 3 appear to be stated. Ship, Sub, Plane.

That sound to me like a "no hope" :-?


I've also looked at the Land Units in TWoS.
I'll not comment on those at this time. It would end up being like this.

:haha:

There is no risk of that happening, you are nowhere near the overdone politeness of the average British man lol

TWoS 'land units' are only a workaround. Under many respects they are disappointing, probably they can be improved, but until someone pops up with anything better, they are the only working coastal defenses in SH5 :03:

If they were, they would have found one on my test ship :)

Not if you didn't update Ship.aix to use the torpedo controller, but even so I doubt that it would have worked. No doubt, some ship commands work on other unit types, but there is no evidence of the opposite being true.

Jeff-Groves
08-09-22, 03:41 PM
You can't just 'Throw' a controller in without doing other work.
Not see your test ship with that controller I can't say 'It won't work'.
You have to look at a lot of things that may have an effect.
Even when you think they shouldn't matter? Many times they do!

kapuhy
08-09-22, 03:48 PM
Not if you didn't update Ship.aix to use the torpedo controller, but even so I doubt that it would have worked. No doubt, some ship commands work on other unit types, but there is no evidence of the opposite being true.

I did. Or more specifically I updated ship-weapons.aix with a torpedo strategy.

You can't just 'Throw' a controller in without doing other work.
Not see your test ship with that controller I can't say 'It won't work'.
You have to look at a lot of things that may have an effect.
Even when you think they shouldn't matter? Many times they do!

I'm not saying it can't work, merely that I tried these specific things mentioned, to no effect. I might have done it wrong or forgotten to add something crucial, so don't take it as me discouraging others.

I will dig up my test mod to upload here so that everyone can take a look and hopefully find out any mistakes/omissions.

Jeff-Groves
08-09-22, 03:50 PM
:up:

gap
08-09-22, 07:05 PM
I did. Or more specifically I updated ship-weapons.aix with a torpedo strategy.

Yes that one, as I said before I have not the game files close by hand :up:


I'm not saying it can't work...

I think the chances of it working are very low, but you never know until you try.
Let's see if Jeff can demonstrate that on this specific subject I am too pessimistic :03:

:salute:

Jeff-Groves
08-10-22, 02:19 PM
Mostly I'm playing with the Sub AI.

I'd like to get a Type 14 to raise up out of the depths and stop engines for a ReSupply.
:D
And before you say there is no Type 14?
Yes there is!

kapuhy
08-10-22, 02:31 PM
As promised, my old attempt at making surface ships fire torpedoes:

https://drive.google.com/file/d/1Rg-wsxTctRMPVuzCWo_umGYKvnl0G7zx/view?usp=sharing

It was some time ago so I don't remember exactly what was changed, but I can see I added wpn_SubTorpedoSys to both ship and to torpedo launcher, and added torpedo strategy to the scripts. This didn't work anyway so...

Jeff-Groves
08-10-22, 02:35 PM
Thanks Mate.

I'll look at your work and see if We can get it working.
:up:

If you have mission files for your Aircraft and this? that would save me some time also.
:up:

kapuhy
08-10-22, 03:28 PM
If you have mission files for your Aircraft and this? that would save me some time also.
:up:

Here, along with airplane and sub deck gun script (mind, the last one was just to prove the concept works, so I only modified one of existing attack patterns - it doesn't make sense as actual tactic):

https://drive.google.com/file/d/1ESTfLWgTKjxVFPRJALHgWpOQnHzalxb3/view?usp=sharing

Edit: Surface torpedo script appears to be bugged (if its mission is run, the destroyer not only doesn't use any tubes but doesn't show up as using normal ship scripts...)

Jeff-Groves
08-10-22, 03:53 PM
OK. I got the files. Thanks!
:up:

kapuhy
02-26-23, 09:07 AM
Else, Plane:Strafe is another of those commands that accept a numeric parameter, but all the instances I found of it go from -20 to 100. Could that be an angle relative to current aircraft heading? :doh:

A little late :) but I finally deciphered what the argument of Strafe function means today. It's altitude. Plane will attempt a strafing run keeping close to specified altitude.

At low or negative values this parameter doesn't seem to make any difference, probably because it is overridden by need to avoid impact with water.

Edit: Another complication I see in my testing is that if a plane has fixed machine guns, it will attempt to aim at target leading it to not keep ordered altitude. This might be connected with fighter planes crashing into sea way more often than heavier bombers.

propbeanie
02-26-23, 10:08 AM
Most interesting find :hmmm: - I wonder what "height" the planes begin to get "jittery" and attempt to avoid collision with the water? In SH4, I attempted to have a grouping of torpedo bombers come down to wave top for their anticipated attack runs, and instead they continued to fly at least 200m up. In the game though, with a Betty TB that had spawned from one of the AirBases, while my sub was on the surface travelling (a different experiment), I observed the Betty TB approaching in the distance, most likely at its default 500m height, then "spiral" down, and instead of coming in from my 270 relative, where it had been approaching from, came in from my 235 and was no more than 50m off the water for its attack run, though it did drop too soon, and the torpedo was easily avoided... but if the game can have a plane do that, why can we not call for that behavior?? lol

kapuhy
02-26-23, 01:51 PM
Most interesting find :hmmm: - I wonder what "height" the planes begin to get "jittery" and attempt to avoid collision with the water?

I'll be testing this, but I suspect it will turn out to be their respective minimum height as set in sim file. It would make sense, why else have minimum height set for a plane if you're not using it as a trigger for AvoidImpact action? If so, the jittery behaviour might be result of basically telling the plane "Strafe at around 15 to 20 meters but no lower than 50".

gap
03-10-23, 11:42 AM
A little late :) but I finally deciphered what the argument of Strafe function means today. It's altitude. Plane will attempt a strafing run keeping close to specified altitude.

At low or negative values this parameter doesn't seem to make any difference, probably because it is overridden by need to avoid impact with water.

Cool, thank you for letting us know :up:


Edit: Another complication I see in my testing is that if a plane has fixed machine guns, it will attempt to aim at target leading it to not keep ordered altitude. This might be connected with fighter planes crashing into sea way more often than heavier bombers.

Good point. Fixed aircraft guns have a small elevation/training angle, in the order of few degrees (otherwise they would never fire). Maybe increasing their elevation angle and/or tweaking their firing arcs might alleviate the problem :hmm2:

Most interesting find :hmmm: - I wonder what "height" the planes begin to get "jittery" and attempt to avoid collision with the water? In SH4, I attempted to have a grouping of torpedo bombers come down to wave top for their anticipated attack runs, and instead they continued to fly at least 200m up. In the game though, with a Betty TB that had spawned from one of the AirBases, while my sub was on the surface travelling (a different experiment), I observed the Betty TB approaching in the distance, most likely at its default 500m height, then "spiral" down, and instead of coming in from my 270 relative, where it had been approaching from, came in from my 235 and was no more than 50m off the water for its attack run, though it did drop too soon, and the torpedo was easily avoided... but if the game can have a plane do that, why can we not call for that behavior?? lol

I'll be testing this, but I suspect it will turn out to be their respective minimum height as set in sim file. It would make sense, why else have minimum height set for a plane if you're not using it as a trigger for AvoidImpact action? If so, the jittery behaviour might be result of basically telling the plane "Strafe at around 15 to 20 meters but no lower than 50".

I agree with kapuhy, minimum height might be the main "culprit", but other unrelated AI routines might also interfere. Their existence can be easily tested by setting min. height to very low values