Sign in to follow this  
karamazovnew

Real Fuel Stock Tank Prices 1.0

Recommended Posts

Important notice: MOD UNDER UPDATE. Gonna keep this first post unchanged until I finish, because I need this info :)

REQUIRED MODS:

- NathanKell's Real Fuels 8.4

- Raptor831's Stockalike Real Fuels Engine Configs

Not required but suggested:

- Yemo's SETI mod

I'm actually counting on Yemo to integrate this into SETI as soon as possible, I'll notify here if he does.

Compatible Mods:

- I'm using more than 100 mods (Seriously). I won't link them here, but since this is just a small modification for RealFuels, if a mod is compatible with that, it should be compatible with mine.

Licence: MIT licence terms included in the download. More information available here: http://opensource.org/licenses/MIT

DOWNLOAD LINK (Current Version 1.01), Mediafire link: but if this is the first time you download this, please the entire post first.

http://www./download/lqnhmrkwldvii9f/RFStockTank_1.01.zip

Changelog

07 Mar 2015: v1.0 initial release

09 Mar 2015: v1.01, fix for "RemoveSyntin.cfg" if you use Kosmos engines.

INSTALLATION: just drag into the Kerbal folder. Already includes GameData folder.

Important: Do not use it on an existing career without backing up your saves. Let me underline that: Do not use it on an existing career without backing up your saves.

Description (modders should also check bottom of the post for a breakup of what each file does what).

Introduction:

Because of Raptor831's work on Stockalike Real Fuels Engine Configs, we've had the pleasure of using Nathan Kell's amazing RealFuels mod outside the Realism Overhaul mod.

I mean let's face it, the Realism Overhaul mod and its Realistic Progression Zero campaign are still very much a work in progress. But even when they're done, Realism Overhaul will always be a bit too much for some. The Earth Sized Kerbin demands lots of times spent at 4X time, planes are basically useless for exploration. The realistic payloads make establishing a refinery base or a space station a challenge worthy of Nasa employees. This means that while I have RO installed at all times and following progress daily, I also still very much enjoy a good old stock career.

While Raptor has fixed every modded engine in existence, fuel tanks and fuel prices have been ignored so far. Playing on Sandbox, you never would've noticed this. But in a career where funds are important, the gaming aspects of choice, compromise and consequence have been affected because of this.

This series of modifications aims to fix that.

What this mod does:

Even if you don't use procedural tanks:

- Removes all stock fuel prices from the cost of buying a tank.

Why? Unlike stock tanks which came full when bought, Real Fuel tanks always starts empty. But the price of any part listed in the part catalog (and the config file that defines it) always contains the cost of the stock fuel. That meant that all RF tanks were more expensive than they should've been. My mod goes through all parts, searches for the presence of Liquidfuel, Oxidizer and Monopropellant, and substracts their price from the cost of that part.

- Greatly increases prices for all real fuels. Kerolox now costs as much as Liquidfuel+Oxidizer.

Why? What you should be wondering is, "why did I not notice the above problem?". That's because the real fuels are very cheap per ton. NathanKell has provided realistic prices, sure, but they are made for Realism Overhaul, where rockets are humongous (I mean realistically humongous). They contain a lot of fuel so the price adds up. In fact they are never akin to stock prices, and that's a good thing. Normally a rocket's most expensive part is the useful payload, not the fuel. Realistic Progression Zero shows that quite well already. But that's another discussion. All I wanted was to give them stock prices. Since the Kerosene+LiquidOxygen (Kerolox) combination is the most used and most useful, I've changed the prices based on a multiplier, so that Kerolox ends up costing exactly as much as the stock fuel combination. But because RealFuels started with realistic prices, simply adding a multiplier to all of them means that almost all of the other resources are much more expensive than Kerolox. Hypergolics in particular are extremely expensive. I don't know if that's realistic or how balanced it is in game, but it sure makes you think twice before building a hypergolic upper stage.

- Hides some of the fuels (only 35 of them, I think). You should now have a cleaner tank interface.

