KSPModStewards / RocketSoundEnhancement

An Audio Framework Plugin for Kerbal Space Program
https://forum.kerbalspaceprogram.com/index.php?/topic/179579-wip15x-rocket-sound-enhancement-pre-v100/
GNU General Public License v3.0
14 stars 13 forks source link

Compatibility to RO's ModuleEngineConfigs #3

Closed Gordon-Dry closed 4 years ago

Gordon-Dry commented 5 years ago

Engines with no maxThrust in ModuleEngines are prone to be modded by RealismOverhaul, they got a ModuleEngineConfigs and the syntax is changed from `volume = #$/MODULE[ModuleEngines]/maxThrust$ to volume = #$/MODULE[ModuleEngineConfigs]/CONFIG,0/maxThrust$`

So only the first/default config is taken into account, but better then nothing/MM errors, right?

And some syntax fixing: volume = #$../../../MODULE[ModuleEngines*]/maxThrust$ is not needed, volume = #$/MODULE[ModuleEngines*]/maxThrust$ does the job very well.

Gordon-Dry commented 5 years ago

I really need some brain vitamins now - there are no MM errors anymore, but the patches are just not applied.

Sometimes errors tell the truth and are the way to a solution ...

But "nothing" does not help at all.

yelp!

Gordon-Dry commented 5 years ago

I found it - brain fart!

Gordon-Dry commented 5 years ago

Something else I stumble upon. Nested variable search... And again I found the limits of the possibilities of MM syntax.

lukecologne commented 5 years ago

You could simplify into a universal patch:

@PART[*]:HAS[@MODULE[ModuleEngines*]:HAS[~maxThrust[]]&@MODULE[ModuleEngineConfigs]]:AFTER[RealismOverhaulEngines]:NEEDS[RealismOverhaul]
{
    @MODULE[ModuleEngines*]
    {
        %maxThrust = #$../MODULE[ModuleEngineConfigs]/CONFIG[*]/maxThrust$
    }
}
Gordon-Dry commented 5 years ago

@lukecologne I will try that, thanks. Then I can stop bothering blowfish, haha.

Gordon-Dry commented 5 years ago

Hmm. Or not. See https://forum.kerbalspaceprogram.com/index.php?/topic/50533-140-16x-module-manager-402-february-3rd-2019-right-to-ludicrous-speed/&do=findComment&comment=3606200 and followed. I think the problem is different then your solution approach could help out, unfortunately.

Gordon-Dry commented 5 years ago

