Special Aircraft Service

Please login or register.

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

Author Topic: How to add and or alter aircraft damage effects?  (Read 752 times)

0 Members and 1 Guest are viewing this topic.

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5592
How to add and or alter aircraft damage effects?
« on: December 23, 2020, 12:33:19 AM »

A while back I d/I'd the IES P-43 (can't remember exactly where I got it from  ;)  ), but never got round to installing it. A couple days ago I did, and found that it behaves as one helluva tough crate! It gives the vaunted Jug a real run for the title of durable.

Among the hundreds I've blasted in testing, *not a single one* has exhibited more than these two effects; oil damage and the lightest engine damage smoke. That's it.

No fuel leak ever.
No fire ever.
No heavy smoke ever.

The gear does drop a bit when damaged. Ailerons are torn off. Wings break off. Pilots die. The plane can explode in mid-air.

But most damage smokes, and no fires can ever seem to be generated.

I've read that this bird had 'wet wings', meaning fuel tanks in the wings. No self-sealing capability in general (at least for the A series), and there was frequent leaking. It was reported that fires were a significant threat.

This has inspired me to try my hand for the first time at creating damage effect hooks and hit boxes.

So I tried to incorporate this fire hazard  by adding new hooks for tank leaks and fires, and adding new hit boxes for the wing tanks. I also ensured the plane class code would handle all tanks. There are no errors popping up, but still I just can never get a fuel leak or fire from the wings. And I'm hitting with tons of MG and cannon shells.

Now, the newly added fuel tank hit boxes in the wings overlap with the existing inner wing and wing spar hit boxes. To (hopefully) ensure the tank boxes would be hit, I made them for the time being fairly thicker than the others, in order that bullets would intercept them first.

I figure that some overlap among hit boxes should pose no problem, given that the landing gear hit boxes during flight are essentially buried completely inside the wing hit boxes, yet gear damage is clearly registering.

Is there some not obvious thing I'm missing?
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)

FL2070

  • Modder
  • member
  • Offline Offline
  • Posts: 1138
  • FAC #87
Re: How to add and or alter aircraft damage effects?
« Reply #1 on: December 23, 2020, 01:19:04 AM »

Have you tried looking at the java classes? It seems to me that things like fuel tank fires are initiated by code in a plane's hitBone method (usually found in plane type superclasses, not the subclasses of individual types). For instance, in B_17.class, I found:



I've never messed with these to see what they do, so I don't know for sure, but it may be worthwhile to check the plane's code for missing parts of the hitBone method.
Logged
On average, the average average averages, averagely, the average average of all averages.

WxTech

  • Modder
  • member
  • Offline Offline
  • Posts: 5592
Re: How to add and or alter aircraft damage effects?
« Reply #2 on: December 23, 2020, 05:33:11 AM »

Flight Level,
Thanks for chiming in!

I did mention briefly mention that I made sure in the plane class that the tanks were handled correctly. The original code is there, and I named my new tank hit boxes accordingly. I even used values for the Val, and a couple slight variations of the code as seen in other plane classes.

But it remains stubbornly impossible to generate the slightest change.

Next I'll try as a test shrinking the two hit boxes for the inner wing, so as to leave a clear gap between for the new tank hit box to sit without any overlap. Just in case overlap is a no no. (But as I pointed out, that the gear hit box when retracted is inside other hit boxes would suggest overlap shouldn't be the problem.)
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: 5592
Re: How to add and or alter aircraft damage effects?
« Reply #3 on: December 23, 2020, 07:42:07 PM »

I found the problem.

First, I did rearrange the three hit boxes so as to have no overlap. But that didn't help.

Then I got to looking more broadly at the hitBone method in the plane class. This popped out in the code...

The first condition

            if(s.startsWith("xx"))
            {


neglects any following conditions such as

        if(s.startsWith("xxarmor"))

because of the closing

            return;
        }

thus exiting this test condition before being able to assess any of those many other following test conditions where the string does start with "xx". It exits out early all the time if a hit box starts with ''xx", missing the many others below the "xxarmor" and "xxeng" ones. If, say, my new "xxtank2" is hit, the method sees and does nothing because it limits to only "xxarmor" and "xxeng", exiting hitBone and thus making for far stronger plane (devoid of other damage smokes/fires.)