Why? There were too many of them. Since this mod is meant to be used with Raptor831's Stockalike Real Fuels Engine Configs, there was no point in keeping resources that his mod doesn't use. Now, I only use the stock engines and the ones from KW Rocketry so from my actual game I deleted even more resources. You can too, just follow the example of the config file. This just hides them from Real fuels Tank Types, it doesn't actually delete the resource type from the game. If a part specifically requests them as a resource, you should be able to see it. That includes mods like Raptor831's Karbonite Real Fuels converters which will still show resources like MON, you'll just not have anywhere to store them.

Note 1: The only used resource I deleted from his mod was Syntin, as that was only used in one engine from the Kosmos pack. In real life Syntin is basically synthetic Kerosene which is no longer used because it was much more expensive. This modifies Raptor831's Syntin to Kerosene. Delete the RemoveSyntin.cfg file if you don't like that.

Note 2: Removing the old Liquid Fuel/Oxidizer/Monopropellant resources was problematic. Although RealFuels itself aggressively cuts them from almost all parts, I found that I had to cut them yet again in a particular way. It works, but it's optional, If you think it might break something, don't use it. Simply delete the RemoveStockFuel.cfg file

- Makes tank types much more varied, just by affecting the price. Read below because it's important to understand how.

Why? Well, how many times have you heard the question "What is the difference between Cryo and Cryo Balloon?" on the Real Fuels thread? Why should an insulated, pressurized tank cost as much as a simple bottle of Soda? Good point. What's preventing you from strapping a Cryo tank to keep that Liquid Hydrogen nice and cool, instead of using a default Tank which boils it on a mild sunny day? Well, cost. I had t ways to do it. One was to make the empty tank itself more expensive, but I didn't like that Idea. You see, rocket fuel tanks are in effect big metal barrels of thin material which prevent rain from going inside. Inside of them are the actual fuel parcels. Kerosene for example doesn't need to be cooled, but Hydrogen can. You might want to cool it, to be able to use it for Mun injection, or not cool it and just use it for a cheap first stage launch. On the other hand, pressurized fuel will prevent the engine from cutting out in the Engine Ignitor mod. Again, you might want to pressurize your Kerosene orbital stage, or you might prefer a cheaper "spin around until engine shows very stable" unpressurized option. Luckily, the way that RealFuels deals with this is brilliant, so all I had to do was add cost for every liter of fuel space that has "Insulated" or "Pressurized". Mind you, i said SPACE. The fuel itself is not more expensive, but the bottle that holds it is. That means that you might want to think twice before allowing your expensive empty tank to burn in the atmosphere or drift away into oblivion.

Here's a breakdown of the Real Fuel tank types, nothing was changed from the original RealFuel mod, just pricing:

- Default: nothing is insulated, nothing is pressurized.

- Cryogenic: boil-off fuels are insulated and more expensive. If you use non-boiloff fuels, there is no difference in price to Default. Read Note 1.

- ServiceModule: All fuels are pressurized, boil-off fuels are also insulated. Overall, this is a much more expensive tank, regardless of what fuel you use.

- Fuselage: Not touched in this mod, acts the same as ServiceModule, meaning that all of your aircraft will be more expensive. Read Note 2.

- Xenon: Removed. Read Note 3.

- All other types, untouched.

Note 1: unfortunately RealFuels tags some of the stock and modded tanks as Cryogenic (for example the 2.5 meter tanks). If you want to fill them up with Liquid Oxygen or Liquid Hydrogen, you will not have a choice to have them insulated or not. They will always be insulated, so that tank will always end up costing more. There is nothing I can do about that. If you don't like it, you can create a copy of that part and tell RealFuels to tag it as "default".

Note 2: more unfortunately, RealFuels also tags almost all aircraft tanks as Fuselage, which are both pressurized and Insulated. Whatever fuel you put in those, you're toast :) But it's not all bad, I mean, you DO want to recover your planes, don't you? You'll get your money back, unless Jebediah decides to make a loop at 600m/s. I'd say that Kerbal Construction Time mod becomes mandatory

