Loading [MathJax]/extensions/Safe.js

Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2] 3   Go Down

Author Topic: Work on the old Random Failure Mod...  (Read 962 times)

0 Members and 1 Guest are viewing this topic.

DarkenedFantasies

  • member
  • Offline Offline
  • Posts: 13
Re: Work on the old Random Failure Mod...
« Reply #12 on: March 19, 2025, 03:21:05 PM »

I was hasty in suggesting success at reading entries from conf.ini. I had just written the code and not tested carefully enough. It turns out that I can't read from conf.ini from this Aircraft.class. Here's a common implementation

Config.cur.ini.get("Mods", "ReliabilityDiffRequired", 0)

Is there any way I can query conf.ini from Aircraft.class?
I don't see why not. You do have il2.engine.Config imported in Aircraft.class? Or does it compile and you're just not getting the defined value in-game? Perhaps a typo where the .mis definition is always taken even when missing?

For efficiency, I think I would get the value from conf.ini only once in World.class, write it to a World class member, and simply access that variable in Aircraft.class. Ditto with the .mis value, but Mission.class instead of World.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #13 on: March 19, 2025, 05:29:36 PM »

I was hasty in suggesting success at reading entries from conf.ini. I had just written the code and not tested carefully enough. It turns out that I can't read from conf.ini from this Aircraft.class. Here's a common implementation

Config.cur.ini.get("Mods", "ReliabilityDiffRequired", 0)

Is there any way I can query conf.ini from Aircraft.class?
I don't see why not. You do have il2.engine.Config imported in Aircraft.class? Or does it compile and you're just not getting the defined value in-game? Perhaps a typo where the .mis definition is always taken even when missing?

For efficiency, I think I would get the value from conf.ini only once in World.class, write it to a World class member, and simply access that variable in Aircraft.class. Ditto with the .mis value, but Mission.class instead of World.

Thanks for the input!

Yep, Config is imported via
  import com.maddox.il2.engine.*;

The code compiles, but the values returned are zero if I don't instantiate them. For example, 

  Config.cur.ini.get("Mods", "ReliabilityDiffRequired", 4)

Would return "4", not the value "1"  I would have like this in conf.ini:

  ReliabilityDiffRequired=1

Being barely a Neandertheralic non-programmer who knows almost enough to get into trouble, I haven't the smarts to proceed further. You suggested "...write it to a World class member, and simply access that variable in Aircraft.class." I've stumbled toward trying this, but no joy yet. How to do it?   :-|
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #14 on: March 19, 2025, 06:31:51 PM »

Here's where I'm at right now. In the following I include the configurable long visual distance mod elements as well, which do work. I'm getting values at run time of "2" (I use HUD.training() to write info to the screen), which are the instantiated values. I'm supposed to be getting "1" and "0". This is baffling...

In World.World():
Code: [Select]
public World()
{
MaxVisualDistance = Config.cur.ini.get("Mods", "MaxVisualDistance", MaxVisualDistance);
MaxStaticVisualDistance = Config.cur.ini.get("Mods", "MaxStaticVisualDistance", MaxStaticVisualDistance);
MaxLongVisualDistance = Config.cur.ini.get("Mods", "MaxLongVisualDistance", MaxLongVisualDistance);
MaxPlateVisualDistance = Config.cur.ini.get("Mods", "MaxPlateVisualDistance", MaxPlateVisualDistance);
.
.
.
Reliability = Config.cur.ini.get("Mods", "ReliabilityDiffRequired", Reliability);
FailRateSource = Config.cur.ini.get("Mods", "FailureRateSource", FailRateSource);
}

public static float MaxVisualDistance = 5000F;
public static float MaxStaticVisualDistance = 4000F;
public static float MaxLongVisualDistance = 10000F;
public static float MaxPlateVisualDistance = 16000F;
.
.
.
public static float Reliability = 2F;  //NEW, for Aircraft.class; 0 or 1; 0 = Reliability Difficulty setting NOT required, 1 = IS REQUIRED
public static float FailRateSource = 2F;  //NEW, for Aircraft.class; 0 or 1; in conf.ini (format: FailureRateSource=1)

In Aircraft.rareAction(), where the operative code resides:
Code: [Select]
public void rareAction(float f, boolean flag)
{
float Reliability;
Reliability = World.Reliability;
iReliability = (int) Reliability;

float FailRateSource;
FailRateSource = World.FailRateSource;
iFailRateSource = (int) FailRateSource;
.
.
.
}

In conf.ini:
Code: [Select]
[Mods]
MaxVisualDistance=16000
MaxStaticVisualDistance=6000
MaxLongVisualDistance=16000
MaxPlateVisualDistance=16000
.
.
.
FailureRateSource=1  //0 or 1; 0 prioritizes .mis file value, 1 prioritizes THIS conf.ini value
ReliabilityDiffRequired=0  //0 or 1; 0 = Reliability Difficulty setting NOT required, 1 = Reliability Difficulty IS REQUIRED
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