I guess I got it. I had to remove the mod and have a ModuleManager.ConfigCache created and carefully investigate. I will test this now: @PART[*]:HAS[@EFFECTS:HAS[@Ammonialox],@MODULE[ModuleEngineConfigs]:HAS[#type[ModuleEngines*]]]:FOR[zzRocketSoundEnhancement]:NEEDS[RealPlume,RealismOverhaul]

Gordon-Dry commented 5 years ago

Or even this to be absolutely sure, kinda double failsafe: @PART[*]:HAS[@EFFECTS:HAS[@Ammonialox],@MODULE[ModuleEngineConfigs]:HAS[#origMass[>0],#type[ModuleEngines*]]]:FOR[zzRocketSoundEnhancement]:NEEDS[RealPlume,RealismOverhaul]

Gordon-Dry commented 5 years ago

Why do I always try to fiddle with patches that have a built-in borderline syndrome?

Could it simply be that the patching by FOR[zzRocketSoundEnhancement] happens too early when RO is installed?

Now I got a patch without MM errors that still doesn't do anything.

So I try it with FOR[zzzRocketSoundEnhancement]:NEEDS[RealPlume,RealismOverhaul]

lukecologne commented 5 years ago

I think the problem is that you call the value = #$/MODULE[ModuleEngineConfigs]/CONFIG[*]/maxThrust$ inside the EFFECTS/Ammonialox/RSEAudio nodes. You have to step out of these nodes first, in order for the ModuleManager to find the ModuleEngineConfigs: volume = #$/../../../MODULE[ModuleEngineConfigs]/CONFIG[*]/maxThrust$ Maybe this works.

lukecologne commented 5 years ago

You said my general solution wouldn't work, but I tested it out and MM didn't throw any errors, and there weren't any sound bugs, so for me, it seems to work.

lukecologne commented 5 years ago

As you see here, this is also how it is done in the originial patch. (referring to my second comment)

Gordon-Dry commented 5 years ago

$/MODULE means from the root.

The ../../ thingie is not necessary anymore.

Check this (now 5 years old) post. https://forum.kerbalspaceprogram.com/index.php?/topic/50533-140-16x-module-manager-402-february-3rd-2019-right-to-ludicrous-speed/&do=findComment&comment=1402467

Which btw is also linked in the https://github.com/sarbian/ModuleManager/wiki/Module-Manager-Syntax

Gordon-Dry commented 5 years ago

And for some other reason this is not the point. I got no MM errors and the AUDIO is not replaced by the RSE_AUDIO.

So the first line, @PART already has problems when RO / RP-1 is installed.

lukecologne commented 5 years ago

Ok, thanks for the info, I didn't know that the ../ isn't necessery. But still, my patch seems to work. Without it, I get MM errors and sound-bugs, and with it, they are fixed. Maybe you could test them out and check if they work for you as well.

Gordon-Dry commented 5 years ago

With a fully modded RO / RP-1 install environment?

And btw this is the actual code in question - feel free to compare it to yours. (1st block is modified original code, 2nd block is for RealismOverhaul) GameData\RocketSoundEnhancement\Patches\Ammonialox.cfg

@PART[*]:HAS[@EFFECTS:HAS[@Ammonialox],@MODULE[@ModuleEngines*]:HAS[#maxThrust[>0]]]:NEEDS[RealPlume]:FOR[ZZROCKETSOUNDENHANCEMENT]
{
    @EFFECTS
    {
        @Ammonialox
        {
            !AUDIO{}
            RSE_AUDIO
            {
                name = running
                channel = Ship
                clip = RocketSoundEnhancement/Sounds/sound_lqd_light
                rolloffMode = Linear
                maxDistance = 10000

                lowpass = 0 1 -130.8109 -130.8109
                lowpass = 0.016 0.256 -5.289068 -5.289068
                lowpass = 0.064 0.128 -1.238469 -1.238469
                lowpass = 0.256 0.064 -0.15625 0
                lowpass = 1 0.064

                volume = 0.0 0.0
                volume = #$/MODULE[ModuleEngines*]/maxThrust$

                @volume,1 /= 1000
                @volume,1 += 1
                @volume,1 /= 2
                @volume,1 ^= :^:0.1 :

                pitch = 0.0 0.2
                pitch = 1.0 0.5

                loop = true
            }
        }
        @engage
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_vent_medium
                volume = #$/MODULE[ModuleEngines*]/maxThrust$

                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
        @disengage
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_vent_soft
                volume = #$/MODULE[ModuleEngines*]/maxThrust$

                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
        @flameout
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_explosion_low

                volume = #$/MODULE[ModuleEngines*]/maxThrust$
                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
    }
}

@PART[*]:HAS[@EFFECTS:HAS[@Ammonialox],@MODULE[@ModuleEngines*]:HAS[~maxThrust[>0]],@MODULE[ModuleEngineConfigs]:HAS[~type[ModuleRCS],#origMass[>0],@CONFIG:HAS[#maxThrust[>0]]]]:NEEDS[RealPlume,RealismOverhaul]:LAST[ZZROCKETSOUNDENHANCEMENT]
{
    @EFFECTS
    {
        @Ammonialox
        {
            !AUDIO{}
            RSE_AUDIO
            {
                name = running
                channel = Ship
                clip = RocketSoundEnhancement/Sounds/sound_lqd_light
                rolloffMode = Linear
                maxDistance = 10000

                lowpass = 0 1 -130.8109 -130.8109
                lowpass = 0.016 0.256 -5.289068 -5.289068
                lowpass = 0.064 0.128 -1.238469 -1.238469
                lowpass = 0.256 0.064 -0.15625 0
                lowpass = 1 0.064

                volume = 0.0 0.0
                volume = #$/MODULE[ModuleEngineConfigs]/CONFIG/maxThrust$

                @volume,1 /= 1000
                @volume,1 += 1
                @volume,1 /= 2
                @volume,1 ^= :^:0.1 :

                pitch = 0.0 0.2
                pitch = 1.0 0.5

                loop = true
            }
        }
        @engage
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_vent_medium
                volume = #$/MODULE[ModuleEngineConfigs]/CONFIG/maxThrust$

                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
        @disengage
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_vent_soft
                volume = #$/MODULE[ModuleEngineConfigs]/CONFIG/maxThrust$

                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
        @flameout
        {
            !AUDIO{}
            AUDIO
            {
                channel = Ship
                clip = sound_explosion_low

                volume = #$/MODULE[ModuleEngineConfigs]/CONFIG/maxThrust$
                @volume /= 1000
                @volume += 1
                @volume /= 2

                pitch = 2.0
                loop = false
            }
        }
    }
}
lukecologne commented 5 years ago

My patch fixes the underlying problem, which is that in some cases, ModuleEngines dont have a maxThrust key defined, and leave it up to the RO engine configs to configure the thrust. If this is the case, my patch takes the thrust from the ModuleEngineConfigs, and places it in the ModuleEngines, which RocketSoundEnhancement can then read properly. It doesn't modify the original Patches from RSE.

lukecologne commented 5 years ago

I tested my patch on RaiderNick's US Rockets pack, which has the problem of missing maxThrust, and everything seems to work fine.

lukecologne commented 5 years ago

Using the latest version of RO from CKAN.

Gordon-Dry commented 5 years ago

Okay, I scrap that and try your patch again ...

Gordon-Dry commented 5 years ago

Let me launch my Procedural Sounding Rocket after a VAB rebuild and listening to it...

lukecologne commented 5 years ago

What engine do you use?

Gordon-Dry commented 5 years ago

NAA-75-110 A-Series (RealEngines)

Gordon-Dry commented 5 years ago

Haha, also especially that engine got effects which are not already in this mod: Alcolox-Lower-A6 Hydynelox-A7

See the list https://github.com/ensou04/RocketSoundEnhancement/issues/4

Gordon-Dry commented 5 years ago

I just fiddled fake replacements for testing:

Hydynelox-A7.cfg is a clone of Ammonialox.cfg Alcolox-Lower-A6.cfg is a clone of Hypergolic-OMS-Red.cfg Hypergolic-Vernier.cfg is a clone of Hypergolic-OMS-White.cfg running.cfg is a clone of Kerolox-Lower.cfg powerflame.cfg is a clone of Kerolox-Lower.cfg

Gordon-Dry commented 5 years ago

I got issues with AudioMuffler, not sure because of RO / RP-1 alone or because of my patches to RocketSoundEnhancement - I will remove AudioMuffler for now. see https://github.com/SerTheGreat/Audio-Muffler-Redux/issues/7

lukecologne commented 5 years ago

You should probably test things on a relatively clean install of RO to ensure that no conflicts with other mods appear. Also, the smaller the install, the faster the game loads, which is really nice if you are changing and restarting a lot.

Gordon-Dry commented 5 years ago

Yeah and no. Thing is, the more mods are around and no issues appear the better. How to find out? Use mods. It's difficult - and it's Unity,yeah! (Are Unity devs Latte Macchiato-folks btw?)

Gordon-Dry commented 5 years ago

The placeholders need to be replaced by properly made configs. See https://github.com/ensou04/RocketSoundEnhancement/pull/3/commits/58e05613bf9d40f0788ccaf529c93c5ee3743955

This is not my job ;)

Gordon-Dry commented 5 years ago

Some additions coming in a few minutes.

This should be taken into account some day ... I feel forgotten.

Gordon-Dry commented 4 years ago

I will close this PR an open a new one because the name of the branch is misleading. So I also delete the branch and create a new one.

I guess many people think it's only for RealismOverhaul...

It's not "just" for RealismOverhaul - it's additions that are generally for all EFFECTS types of RealPlume.