Note 3: RealFuels modifies Xenon to be realistic. But the Near Future Propulsion mod relies on the stock Xenon and ends up with less than 1/10 the DeltaV. Since Raptor831's mod never mentions Xenon, I completely inverted any modification made by the RealFuels mod which mentions Xenon. This includes removing Xenon as a resource from Procedural Tanks.

If you use procedural tanks:

Adding to the above, this mod changes how Procedural Tanks are used with RealFuels. This mod hides the remaining RealFuel Procedural tank (as the Procedural Mod itself hides all of its other parts) and adds 6 new tanks: Default, Cryogenic, Balloon, Balloon Cryogenic, Service Module and Structural. Unlike the procedural tank you were used to, mine do not allow you to change tank type. The trade-off is that now we can make any changes we want to these tanks. For example, although I've made all of them available on Start node of the Tech tree, maybe Yemo can patch it in the SETI mod to spread it in the tech tree.

The changes I've made are listed below:

- Inspired by the SETI mod, I've lowered the max temperature and I've copied the tech size limitations so that you can use them immediately with SETI.

- Tank utilization: while stock tanks already have this included (for example, the stock 1000L tank is actually a 1200L Cylinder utilizing just 85% of total volume), Procedural Tanks did not. There was no benefit to choosing one over another in terms of utilization. Now, default tank represents an 85% utilization (but same as stock), Cryogenic is 80%, ServiceModule is 75%, Balloon is 95% and Balloon Cryo is 90%. It might be possible to link this also with the tech tree. I've done this by using "tankVolumeConversion" inside the part's config file, not by messing around with RealFuels. There was a way to do that, but it broke Procedural Parts (sort of). I left that config file in the download, but it is not used: TankUtilization(example only).bak

- Balloon and BalloonCryo tanks can not be surface attached and they can not have any parts attached to them. Realistically, these are weak tanks and should be used only for the second stages of sat launches, not for hauling Apollo to the Mun. They provide a massive decrease in tank weight, thus a big increase in DeltaV. So to balance that, I've also increased the price of any L of any fuel of those tanks by 200 credits per 1000L to prevent overusing. If anybody can make them structurally weak and collapse under weight or aerodynamic forces, that would be even better. I'm not that smart.

Things I did not change but seem to work nicely:

- Life Support: I don't know which mod is responsible (either TAC, or SETI, maybe RealFuels itself), but you do get all life support tanks in the ServiceModule tank. Comparing this to the Procedural Life Support tank in game, I found that the ServiceModule can hold less Life support resources (because of lower utilization), but is balanced by reduced weight and price.

Things I did not yet do:

- The Structural tank is there as a placeholder. It's basically a normal ProceduralTank, with Default characteristics, no utilization modded (actually it has a 90% utilization thanks to the Procedural Parts mod), no prices added. Yes, now you can use it to cheat, but I'm counting on the SETI mod to implement resources for EPL and MKS/OKS. If so, the Structural Tank should only be used for those special resources. So, good luck Yemo.

- Anything to hinder Near Future Propulsion. And I will not do it. Yes, you will have 2 resources called "LqdHydrogen" (Real Fuels) and "Liquid Hydrogen" (NFP), but this forces you to use the tanks that NFP provides. And I'm ok with that. Moreover, as I've said before, Xenon should now work with NFP.

- - - For modders - - -

Breakup of files in the mod, if you don't like something in there, don't use it (just rename the *.cfg termination):

- RemoveStockFuelPrice.cfg : Simply subtracts the price of stock fuel from all parts that have them, before RealFuels deletes them.

- HideUnusedFuels.cfg: optional. Makes fuels that are not used by the Stockalike Engine Configs mod disappear from the tanks.

- RemoveSyntin.cfg: optional. Also removes Syntin and modifies the only engine that uses it.

- RemoveStockFuel.cfg: optional and possibly dangerous. I had to leave the command modules alone, else they lost their resources. So far I can't find any other side effects.