Code: [Select]
    protected void hitBone(String s, Shot shot, Point3d point3d)
    {
        if(s.startsWith("xx"))
        {
            if(s.startsWith("xxarmor"))
            {
                if(s.endsWith("p1"))
                    getEnergyPastArmor(8.26F / (Math.abs((float)((Tuple3d) (Aircraft.v1)).x) + 1E-005F), shot);
                return;
            }
            if(s.startsWith("xxeng"))
            {
                int i = s.charAt(5) - 49;
                if(s.endsWith("case"))
                {
                    if(getEnergyPastArmor(1.7F, shot) > 0.0F)
                    {
                        if(World.Rnd().nextFloat(20000F, 140000F) < shot.power)
                            ((FlightModelMain) (super.FM)).AS.setEngineStuck(shot.initiator, i);
                        if(World.Rnd().nextFloat(10000F, 50000F) < shot.power)
                            ((FlightModelMain) (super.FM)).AS.hitEngine(shot.initiator, i, 2);
                    } else
                    if(World.Rnd().nextFloat() < 0.04F)
                        ((FlightModelMain) (super.FM)).EI.engines[i].setCyliderKnockOut(shot.initiator, 1);
                    else
                        ((FlightModelMain) (super.FM)).EI.engines[i].setReadyness(shot.initiator, ((FlightModelMain) (super.FM)).EI.engines[i].getReadyness() - 0.02F);
                    getEnergyPastArmor(12F, shot);
                }
                if(s.endsWith("cyls"))
                {
                    if(getEnergyPastArmor(0.85F, shot) > 0.0F && World.Rnd().nextFloat() < ((FlightModelMain) (super.FM)).EI.engines[i].getCylindersRatio() * 0.9878F)
                    {
                        ((FlightModelMain) (super.FM)).EI.engines[i].setCyliderKnockOut(shot.initiator, World.Rnd().nextInt(1, (int)(shot.power / 19000F)));
                        if(World.Rnd().nextFloat() < shot.power / 48000F)
                            ((FlightModelMain) (super.FM)).AS.hitEngine(shot.initiator, 0, 2);
                    }
                    getEnergyPastArmor(25F, shot);
                }
                if(s.endsWith("supc"))
                {
                    if(getEnergyPastArmor(0.05F, shot) > 0.0F)
                        ((FlightModelMain) (super.FM)).EI.engines[i].setKillCompressor(shot.initiator);
                    getEnergyPastArmor(2.0F, shot);
                }
                if(s.endsWith("oil1") && World.Rnd().nextFloat() < 0.5F && getEnergyPastArmor(0.25F, shot) > 0.0F)
                    ((FlightModelMain) (super.FM)).AS.hitOil(shot.initiator, 0);
            }
            return;
        }   // <----------------------------------THIS IS THE BAD PLAYER -- NEEDS TO FOLLOW ALL startsWith("xx*")----------------------------
        if(s.startsWith("xxmgun"))
        {

and so on...

This is proper...

Code: [Select]
    protected void hitBone(String s, Shot shot, Point3d point3d)
    {
        if(s.startsWith("xx"))
        {
            if(s.startsWith("xxarmor"))
            {
                if(s.endsWith("p1"))
                    getEnergyPastArmor(8.26F / (Math.abs((float)((Tuple3d) (Aircraft.v1)).x) + 1E-005F), shot);
                return;
            }
            if(s.startsWith("xxeng"))
            {
                int i = s.charAt(5) - 49;
                if(s.endsWith("case"))
                {
                    if(getEnergyPastArmor(1.7F, shot) > 0.0F)
                    {
                        if(World.Rnd().nextFloat(20000F, 140000F) < shot.power)
                            ((FlightModelMain) (super.FM)).AS.setEngineStuck(shot.initiator, i);
                        if(World.Rnd().nextFloat(10000F, 50000F) < shot.power)
                            ((FlightModelMain) (super.FM)).AS.hitEngine(shot.initiator, i, 2);
                    } else
                    if(World.Rnd().nextFloat() < 0.04F)
                        ((FlightModelMain) (super.FM)).EI.engines[i].setCyliderKnockOut(shot.initiator, 1);
                    else
                        ((FlightModelMain) (super.FM)).EI.engines[i].setReadyness(shot.initiator, ((FlightModelMain) (super.FM)).EI.engines[i].getReadyness() - 0.02F);
                    getEnergyPastArmor(12F, shot);
                }
                if(s.endsWith("cyls"))
                {
                    if(getEnergyPastArmor(0.85F, shot) > 0.0F && World.Rnd().nextFloat() < ((FlightModelMain) (super.FM)).EI.engines[i].getCylindersRatio() * 0.9878F)
                    {
                        ((FlightModelMain) (super.FM)).EI.engines[i].setCyliderKnockOut(shot.initiator, World.Rnd().nextInt(1, (int)(shot.power / 19000F)));
                        if(World.Rnd().nextFloat() < shot.power / 48000F)
                            ((FlightModelMain) (super.FM)).AS.hitEngine(shot.initiator, 0, 2);
                    }
                    getEnergyPastArmor(25F, shot);
                }
                if(s.endsWith("supc"))
                {
                    if(getEnergyPastArmor(0.05F, shot) > 0.0F)
                        ((FlightModelMain) (super.FM)).EI.engines[i].setKillCompressor(shot.initiator);
                    getEnergyPastArmor(2.0F, shot);
                }
                if(s.endsWith("oil1") && World.Rnd().nextFloat() < 0.5F && getEnergyPastArmor(0.25F, shot) > 0.0F)
                    ((FlightModelMain) (super.FM)).AS.hitOil(shot.initiator, 0);
            return;
//        }   <----------------------------------MOVED TO END OF ALL startsWith("xx*")----------------------------
        if(s.startsWith("xxmgun"))
        {

and so on.....
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: 5592
Re: How to add and or alter aircraft damage effects?
« Reply #4 on: December 23, 2020, 07:58:57 PM »

Solved! The moving of that single closing curly bracket farther down so as to enclose ALL startsWith("xx*") conditions is what was needed.

I've edited this and the previous post to reflect the better approach. My first try was to remove the

    if(s.startsWith("xx")
    {

and its closing

    }

But this only forced the potentially needless progressing through all instances of startsWith("xx*") checks if a different hit box not starting with "xx" is involved.

Because of the large number of hit boxes starting with "xx", it makes sense to enclose all of them with a first check, to exclude right away their consideration if a different starting string applies.
Logged
Great minds discuss ideas. Average minds discuss events. Small minds discuss people. - Hyman Rickover (but probably predating his use.)
Pages: [1]   Go Up
 

Page created in 0.089 seconds with 26 queries.