DarkenedFantasies

  • member
  • Offline Offline
  • Posts: 13
Re: Work on the old Random Failure Mod...
« Reply #15 on: March 19, 2025, 06:51:28 PM »

As it currently stands, the only reason I can think of would be that you're modifying the wrong conf.ini file, whereas the actual file still doesn't have the ReliabilityDiffRequired line. If you change something else (MaxVisualDistance for example) and print the value on screen, do you get the correct value then? Just to be sure, set the value to a number you know wouldn't exist in another conf.ini file.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #16 on: March 19, 2025, 08:32:03 PM »

When I display a couple of the visual distance values which are different as instantiated versus as set in conf.ini, I do indeed get the correct values from conf.ini. But the two items under consideration here remain stubbornly unable to be passed from conf.ini. So puzzling why the same structure works for one but not the other. And I've definitely not got some other conf.ini floating about.  ;)

Here's what I've put in method rareAction() to query the values:

  HUD.training("MaxStaticVisDist= " + World.MaxStaticVisualDistance + " Reliability= " + World.Reliability + " FailSource= " + World.FailRateSource);
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

DarkenedFantasies

  • member
  • Offline Offline
  • Posts: 13
Re: Work on the old Random Failure Mod...
« Reply #17 on: March 19, 2025, 09:13:38 PM »

Okay, I think I know why. The game doesn't expect comments on the same line, so they don't get trimmed out of the string, and are causing an exception when it tries to parse the numerical value. Since it's inside of a try-catch statement and the exception gets ignored, nothing shows up in the log file and it silently defaults to the fallback value (in this case the initialization value).

The semi-colon ( ; ) is what is used in the conf.ini file for marking a line to be ignored, and only so if it's the first character on the line. It will have no effect anywhere else on the line, and the double-slash doesn't appear to have any meaning at all.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #18 on: March 20, 2025, 12:56:27 AM »

DarkenedFantasies,
You brought some brightened reality!  ]thumleft[  That cleaning up of the formatting in conf.ini the trick, and now I can query conf.ini from within Aircraft.rareAction(), without involving World.class.

Thanks a bunch!
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #19 on: March 20, 2025, 01:56:23 AM »

To assess what's going on during the testing phase of a mod I sometimes direct specific output to log.lst. Here all events initiated for all 14 single-engined fighters in a furball I just played are listed, with about 2 events per plane on average during the nearly 5 minute period of the fight. I had the probability set to maximum, to get a fair sample of events. If I had set the probability from 100 down to 1, the same number of events would be expected to require about 8 hours.

Again, compared to the original implementation of this mod of more than a decade ago, I have reduced the initial damage inflicted in a few instances, as well as limit how bad it can get. That is, once something like light engine damage is established, this mod will not add to that damage; it would require another external cause, or it would result from ongoing intrinsic degradation.

I have implemented user control as follows:

1) The player can elect to require this mod to operate ONLY when the Difficulty setting Reliability is ON, or to ignore that Difficulty setting and operate anyway.

2) The failure rate value can be placed in the [Mods] section of conf.ini and/or a mission file. The player can choose to give priority to one or the other if both files have an entry. If only one file has a failure rate entry and one prioritizes the other file as the source, the mod will NOT operate, treating the lack of a failure rate value as zero. I may structure things so that if the .mis file entry is prioritized but is missing, the conf.ini value will still be used. In this way one can have a general failure rate always in operation, but with certain missions having a different failure rate.