- TankPrices.cfg: Adds price to configuring an empty tank. 0.2 means that for every 1000L of resource, price of the empty tank will increase by 200 credits. Balloon tanks are adding more.

- ExpensiveFuels.cfg: makes fuels more expensive. Contents inside should be self explanatory. Don't worry about the XenonGas part, as it's overwritten by the following file. Xenon will not become more expensive if you use the next file.

- RestoreXenonStock.cfg. I've searched every file in RealFuels for mentions of the word "Xenon". I then removed all changes made to those parts and also restored Xenon to the stock price and density. I also hide it from the RF tanks. This is to force you to use the much more expensive stock and mod solutions (Near Future Propulsion).

- New Procedural Tanks folder. Simply altered versions of the Procedural Parts file.

- RemoveProceduralTankRF: optional. This removes the Procedural Parts tank.

- ProceduralTanksFixes: rather than editing each part by hand, I've listed changes here. So far includes utilization and surface attachment.

- TankUtilization(example only).bak: not used, a previous attempt at implementing Utilization without creating new Procedural Tanks. Bugged but left as inspiration.

Edited by karamazovnew
updated to v1.01

Share this post


Link to post
Share on other sites

This is a great idea, and kudos for digging through the gruesome complexity of RF to achieve it. Giving it a whirl right now. :)

Share this post


Link to post
Share on other sites

Congratulations! Glad to see you've got a release for this.

One thing though: you should include a specific license with the mod. Even if it's "Public Domain", just so everything is a-ok with the forum and add-on rules. :wink:

Share this post


Link to post
Share on other sites
Congratulations! Glad to see you've got a release for this.

One thing though: you should include a specific license with the mod. Even if it's "Public Domain", just so everything is a-ok with the forum and add-on rules. :wink:

Thanks, I've linked the MIT licence before the download. I hope that should cover it.

This is a great idea, and kudos for digging through the gruesome complexity of RF to achieve it. Giving it a whirl right now. :)

Honestly, RF is not that complicated code wise. It must've been hard for NathanKell to gather all that information about the fuels, but the code sits nicely on top of the Modular Fuel system which is a joy to use, really :) Once I started messing around with value, results started to appear. Procedural Tanks were the main burden and the main goal, I was quite surprised at how little I had to do. I guess that the worst part was having to repeatedly start a 100mod KSP.exe. There's only so much on 9gag I can watch during waiting, hehe.

Anyway, is everything ok with the mod? No fatal crashes? No burning monitors?

Share this post


Link to post
Share on other sites

Started a new campaign with it (using SETI) on moderate difficulty, and I noticed that I'm really starting to bother a lot more with tank types, as they can really put a a dent in the finances now. Before, I often was just too lazy to switch to Balloon types etc., despite a potential slight advantage.I only ever changed it if the "Default" tank type didn't support the required fuel type (e.g. service module hdyrazin).

The decluttered fuel type list also is great. I love the diversity of RF, but having all those crazily exotic fuels that aren't even used in any engine is just pointless.

What I disliked is the split into unique parts for each tank. I also run with a ridiculous amount of mods (~12GB memory in main menu, but with DDS conversion and DDSLoader startup time is reasonable), and my part list always is cluttered. I always found it very convenient to have a single tank part, allowing me to easily switch tank types whenever I change an engine, instead of having to replace the part. And every superfluous part removed from the list is a bonus. The single-part solution also makes it much easier to immediately see the effects of using a different tank type of the same dimensions (switching to balloon will give me how much more dV?). I found myself removing the RemoveProceduralTankRF.cfg and your new set of fuel tanks and just continue building with the single-part.

Is there a significant balance change you made for the individual parts? Or is it just for tech unlock reasons? If so, I'd much prefer a solution similar to the "unlock bigger/smaller dimensions/shapes" approach that already exists for procedural tanks/fairings.

Share this post


Link to post
Share on other sites

