sarcazmotron3040 Posted May 2, 2012 Share Posted May 2, 2012 Accountant - Alpha v0.05Author: sarcazmotron3040, based on the Kerbal Engineer 0.2 plugin by jhultgreExample of the plugin calculating the cost for Daedalus by ccikv0.01v0.04 - Now works with custom parts thanks to FlutteryChicken!v0.05 - Cleaned up Interface - Changed Part to be a Command ModuleI was inspired by jhultgre\'s Kerbal Engineer 0.2 plugin to start what I hope will become an eventual economic system.This plugin currently only works with stock parts. I have no idea how to grab the cost of a part from within KSP, so for now, it reads a static CSV file that contains the part name, cost and title located in the Plugins/Economy folder named parts.csv. If anyone can help with determining the cost of parts from within KSP, I would very much appreciate it. For now, if you want the Accountant to work with custom parts, you\'ll have to add them to that file manually. I can write a utility that will auto-populate that file when run by reading the parts folder, but would rather not if there is a more elegant way of obtaining part costs.This plugin works with any part, including custom parts you may have in your game, thanks to help from FlutteryChicken.This plugin does not currently have a custom model that goes with it. I\'m slightly better at coding than I am at modeling, so you will have to either copy an existing part and modify it to work with this plugin, or create your own part. I trust you know how to do this already. I\'m using the stock decoupler, RCS Fuel Tank Command Module as the model for the time being.Future plans[li]Budget that adds to Available Funds on periodic basis[/li][li]Public Interest that modifies Budget positively or negatively as a percentage[/li][li]Deduction of cost of rocket from Available Funds[/li][li]Milestones (can only be obtained once for each) that increase Budget Amount (by $) and Public Interest when reached[/li][li]Records and Record-Breaking which modifies Public Interest positively. The higher the difference between the current and previous record has a bigger impact[/li][li]Inactivity causes Public Interest to decline[/li][li]Loss of crew reduces Available Funds as penalty. Side-effect, if funds are sufficiently negative, will cause loss of Public Interest due to inactivity[/li][li]Mission types (deliver passengers or payloads, perform maintenance, etc)- unlocked as Milestones are reached.[/li][li]Prototype costs - Parts initially are more expensive. As more of that part are produced, the cost decreases.[/li][li]Some parts/functions unlocked after exceeding certain metrics. Just an example: Automated circularizing orbit function only available after completing five manual circularized orbit missions (To obtain research necessary to automate that function) Another example: More efficient engines become available after so many of the first model have been produced. A friend came up with this idea.[/li][li]Random Part Failure - very low chance, unless Available Funds happens to be less than the cost of the rocket when launching, then chance for Part Failure increases. The bigger the difference between Available Funds and Ship cost, the higher the chance. This represents taking shortcuts or under funding to produce the part(s). Type of failure depends on the kind of part affected.[/li][li]Model for the part[/li][li]Option to launch rockets in simulation mode, to test out new designs before actually spending time and money on the real thing. If possible have different scenarios available to simulate.[/li][li]Parts take time to produce and assemble[/li]Suggestions/Comments are always welcome. Changelogv0.05Changed part to Command ModuleCleaned up GUI for displaying costMoved drawGUI to onBackup()v0.04Added beginning of finance systemModified code to enable this plugin to work with any part, even custom parts. Thanks goes to FlutteryChicken for this!v0.03Changed temp model for another one that seemed to make more sense.v0.02Added temp model for part.v0.01Initial Release Link to comment Share on other sites More sharing options...
ping111 Posted May 2, 2012 Share Posted May 2, 2012 This is amazing! This could be a big help for RP and the experimental campaign mode! Link to comment Share on other sites More sharing options...
togfox Posted May 2, 2012 Share Posted May 2, 2012 Awesome!! This is what the forum campaign has needed for weeks!!!The ship files have cost in the .craft file so can you read from that instead of your \'economy\' file? I\'m no coder - just the bright idea\'s man. On the other hand, by having a seperate file I can set my own costs for parts. That\'s cool too! Maybe for parts missing from the economy file, you can read from the .craft and set that \'default\' value in the economy file but allow someone to change that default value if needed. It will involve a \'write\' to the economy file of course.I haven\'t d/l the file yet, is this a part that sits on the ship? How does it work? Guess I\'ll find out soon enough!! Link to comment Share on other sites More sharing options...
NovaSilisko Posted May 2, 2012 Share Posted May 2, 2012 Pretty much everything in your planned features list is planned for the game itself, so you may be wasting your time. Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 2, 2012 Author Share Posted May 2, 2012 Awesome!! This is what the forum campaign has needed for weeks!!!The ship files have cost in the .craft file so can you read from that instead of your \'economy\' file? I\'m no coder - just the bright idea\'s man. On the other hand, by having a seperate file I can set my own costs for parts. That\'s cool too! Maybe for parts missing from the economy file, you can read from the .craft and set that \'default\' value in the economy file but allow someone to change that default value if needed. It will involve a \'write\' to the economy file of course.I haven\'t d/l the file yet, is this a part that sits on the ship? How does it work? Guess I\'ll find out soon enough!!I think you meant the part.cfg files for each part has the cost and other info listed. In any case, you are correct that I can grab the values I need from them. I put those values in a CSV as it is quicker to read from. I can write a utility to append to the CSV file for non-standard parts, but as I said before, if those values can be retrieved from the game as it is running (since it has already loaded those part data into memory), that would be the most optimal solution.This is a part that sits on the ship. There is no model yet and I may post an update with a stock model, as a temporary placeholder, if that\'s not against any rules. How does it work? At it\'s most basic level, it goes to each part of the ship, identifies it, keeps track of how many of that part exist on the ship, then multiplies that number by the cost to get the item total and adds all of those values together to get a grand total. It certainly isn\'t something that will fly your ship! Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 2, 2012 Author Share Posted May 2, 2012 Pretty much everything in your planned features list is planned for the game itself, so you may be wasting your time.It\'s my time to waste. Link to comment Share on other sites More sharing options...
togfox Posted May 2, 2012 Share Posted May 2, 2012 Ah - yes - the part.cfg. I stand corrected. And if we only did mods for features NOT planned in the game then MechJeb would never have been invented.I\'m confused when you say this is a part that sits on the ship but there is no model yet. Is it an invisible part? Do you mean no *custom* model yet? Anyway - I\'m just stoked this now exists!!! I shall explore it in detail later on. 8) Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 2, 2012 Author Share Posted May 2, 2012 Ah - yes - the part.cfg. I stand corrected. And if we only did mods for features NOT planned in the game then MechJeb would never have been invented.I\'m confused when you say this is a part that sits on the ship but there is no model yet. Is it an invisible part? Do you mean no *custom* model yet? Anyway - I\'m just stoked this now exists!!! I shall explore it in detail later on. 8)Yeah, I meant no custom model yet. I have re-uploaded the mod which uses the decoupler as a temp model for this plugin. Link to comment Share on other sites More sharing options...
Thobewill10 Posted May 2, 2012 Share Posted May 2, 2012 Dammit. I had just started an external version of the same thing, with a campaign mode planned and everything. I just finished my cost calculator jar. Link to comment Share on other sites More sharing options...
sjwt Posted May 2, 2012 Share Posted May 2, 2012 Sweet, thanks! Link to comment Share on other sites More sharing options...
FlutteryChicken Posted May 3, 2012 Share Posted May 3, 2012 In your \'walkParts\' method change the line\'totalCost += Convert.ToInt32(namedPartsCost[p.name]);\'to\'totalCost += p.partInfo.cost;\'that should get the cost of the part without having to load up the cfg files seperately Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 3, 2012 Author Share Posted May 3, 2012 In your \'walkParts\' method change the line\'totalCost += Convert.ToInt32(namedPartsCost[p.name]);\'to\'totalCost += p.partInfo.cost;\'that should get the cost of the part without having to load up the cfg files seperatelyThanks for that. Works perfectly! Link to comment Share on other sites More sharing options...
FlutteryChicken Posted May 3, 2012 Share Posted May 3, 2012 No problem, just started having a play with creating a plugin yesterday, but if you need a hand give a shout out. Link to comment Share on other sites More sharing options...
Justin8Ball Posted May 8, 2012 Share Posted May 8, 2012 For your model, could it be like Jeb autopilot panel device? Link to comment Share on other sites More sharing options...
togfox Posted May 8, 2012 Share Posted May 8, 2012 This is looking nicer every day. Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 8, 2012 Author Share Posted May 8, 2012 For your model, could it be like Jeb autopilot panel device?If you mean something that can attach to a surface of the rocket, sure. I\'ll look into adding another part that works with this plugin which isn\'t a command module for the next update. Link to comment Share on other sites More sharing options...
Justin8Ball Posted May 11, 2012 Share Posted May 11, 2012 Hows the accountant coming along? Link to comment Share on other sites More sharing options...
ping111 Posted May 11, 2012 Share Posted May 11, 2012 Umm, did I install this correctly?I built a rocket normally, and though the window showed up, nothing appeared on it. Then when I launched, it took a few seconds to take off, and when it did, it left the pod behind, floating in midair! Any help? Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 11, 2012 Author Share Posted May 11, 2012 Hows the accountant coming along?Expect updates to be sporadic, unannounced and generally buggy. Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 11, 2012 Author Share Posted May 11, 2012 Umm, did I install this correctly?I built a rocket normally, and though the window showed up, nothing appeared on it. Then when I launched, it took a few seconds to take off, and when it did, it left the pod behind, floating in midair! Any help?You could try removing the plugin and any parts that are part of the plugin, then reinstall. Let me know how that goes. Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 11, 2012 Author Share Posted May 11, 2012 Here\'s a sneak peek at a side effect I had not anticipated with the stuff I was experimenting with.Where\'s Jeb and Bill??? 8) Link to comment Share on other sites More sharing options...
Justin8Ball Posted May 11, 2012 Share Posted May 11, 2012 Maybe Bob just got tired of Jebs flying. Link to comment Share on other sites More sharing options...
Amram Posted May 15, 2012 Share Posted May 15, 2012 love this thing, especially now that i don\'t need to maintain an external CSV for part costs.Can I ask a few additions to the future plans?inflationary value for the base funding. after playing for X amount of time, all things equal, your income should be greater. Essentially just one more small percentage multiplier, which is applied every payday, regardless of other factors. mimics increases in the Kerbal national budget, which leaves you with the same percentage, but a larger and larger value over time.A two tier public interest system. Achieving milestones nets you a one time payout, yes, but it would also boost public interest alot more. 'Yawn, another rocket launch' vs 'they went to the MUN!?!?'. Payouts are essentially government subsidy or private benefactors supporting your successes, but public interest is like voters influencing politicians to devote more of the budget to you. Simply accomplishing something decent, like putting satellites in orbit for the first however many satellites it counts for should net a P.I. increase, but nothing like the first time you do something.A continuous depletion of P.I. Essentially you lose x amount every payday, and this needs to be offset by accomplishing something the previous pay day. It should be small enough that any successful mission that provides at least the lower P.I. increase can offset this for a couple of paydays, in this manner, doing nothing for long periods will begin to hurt your overall income, and take you a few good missions to recover.Since you mention planning to include production and prototyping:an R&D duration, coupled with a development chain. Just a list will do, this leads to that which leads to that and that, which....etcthe first part of the chain is specified as unlocked or not, trigger an R&D somehow(VAB menu?), wait out the R&D, then you can prototype it(use it an higher cost)later items might take longer.anyways, you\'re already planning pretty much everything i\'d be looking for in such a plugin. just thought i\'d put these out there and see if maybe you\'d add them into your plans or not.Im not trying to rush you or anything, just having it total the cost is a bonus to me any my little sideline campaigns i play out. Link to comment Share on other sites More sharing options...
sarcazmotron3040 Posted May 16, 2012 Author Share Posted May 16, 2012 Thank you for the comments and suggestions Amram!I have not thought of inflation, but it should be something I can implement as a configurable value. I\'ll add it to my 'to do' list. Thanks!Some of the things I am doing with public interest is relating the amount to the number of Kerbals involved in the flight (which can range between 0 and 3, though more may be possible, haven\'t tested 4+ yet) and increasing it when records are broken (highest altitude, speed, etc). So unmanned missions initially generate no public interest, however, since the command module is cheaper (no life support, seats, etc. needed), it is easier to add other parts and break certain records than with manned pods. I am thinking of keeping track of manned vs. unmanned records, so that manned records, even though they may be less than unmanned records, should generate a lot more Public Interest.I have implemented a kind of inactivity penalty to public interest for not launching flights, and all the variables involved (penalty amount, time for inactivity, etc) are configurable.R&D is on hold until I start Random Part Failure as I am not sure if I can stop someone from placing parts they have not researched yet, but prototype pricing is in (and configurable) for the next update. There are some bugs with how symmetry is affecting the prototype price calculations, but I may decide that those bugs are actually 'features.' Not sure yet. I do like your idea of making R&D time based.Here are some screenshots of my progress so far:Unmanned pod. Cheap to build.Single Seater. A little more expensive to produce, but now there\'s a skilled pilot in control of the craft!Prototype pricing can be seen here, along with a cleaner GUI. Prototype pricing can be configured to be on or off.Finance Tab. Time to Payday is configurable. The Advance Time button does not actually advance the game\'s universe time currently. Haven\'t been able to figure that out yet aside from editing the persistent.sfs file and I only want to do that as a last resort if I can\'t figure out another way. You can see that Public Interest is currently not very good. Had a few missions where the parachute didn\'t open fast enough...Statistics Tab. Eventually will include records. The onTouchdown() event does not seem to work at all, which is why it does not show any touchdowns. I will have to figure out a different way of detecting when that occurs. Kerbonaut heroes are those who paid the ultimate sacrifice for Kerbalkind...Milestones Tab. Right now, it\'s very simple, but I plan on expanding on it as I learn more.The other two tabs (missions and configuration) currently do nothing. Once I learn how to retrieve player input from text boxes I will implement the config tab. Right now, I\'m configuring by hand-editing a csv file.At the launch pad we see that the lone Kerbonaut awaits liftoff. He\'s in a single seater pod. There are also two and three seat variants, each more costly than the last.Thanks again for your comments and suggestions! Link to comment Share on other sites More sharing options...
Thobewill10 Posted May 16, 2012 Share Posted May 16, 2012 This looks to be shaping up excellently! Link to comment Share on other sites More sharing options...
Recommended Posts