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 ... 457 458 [459] 460 461 ... 706

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

Alex

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

Ah, ok - yeah, the conclusion makes sense. Fast-time ships will advance() several times in a row without the rest of the engine advancing, so stuff like adding/removing projectiles might not get processed if it's done in a system script for a ship that's in fast-time. I forget the details - they're hairy - but, yeah, this doesn't sound unreasonable.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6871 on: October 27, 2020, 08:04:02 AM »

(I split the more suggestion-themed discussion regarding mod versioning into a separate thread.)
Logged

shoi

  • Admiral
  • *****
  • Posts: 650
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6872 on: October 27, 2020, 09:15:25 PM »

Thanks!

I noticed fighters will sometimes leave behind a hulk like disabled ships, or straight out be vaporized.
Is there any way to make them always become hulks/husks?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6873 on: October 28, 2020, 10:23:28 AM »

Ah, there isn't, sorry! It's hardcoded to 50% for fighters.
Logged

Jaghaimo

  • Admiral
  • *****
  • Posts: 661
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6874 on: October 28, 2020, 11:52:38 AM »

Is there a way to get the intersection of two CargoAPI objects easily? Right now I use brute force and go over each cargo stack in both CargoAPIs, check if it's the same item, take one stack, and adjust size to min of the two sizes.

I could also use mathematical approach (pseudocode, for simplicity assume it returns new CargoAPI, in actuality would need to use to multiple copies):
Code
aLessB = cargoA.removeAll(cargoB);// left side of union
bLessA = cargoB.removeAll(cargoA);// right side of union
aPlusB = cargoA.addAll(cargoB);// union
intersection = aPlusB.removeAll(aLessB).removeAll(bLessA);// center of union, intersection, but need to accommodate for duplicates (stacks have sizes which mutate due to addAll/removeAll, lets treat them as duplicates), every stack needs to be halfed (got napkin math to cover that)
Actual quantity in intersection is: in bLessA: max(0, qB - qA), in aLessB: max(0, qA - qB), in aPlusB: qA + qB, in intersection: qA + qB - max(0, qB - qA) - max(0, qA - qB), solve for A > B, A < B, A = B) to see quantity is doubled in each case.

Edit: Actual Java code doesn't seem too terrible:
Code
    public CargoAPI getCommonCargo(CargoAPI cargoA, CargoAPI cargoB) {
        CargoAPI aLessB = cargoA.createCopy();
        aLessB.removeAll(cargoB);
        CargoAPI bLessA = cargoB.createCopy();
        bLessA.removeAll(cargoA);
        CargoAPI intersection = cargoA.createCopy();
        intersection.addAll(cargoB);
        intersection.removeAll(aLessB);
        intersection.removeAll(bLessA);
        halveQuantities(intersection);
        return intersection;
    }

    private void halveQuantities(CargoAPI cargo) {
        for (CargoStackAPI cargoStack : cargo.getStacksCopy()) {
            float size = cargoStack.getSize();
            cargoStack.setSize(size / 2);
        }
    }
Even with having to create those copies this code is vastly simpler to what I actually ended up with (the two nested loops), it is even simpler than one helper function I use (below)! I worry about performance (and calls to addAll, removeAll) though.

Is there an easier way to check if two cargo stacks are the same item (disregarding quantities)? I stole this from Misc.isSameCargo():
Code
    private boolean isSameCargoStack(CargoStackAPI s1, CargoStackAPI s2) {
        if ((s1 == null || s2 == null) && s1 != s2) {
            return false;
        }
        if (s1.getType() != s2.getType()) {
            return false;
        }
        if ((s1.getData() == null || s2.getData() == null) && s1.getData() != s2.getData()) {
            return false;
        }
        if (!s1.getData().equals(s2.getData())) {
            return false;
        }
        return true;
    }
This one helper function is already comparable to the whole code using addAll/removeAll. Curious, how would you find the common part of two cargos?
« Last Edit: October 28, 2020, 02:04:57 PM by Jaghaimo »
Logged

Alex

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