Trust me, I disliked it too, but I didn't have a choice. There might be a good thing coming out of this, if this mod is integrated into a mod like SETI and it replaces other Procedural Tanks (Life support, EPL, OKS/KMS). I'd like it if Yemo actually adds more tanks, like Fuselage, which I didn't mess with. I also didn't convert the Tank cone part. I for one don't think that you should have fuel close to the tip of the nose-cone, so I had already deleted that part from my SETI setup anyway and using empty procedural nose cones instead.

Right now you'd be missing out on 3 things , maybe more in the future (actually, the last one you can fix easily):

- balloon tanks are not surface-attachable and you can not attach anything to them.

- different capacity (utilization) for each tank (as insulation and pressurization should take up more space inside the tank, balloon tanks lack the structural bits so they should allow more space).

- the "general" Procedural Tank cost is still about zero when empty. Go to GameData\ProceduralParts\Parts\ZOtherMods\RFTank.cfg and change "costPerkL = 0.00957" to "costPerkL = 258.39". This will add about 300 credits per 1000L if I remember correctly. This is close to empty stock tank price.

The first two listed in the ProceduralTanksFixes.cfg file, the price one sits in each part file. You can alter them however you like, without messing up the default Procedural Tank. Basically, if you delete this file, my tanks should be exactly the same as the normal ProceduralTankRF with SETI mod added (which alters max temperature and tech size limitations).

You have to understand that the ModuleFuelTanks module is limited with what it can do. It can't for example alter the "size" aspect of a procedural tank, because that sits in another module. Your idea is great about limiting size per type, but it can only be done with my system of adding more tanks, each with it's own Tech Tree size limitations.

There are some things that you can achieve inside the ModuleFuelTanks, sure, but once you put a "type = ServiceModule" on a part, simply adding a "typeAvailable = Cryogenic" will not alter some things, like cost, Volume, tankVolumeConversion when you change the type in game, even though they are part of the ModuleFuelTanks plugin. They will remain "ServiceModule". I tried this with the utilization file and I failed, because Procedural Tanks didn't fill up properly when you pressed the "auto-fill" button, because it didn't update the Volume variable correctly. I'm not sure what can be done with the ModuleFuelTanks plugin, some variables are not documented. The cost one I had to figure out by trial and error.

So you might not like having 5 extra parts, but I think this is the way to go. I'm looking forward to serious SETI integration, especially since my code is a bit messy (I had to keep it messy to be able to make more files, so that you guys can delete or change what you wish) ;)

Edited by karamazovnew

Share this post


Link to post
Share on other sites

Hey,

I was wondering whether you recieved my pm about SETI integration?

Basically, supporting real fuels would essentially double the "versions" of the game for which I would have to test when releasing updates.

Currently I have the "maxMods" version, the sub-version "boldMods/FAR" which goes along with it and the minMods version (only required mods).

While the boldMods/FAR version can be easily maintained together with the maxMods version, I simply do not have the time to properly test the minMods version.

The latter one just kind of just moves along with the rest.

Since each one of them could be combined with RealFuels, it would drastically complicate my testing and maintenance effort, especially considering the craft files and the guide I m working on at the moment.

However I really want to stay compatible with RealFuels and especially your modded version.

So although I can not test it myself due to time constraints, I can provide you with the info you need and I will introduce changes to my cfgs, if you need them.

In the last version 0.8.5 of SETI, I changed the tech unlocks for procedural parts.

Except for SRBs/HRBs and structural parts (which are now unlimited from the start), all procedural fuel tanks get introduced without length and volume restrictions.

The basic maxDiameter is now 1.25m, the 2.5m maxDiameter is unlocked at heavyRocketry and the 3.75m maxDiameter is unlocked at advMetalWorks.

Also there is no tech unlock required for the different shapes.

These are the new size and shape modules for the procedural liquid tank in SETI:


