SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 08-08-22, 03:59 PM   #106
kapuhy
Grey Wolf
 
Join Date: Oct 2010
Location: Poland
Posts: 874
Downloads: 72
Uploads: 3
Default

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

Last edited by kapuhy; 08-08-22 at 04:10 PM.
kapuhy is offline   Reply With Quote
Old 08-08-22, 04:05 PM   #107
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,425
Downloads: 131
Uploads: 0


Default

Good job Mate!!


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

Last edited by Jeff-Groves; 08-08-22 at 04:14 PM.
Jeff-Groves is offline   Reply With Quote
Old 08-08-22, 05:01 PM   #108
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by Jeff-Groves View Post
Good job Mate!!
I second that

Quote:
Originally Posted by Jeff-Groves View Post
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.
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 08-09-22, 04:50 AM   #109
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by kapuhy View Post
 
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?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 08-09-22, 05:01 AM   #110
kapuhy
Grey Wolf
 
Join Date: Oct 2010
Location: Poland
Posts: 874
Downloads: 72
Uploads: 3
Default

Quote:
Originally Posted by gap View Post
[*]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.


Quote:
Originally Posted by gap View Post
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.

Quote:
Originally Posted by gap View Post
[*]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.
Attached Files
File Type: txt Airplane.aix.txt (12.7 KB, 5 views)

Last edited by kapuhy; 08-09-22 at 05:37 AM.
kapuhy is offline   Reply With Quote
Old 08-09-22, 06:52 AM   #111
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by kapuhy View Post
Exclamation mark? Yes, that's exactly what it does.
Ops, sorry, exclamation mark is what I meant

Quote:
Originally Posted by kapuhy View Post
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

Quote:
Originally Posted by kapuhy View Post
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.

Quote:
Originally Posted by kapuhy View Post
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
__________________
_____________________
|May the Force be with you!|
...\/

Last edited by gap; 08-09-22 at 07:06 AM.
gap is offline   Reply With Quote
Old 08-09-22, 07:08 AM   #112
kapuhy
Grey Wolf
 
Join Date: Oct 2010
Location: Poland
Posts: 874
Downloads: 72
Uploads: 3
Default

Quote:
Originally Posted by gap View Post
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.

Last edited by kapuhy; 08-09-22 at 07:19 AM.
kapuhy is offline   Reply With Quote
Old 08-09-22, 07:32 AM   #113
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,425
Downloads: 131
Uploads: 0


Default

Quote:
Originally Posted by kapuhy View Post
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?
Jeff-Groves is offline   Reply With Quote
Old 08-09-22, 08:33 AM   #114
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by kapuhy View Post
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.

Quote:
Originally Posted by Jeff-Groves View Post
Maybe this?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 08-09-22, 12:22 PM   #115
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,425
Downloads: 131
Uploads: 0


Default

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.
Jeff-Groves is offline   Reply With Quote
Old 08-09-22, 01:24 PM   #116
kapuhy
Grey Wolf
 
Join Date: Oct 2010
Location: Poland
Posts: 874
Downloads: 72
Uploads: 3
Default

Quote:
Originally Posted by Jeff-Groves View Post
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.
Or, even:



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...
kapuhy is offline   Reply With Quote
Old 08-09-22, 01:35 PM   #117
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,425
Downloads: 131
Uploads: 0


Default

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?

Last edited by Jeff-Groves; 08-09-22 at 01:47 PM.
Jeff-Groves is offline   Reply With Quote
Old 08-09-22, 01:47 PM   #118
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by kapuhy View Post
Or, even:



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?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Old 08-09-22, 01:52 PM   #119
Jeff-Groves
Village Idiot
 
Jeff-Groves's Avatar
 
Join Date: Sep 2014
Posts: 5,425
Downloads: 131
Uploads: 0


Default

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
Jeff-Groves is offline   Reply With Quote
Old 08-09-22, 02:17 PM   #120
gap
Navy Seal
 
Join Date: Jan 2011
Location: CJ8937
Posts: 8,215
Downloads: 793
Uploads: 10
Default

Quote:
Originally Posted by Jeff-Groves View Post
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
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

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?
__________________
_____________________
|May the Force be with you!|
...\/
gap is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 07:35 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.