What you're doing seems fine! Depending, might want to throw in a .sort() for each of the starting cargos; that'd - iirc - compress any multiple stacks of something into a single stack. (Careful if doing this to player cargo, since that'd also nuke any special custom stacking/ordering they might have done.)

I think the more important question, performance-wise, is whether worrying about the performance on this makes sense or not. For example, if this code runs in response to a UI interaction (i.e. inside some dialog or similar), then it likely doesn't matter. If it can run in the background while the player is flying around, then it might matter if the cargo size could be pretty large or you need to do this a lot for some reason, but if not, then again it probably doesn't matter how optimized that is.

Edit: regarding the "are the stacks the same" question, your code looks good to me. Are you concerned about performance or code length? The former seems like it'd be very good for this method, and the latter it doesn't seem like there's an easy/obvious way to cut down on it.
« Last Edit: October 28, 2020, 08:47:02 PM by Alex »
Logged

shoi

  • Admiral
  • *****
  • Posts: 650
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6876 on: October 28, 2020, 01:14:28 PM »

Ah, there isn't, sorry! It's hardcoded to 50% for fighters.

thanks  :'(
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6877 on: November 05, 2020, 11:09:29 AM »

What's the difference between getVisualBounds() and getExactBounds()?

Ah, there isn't, sorry! It's hardcoded to 50% for fighters.

thanks  :'(
I don't know if you've already tried this (I haven't) but if you turn a fighter into a frigate, or change its collision class, right as it dies, the hulk might stick around?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6878 on: November 05, 2020, 11:15:45 AM »

getExactBounds() is used for collisions. getVisualBounds() is used for rendering ship pieces after they've been split apart, the ship sprite is stenciled to an area defined by the bounds, weapons outside it are discarded, etc. I forget what the difference is in how the two are generated, but in terms of what they're for, that's it.
Logged

boogie

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6879 on: November 09, 2020, 02:11:57 PM »

Could anyone please give me a direction to dig infor this error?
I'm trying to run a basic ship mod following the wiki intro to modding guide. there should be nothing creating this.
Never mind I'm an actual idiot, I forgot to enable lazy lib with the console command mod for testing.
Code
12695 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
java.lang.RuntimeException: Failed to find script of class [com.fs.starfarer.api.impl.campaign.CoreLifecyclePluginImpl]
at com.fs.starfarer.loading.scripts.ScriptStore.new(Unknown Source)
at com.fs.starfarer.settings.StarfarerSettings.OO0000(Unknown Source)
at com.fs.starfarer.launcher.ModManager.getEnabledModPlugins(Unknown Source)
at com.fs.starfarer.loading.ResourceLoaderState.init(Unknown Source)
at com.fs.state.AppDriver.begin(Unknown Source)
at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

[attachment deleted by admin]
« Last Edit: November 09, 2020, 02:43:02 PM by boogie »
Logged

Krelian

  • Lieutenant
  • **
  • Posts: 63
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6880 on: November 09, 2020, 06:16:48 PM »

Hello. Just curious, are non-orignal mods (as in from popular culture) frowned upon on this comunity? I ask because there is a TON of awesome mods, but most impressive of all is that almost all of them are original ideas, besides the unavoidable starwars one, one from gundam iron brooded, and one from homeworld (that comes from the top of my mind). The "original" mod ratio is extremelly high; and with a game that is a perfect fit for a ton of popular culture sci-fy, I just cant but wonder why is that.

More to the point, I had been toying with the idea of implementing certain sci-fy I would like a lot to play with, but now I fear it could be rejected by the comunity because of my previous point.

Regards
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6881 on: November 10, 2020, 03:41:44 AM »

Translating an existing IP into Starsector is more difficult and less rewarding than creating an original work. Not to mention the risk of getting C&Ded — all your work down the drain.
Logged

Harmful Mechanic

  • Admiral
  • *****
  • Posts: 1340
  • On break.
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6882 on: November 10, 2020, 03:48:28 PM »

You're unlikely to get either help or hindrance in creating whatever IP mod you want to exist. The problem with most IP mods is that someone with beginner skills shows up, does a little bit of work, and then expects the rest of the forum to pitch in to complete it with/for them. Then the mod gets abandoned. Rinse, repeat.

Regarding C&Ds; generally it's not worth the negative publicity hit for a rights-holder to issue those for tiny fan projects unless the fan project is seeing as being in direct competition with an official project. But you have no functional way of knowing what might be in the works at any given time; you could chug along on your mod for years and get it all nullified at once because someone decided in a closed meeting to greenlight a game, and the legal staff is doing a sweep for competing fan projects. And; the game they greenlit might never see the light of day; you might just get your work tanked because Legal is doing their due diligence.

There are lots of pseudo-legal arguments about copyright and trademark violations being magically legal if you're not charging money or if you change a certain percentage of pixels, and those are all garbage arguments with no legal basis. In the former case, it's just not worth the time and expense to go after you; in the latter, disguising what you're doing just improves the chances of getting away with it. But assuming a rights-holder has deep pockets and a single-minded desire to chase after you, none of that is legal; it just might be beneath notice, or lack a basis for action.

So it's less 'frowned upon' and more 'given the high barriers to entry in modding Starsector at all, low-effort IP mods don't get very far compared to original work'. The exceptions are all pretty unique - dating back to when the game was much less complex, putting a unique spin on the IP, or directly copying functionality from other, more complex original mods. Nothing is actively stopping you from being another exception.
Logged

Krelian

  • Lieutenant
  • **
  • Posts: 63
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6883 on: November 10, 2020, 07:56:29 PM »

I see the point, thanks for the thoughtful answers
Logged

Sinosauropteryx

  • Captain
  • ****
  • Posts: 262
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6884 on: November 11, 2020, 05:35:00 AM »

getExactBounds() is used for collisions. getVisualBounds() is used for rendering ship pieces after they've been split apart, the ship sprite is stenciled to an area defined by the bounds, weapons outside it are discarded, etc. I forget what the difference is in how the two are generated, but in terms of what they're for, that's it.
Alright - thanks!

Is it possible to change the maximum industry count for a given planet, without affecting other planets?
Logged
Pages: 1 ... 457 458 [459] 460 461 ... 706