MODULE
{
name = ProceduralPart
textureSet = RedstoneStripes

TECHLIMIT {
//starting node for the part through SETI-TechTree-ProceduralParts.cfg: @TechRequired = basicRocketry
name = basicRocketry
diameterMax = 1.25
}
TECHLIMIT {
name = heavyRocketry
diameterMax = 2.5
}
TECHLIMIT {
name = advMetalworks
diameterMax = 3.75
}
TECHLIMIT {
// Make everything unlimited for metaMaterials, will be changed in the future, for the later part of the CTT
name = metaMaterials
diameterMin = 0.01
diameterMax = Infinity
lengthMin = 0.01
lengthMax = Infinity
volumeMin = 0.001
volumeMax = Infinity
}
}
MODULE
{
name = ProceduralShapeCylinder
displayName = Cylinder

//no tech requirements for any of the shapes
length = 2.0
diameter = 1.25
}
MODULE
{
name = ProceduralShapeCone
displayName = Cone

length = 1.0
topDiameter = 0.625
bottomDiameter = 1.25
}
MODULE
{
name = ProceduralShapePill
displayName = Fillet Cylinder

length = 1.0
diameter = 1.25
fillet = 0.25
}
MODULE
{
name = ProceduralShapeBezierCone
displayName = Smooth Cone

selectedShape = Round #1

length = 1.0
topDiameter = 0.625
bottomDiameter = 1.25
}

So my question is, do you want to use this system as well?

Otherwise I would write MM configs for your parts, which would adjust them to this if SETI is installed.

If you do want to use this system also if SETI is not installed, please let me know, I can provide you with dummy parts, showing the upgrade nodes in the tech tree.

If you have any other suggestions/adjustment needs for SETI-RealFuelStockTankPrices integration, please let me know.

Share this post


Link to post
Share on other sites

As noted over in the SETI thread, either RF or this Mod also breaks Yemo's Hybrid Rocket Booster, this is relatively easy to fix, the following MM code that just swaps out the Oxidizer for RF LqdOxygen and all works fine after that, although I don't know if there are any balance issues associated with doing that.

Another option would be to use NitrousOxide instead which is more common with real hybrid motors, but wasn't sure on whether it would need changing of ratios and tank volumes to ensure it makes sense so LqdOxygen is just the simple solution.

Also note this is only my second ever MM cfg code written, so it is probably really poor syntax but it works!


@PART[proceduralTankHRB]:AFTER[SETI]
{
@MODULE[ModuleEngines]
{
@PROPELLANT[Oxidizer]
{
@name = LqdOxygen
}
}
@MODULE[TankContentSwitcher]
{
@TANK_TYPE_OPTION[SolidFuel]
{
@RESOURCE[Oxidizer]
{
@name = LqdOxygen
}
}
}
}

Edited by Chonner

Share this post


Link to post
Share on other sites

Thanks for making this mod -- working perfectly for me right out of the box on a 64K career. I'm using a real grab bag of assorted parts mods and no problems at all. Really enjoying the challenge and the immersion. Kudos! :D

Share this post


Link to post
Share on other sites

Sorry for the necro but when I made a 1.25x1m standard tank, it cost about 400000 Funds, I do not think it is intentional.

Share this post


Link to post
Share on other sites

You might be better served with using RP0 for RealFuels/RO and career mode costing, this one's no longer supported and a bit outdated by now.

Share this post


Link to post
Share on other sites

Well I'm using Real Fuels for a SETI/64k game, and I want these patches. I do, in fact have a RO/RP-0 install. Very fun mods. Maybe someone else can take it under their belt?

Share this post


Link to post
Share on other sites

Howdy all. Seems like the download link is completely broken, and I wasn't smart enough to keep a backup. So I'm gonna start redoing the mod from scratch for 1.3.1. This time I'm gonna post all the code here, just in case I lose the files again.

First step is ready, just a remake of the old RemoveStockFuelPrice.cfg file. This time I am doing it in a less aggressive way (probably safer as well). Feel free to test it, although it doesn't do much by itself (It actually makes all monoprop tanks cheaper, since I haven't yet remade the fuel prices). I haven't yet touched Xenon (as in the old mod, NearFuture mods will probably deal with Xenon). 

 