Code: [Select]
[2025-03-20 07:27:49.324] dT:  244 iRandom=31       MAGNETO #1 kill eng#1
[2025-03-20 07:27:50.519] dT:   40 iRandom=31       MAGNETO #1 kill eng#1
[2025-03-20 07:27:58.706] dT:  273 iRandom=56       CYLINDER knock-out eng#1
[2025-03-20 07:28:16.167] dT:  582 iRandom=56       CYLINDER knock-out eng#1
[2025-03-20 07:28:26.828] dT:  355 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:28:34.619] dT:  260 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:28:49.268] dT:  488 iRandom=24       OIL light damage (setOilState=1) eng#1
[2025-03-20 07:28:50.225] dT:   32 iRandom=62       FUEL TANK damage (initiate 1st small leak) tank#1
[2025-03-20 07:28:59.161] dT:  298 iRandom=56       CYLINDER knock-out eng#1
[2025-03-20 07:28:59.404] dT:    8 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:29:03.132] dT:  124 iRandom=56       CYLINDER knock-out eng#1
[2025-03-20 07:29:03.814] dT:   23 iRandom=56       CYLINDER knock-out eng#1
[2025-03-20 07:29:07.624] dT:  127 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:29:16.924] dT:  310 iRandom=24       OIL light damage (setOilState=1) eng#1
[2025-03-20 07:29:19.386] dT:   82 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:29:26.215] dT:  228 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:29:27.327] dT:   37 iRandom=31       MAGNETO #1 kill eng#1
[2025-03-20 07:29:44.728] dT:  580 iRandom=24       OIL light damage (setOilState=1) eng#1
[2025-03-20 07:29:59.047] dT:  477 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:30:01.887] dT:   95 iRandom=11       kill ENGINE eng#1
[2025-03-20 07:30:23.728] dT:  728 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:30:46.805] dT:  769 iRandom=24       OIL light damage (setOilState=1) eng#1
[2025-03-20 07:30:48.847] dT:   68 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:31:03.969] dT:  504 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:31:09.205] dT:  175 iRandom=32       MAGNETO #0 kill eng#1
[2025-03-20 07:31:23.224] dT:  467 iRandom=24       OIL light damage (setOilState=1) eng#1
[2025-03-20 07:31:27.127] dT:  130 iRandom=31       MAGNETO #1 kill eng#1
[2025-03-20 07:31:31.528] dT:  147 iRandom=31       MAGNETO #1 kill eng#1
[2025-03-20 07:32:00.718] dT:  973 iRandom=11       Engine light damage (hitEngine, to state 1) eng#1
[2025-03-20 07:32:28.291] dT:  919 iRandom=24       OIL light damage (setOilState=1) eng#1
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

GeraltNotRivia

  • member
  • Offline Offline
  • Posts: 38
Re: Work on the old Random Failure Mod...
« Reply #20 on: March 20, 2025, 03:04:49 AM »

Can you outsource failure messages to hud_log.properties file, so it would be easier to translate texts from english to another language without hex-editor or some otherway?
I would appreciate if you can.
Logged

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #21 on: March 20, 2025, 04:21:56 AM »

Those messages I presented in my previous post are written with more specific detail so that I can keep track of the coded actions and their results as I test. They are quite different from the messages sent to the screen during play.

The simple, fixed format messages which are able to be easily translated by a properties file are handled by HUD.log(). But here almost all are handled by HUD.log(AircraftHotKeys.hudLogWeaponId,...). I'm not sure why, and haven't delved into that yet. But those messages are constructed dynamically to include a variable such as the engine number. That makes the translation task much more complicated. In any event, those messages sent to the screen for the player are reasonably simple, certainly rather more so that what I've put together for my own development aid and posted in my last message  ;)
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 6205
Re: Work on the old Random Failure Mod...
« Reply #22 on: March 20, 2025, 12:08:45 PM »

I've added another control for conf.ini, which allows to apply a bias in favour of the player, if desired. If we consider the base probability for AI failures as 1.0, the player can choose to apply the same probability to himself, or reduce it all the way down to 1/10 as likely as for AI. The purpose of this is to reduce the fear and aggravation, and increase the fun factor, while still enjoying the randomness of the fates. In a more extreme setup, the fail rate probability could be set fairly high (30-100) and the player bias could be set to the minimum of 0.1 (10%). This would have the player suffering random failures only 1/10 as often as the AI, thus having the little silicon aircrew sweating hard while the player is comparatively immune.  ;D

I find that setting the Difficulty option for Reliability is a harsh enough mistress, with not much forgiveness of hard treatment of one's engine(s). And more so when this mod is active as well. When using this mod it's arguably needlessly tough to have the Reliability Difficulty toggled on as well. I certainly prefer to use one, and not both together. The Reliability option concerns the motor only, while this mod deals with the motor and other systems and so is more varied.

Anyway, as mentioned in a previous post I do offer a control that allows to use this mod either only when the Reliability difficulty setting is on, or without the Reliability option having to be toggled on.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

GeraltNotRivia

  • member
  • Offline Offline
  • Posts: 38
Re: Work on the old Random Failure Mod...
« Reply #23 on: March 20, 2025, 12:59:34 PM »

Quote
But those messages are constructed dynamically to include a variable such as the engine number. That makes the translation task much more complicated. In any event, those messages sent to the screen for the player are reasonably simple, certainly rather more so that what I've put together for my own development aid and posted in my last message  ;)

Okay, good to know!

Quote
I've added another control for conf.ini, which allows to apply a bias in favour of the player, if desired. If we consider the base probability for AI failures as 1.0, the player can choose to apply the same probability to himself, or reduce it all the way down to 1/10 as likely as for AI.

This applies to AI in general and not just enemy AI, or is it possible to do mission where e.g early war Soviet or late war Germany as a enemy can get higher change to failure, but not your own AI buddies? Or is it even possible to define these in any way from each other, like blue get higher failure rate than red and vice versa?

And sorry, if I have too many questions and wishes. Just excited here.  :-[
Logged
Pages: 1 [2] 3   Go Up
 

Page created in 0.045 seconds with 20 queries.