Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: 1 ... 399 400 [401] 402 403 ... 706

Author Topic: Misc modding questions that are too minor to warrant their own thread  (Read 1699992 times)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6000 on: January 26, 2020, 08:05:42 AM »

My current interpretation is:
Use for
  • Ballistic spawned from ballistic
  • Ballistic spawned from missile
Don't use for
  • Missile spawned from ballistic
  • Missile spawned from missile

It should just be:
  • Use for ballistic/BALLISTIC_AS_BEAM spawned from missile

But, fortunately, the effects are fairly minor regardless. IIRC It'll just make the AI take some extra care against these.


What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month.

That should work fine, yeah. You don't need to reset anything - it's just a value, the code applying it to the monthly expenses looks at it and does whatever is appropriate. Unless I'm misunderstanding something about what you're asking...
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6001 on: January 26, 2020, 08:39:36 AM »

What would be the best way to go about implementing a dynamic upkeep for a structure? I was thinking about calling applyIncomeAndUpkeep() and changing upkeep as I go but I'm not sure how to zero out the upkeep at the beginning of a new month. I've just been creating intel messages but it really clogs up your screen if you have multiple colonies lol

Not sure your skill level, so I'll spell it out a bit. :)

You want to extend BaseIndustry and override applyIncomeAndUpkeep(). Copy BaseIndustry's applyIncomeAndUpkeep() method, understand what it is doing, then modify it to do what you want.

If you override apply(), make sure BaseIndustry's apply() method is getting called (i.e. your apply() has a super.apply() call in it), because it calls updateIncomeAndUpkeep() which calls applyIncomeAndUpkeep(). Otherwise you need to call applyIncomeAndUpkeep() yourself.
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6002 on: January 26, 2020, 10:38:31 AM »

That should work fine, yeah. You don't need to reset anything - it's just a value, the code applying it to the monthly expenses looks at it and does whatever is appropriate. Unless I'm misunderstanding something about what you're asking...

I'm trying to have a structure keep a running monthly tab and then apply the debt at the end of the month. Basically, during the month, add x credits n times to the tab, both of which can vary month to month. Then, charge the player at the end of the month for the total and zero out the tab. I'm probably just going to have to detect when the month changes through advance() with more instance variables huh
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6003 on: January 26, 2020, 10:46:54 AM »

Ah - for adding an expense to the current month, see:

MonthlyReport report = SharedData.getData().getCurrentReport();

There is code using it in CoreScript.reportEconomyTick() for a more detailed example.
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6004 on: January 26, 2020, 12:28:43 PM »

MonthlyReport report = SharedData.getData().getCurrentReport();

Thanks, it worked perfectly! Are the MonthlyReport and FDNode objects transient? Is it safe to retrieve them once for the industry and store it, or should I retrieve them every time I want to update the values? I noticed you did the latter.

Also, I followed your code to retrieve the node for a particular industry and created this monstrosity:
FDNode iNode = report.getNode(report.getNode(report.getNode(report.getNode(MonthlyReport.OUTPOSTS), market.getId()), "industries"), getId());
Is there any way to truncate or is it just a tree you have to traverse?
Logged

MesoTroniK

  • Admiral
  • *****
  • Posts: 1731
  • I am going to destroy your ships
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6005 on: January 26, 2020, 02:23:04 PM »

Thank you for the clarification Alex!

But uh can you please consider rewriting that comment on setFromMissile in the API please? Right now it is supremely confusing, vague and doesn't even really say when to use it (and it is *really* specific when it should be used) and thus it is literally worthless than nothing at all. Heh, sorry that was crass but really.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6006 on: January 26, 2020, 02:28:34 PM »

Adjusted the comment. And, hey, it made you ask the question, so it was better than nothing :)

Thanks, it worked perfectly! Are the MonthlyReport and FDNode objects transient? Is it safe to retrieve them once for the industry and store it, or should I retrieve them every time I want to update the values? I noticed you did the latter.

You should do the latter since the "current" report will change when the month ticks over.

("Transient", at least in terms of Starsector API stuff, generally means "does not end up in the savefile", btw, which isn't what we're talking abut here. I get what you mean, though, and it's not wrong to say it the way you did; just pointing out it could be a point of confusion at some later time.)

Also, I followed your code to retrieve the node for a particular industry and created this monstrosity:
FDNode iNode = report.getNode(report.getNode(report.getNode(report.getNode(MonthlyReport.OUTPOSTS), market.getId()), "industries"), getId());
Is there any way to truncate or is it just a tree you have to traverse?

It is a tree, but this construction looks wrong. getNode() returns an FDNode but takes a String as a parameter so you couldn't chain it like this.
Logged

cloverstar

  • Ensign
  • *
  • Posts: 7
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6007 on: January 26, 2020, 02:43:15 PM »

It is a tree, but this construction looks wrong. getNode() returns an FDNode but takes a String as a parameter so you couldn't chain it like this.

getNode() is overloaded! There's one that takes in an FDNode and is actually the one you use in CoreScript
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6008 on: January 26, 2020, 03:04:10 PM »

Ah! Well in that case, yeah, that's probably workable :) I'd personally split it into a bunch of lines - and separate statements and variables for each node, just for clarity.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6009 on: January 27, 2020, 12:04:15 PM »

Quick question: Is there a tool that can find and replace a string in all the files in a chosen directory?

I think I used something like this a couple years ago to find a particularly elusive nullpointer from a removed weapon id, but i'm not sure if it can replace anything. I wanted to use it to change the id in every instance it's found in a variant file.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6010 on: January 27, 2020, 12:06:49 PM »

Hmm, your IDE of choice should support this.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6011 on: January 27, 2020, 12:12:32 PM »

Thanks! I had assumed that could only work for actual project files in the jar or the imported dependencies. I'll look into using it for the variants directory.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6012 on: January 27, 2020, 12:29:50 PM »

(I was kind of assuming the variant files would be in a resource folder in your project.)
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6013 on: January 27, 2020, 01:57:29 PM »

I think so, but it has been a long time since I messed with the project structure. I know the API and core files are.

*Edit* Oh wow yeah, that was actually super easy. I can edit mod files directly from the overall project (separate from jar) sub-directories in the IntelliJ 2017 community edition IDE- by directory- and easily find and replace strings for any of the mod files- no jar update or recompile from src required. That saves so much time it's crazy. For work assignments I used the current version of IntelliJ Ultimate and wasn't sure how many features were retained in the older versions- wasn't putting two and two together in this case.

I wasn't sure if I could save the changes to mod files specifically- I thought the dropdown under the project was mostly for reference only. So glad to know I'm wrong.  ;D

I think with a little work I can quite literally make full mod compatibility with factions mods- even possibly ones that edit vanilla files. Assuming no complications come up.
« Last Edit: January 27, 2020, 03:36:56 PM by Morrokain »
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6014 on: January 27, 2020, 05:37:45 PM »

Sounds like you've got it sorted, but in case you find yourself unable to do it for some files: Notepad++ also has a directory wide (and recursive subdirectory) search/replace feature.
Logged
Pages: 1 ... 399 400 [401] 402 403 ... 706