- RemoveStockFuelPrice.cfg code (click spoiler to see)

Spoiler

//DESCRIPTION: 
//    Normal fuel tanks in stock Kebal (including mods) have a Cost which includes the loaded default fuel. But when RealFuels creates its "ModuleFuelTanks", it starts with an empty tank, for the same cost. 
//    Thus, when you add fuel, the part becomes more expensive than stock. Normal RealFuels are very cheap compared to Stock fuels, so you might not have noticed. 
//    This file checks all parts with stock resources and sums up their resource costs, before Real Fuels deletes them. 
//    After RealFuel finishes its MM work, this file subtracts the resource costs from the cost of the tank. 
//
//    NOTE: Although stock LF and Oxidizer show perfect values, Monopropellant will be cheaper because of RF. Fuel prices will be altered in a different file to preserve stock values. 
//--------------------------------------

//CONSTRUCTOR: Adds a temporary module to handle the per-part price adjustment calculations. Add any custom resources here, if needed (yes, no way to chain them into a single command)

@PART[*]:HAS[!MODULE[RFStockFuelPrice],@RESOURCE[LiquidFuel]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels]
{
    MODULE
    {
        &name=RFStockFuelPrice
        &resCost=0
        &resCostTotal=0
    }            
}
@PART[*]:HAS[!MODULE[RFStockFuelPrice],@RESOURCE[Oxidizer]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels]
{
    MODULE
    {
        &name=RFStockFuelPrice
        &resCost=0
        &resCostTotal=0
    }            
}
@PART[*]:HAS[!MODULE[RFStockFuelPrice],@RESOURCE[MonoPropellant]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels]
{
    MODULE
    {
        &name=RFStockFuelPrice
        &resCost=0
        &resCostTotal=0
    }            
}

//STORE FUEL COSTS: Adds all provided resource costs to a temporary module. Add any custom resources here, if needed.

@PART[*]:HAS[@MODULE[RFStockFuelPrice],@RESOURCE[LiquidFuel]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels]
{
    @MODULE[RFStockFuelPrice]
    {
        @resCost = #$../RESOURCE[LiquidFuel]/amount$
        @resCost *= #$@RESOURCE_DEFINITION[LiquidFuel]/unitCost$        
        @resCostTotal += #$resCost$        
    }    
}

@PART[*]:HAS[@MODULE[RFStockFuelPrice],@RESOURCE[Oxidizer]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels] 
{
    @MODULE[RFStockFuelPrice]
    {
        @resCost = #$../RESOURCE[Oxidizer]/amount$
        @resCost *= #$@RESOURCE_DEFINITION[Oxidizer]/unitCost$        
        @resCostTotal += #$resCost$        
    }    
}
@PART[*]:HAS[@MODULE[RFStockFuelPrice],@RESOURCE[MonoPropellant]:HAS[#amount[>0]]]:NEEDS[RealFuels]:BEFORE[RealFuels]
{
    @MODULE[RFStockFuelPrice]
    {
        @resCost = #$../RESOURCE[MonoPropellant]/amount$
        @resCost *= #$@RESOURCE_DEFINITION[MonoPropellant]/unitCost$        
        @resCostTotal += #$resCost$        
    }    
}

//APPLY COST CORRECTION: Only to parts affected by RealFuels (for example, no pods)

@PART[*]:HAS[@MODULE[ModuleFuelTanks],@MODULE[RFStockFuelPrice]:HAS[#resCostTotal[>0]]]:NEEDS[RealFuels]:AFTER[RealFuels] 
{
    @cost -= #$/MODULE[RFStockFuelPrice]/resCostTotal$    
}


//CLEANUP

@PART[*]:HAS[@MODULE[RFStockFuelPrice]]:NEEDS[RealFuels]:FINAL 
{            
    -MODULE[RFStockFuelPrice]{ }
}

 

Edited by karamazovnew

Share this post


Link to post
Share on other sites
This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this