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 ... 593 594 [595] 596 597 ... 706

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

speeder

  • Captain
  • ****
  • Posts: 364
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8910 on: July 08, 2022, 04:17:03 PM »

How I change a faction color programatically? Specially the player, so a menu can be made for those that prefer it orange or something instead of blue.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8911 on: July 08, 2022, 06:27:52 PM »

Hey Alex, I've noticed the ShipHullSpecAPI lacks a method to tell you if a ship is a station, module, or ship.  I've had to create janky workarounds like seeking ShipTypeHints.STATION, looking at the top speed, acceleration, and deceleration, and checking for a module anchor.  There's gotta be a better way, right?

Code
    private static boolean isModule(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getModuleAnchor() != null
                      || (shipHullSpec.getEngineSpec().getMaxSpeed() == 0
                          && shipHullSpec.getEngineSpec().getAcceleration() == 0
                          && shipHullSpec.getEngineSpec().getDeceleration() == 0);
        } catch (Throwable t) { return false; }
    }

    private static boolean isStation(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getHints().contains(ShipHullSpecAPI.ShipTypeHints.STATION); }
        catch (Throwable t) { return false; }
    }

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8912 on: July 09, 2022, 06:14:36 AM »

I've got 2 questions about bad ideas modular frigates -

1 - is there a way to make a module completely untargetable in battle? for now I'm using the "module_hull_bar_only" tag, but that still looks iffy when the player zooms in / gets their mouse too close to the ship.

2 - is there a good, consistent way to prevent explosions from missiles / projectiles "leaking" past a module's shields & hitting the main hull?
I've got a frigate with a secondary shield as a system, and if a missile w/ a big enough explosion (it's pretty close to the main hull so an atropos can do it in my case) hits the outer shield, it'll deal damage to both the outer shield & main ship in 2 separate instances (one for the missile on the module, one for the explosion on the main ship) with nothing really connecting the two for me to throw into a damageTakenModifier listener.
I could store a buncha data about each instance and compare that to check if it's close enough, but that feels like jankery of the highest order & i'd like to avoid it

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8913 on: July 09, 2022, 10:17:29 AM »

How I change a faction color programatically? Specially the player, so a menu can be made for those that prefer it orange or something instead of blue.

I don't think you can; it's not set up to keep that data in a campaign-instance-specific copy of the faction data.

Hey Alex, I've noticed the ShipHullSpecAPI lacks a method to tell you if a ship is a station, module, or ship.  I've had to create janky workarounds like seeking ShipTypeHints.STATION, looking at the top speed, acceleration, and deceleration, and checking for a module anchor.  There's gotta be a better way, right?

Code
    private static boolean isModule(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getModuleAnchor() != null
                      || (shipHullSpec.getEngineSpec().getMaxSpeed() == 0
                          && shipHullSpec.getEngineSpec().getAcceleration() == 0
                          && shipHullSpec.getEngineSpec().getDeceleration() == 0);
        } catch (Throwable t) { return false; }
    }

    private static boolean isStation(ShipHullSpecAPI shipHullSpec) {
        try { return shipHullSpec.getHints().contains(ShipHullSpecAPI.ShipTypeHints.STATION); }
        catch (Throwable t) { return false; }
    }

That's quite literally what ShipTypeHints.STATION is for! Not sure why you have it in a try/catch, though, that should not be necessary.



I've got 2 questions about bad ideas modular frigates -

1 - is there a way to make a module completely untargetable in battle? for now I'm using the "module_hull_bar_only" tag, but that still looks iffy when the player zooms in / gets their mouse too close to the ship.

You could make it take no hull damage (by setting the hull damage taken multiplier to 0) but I don't think that's what you want. Aside from that, no - if something can get damaged, it can have a hull bar and can be targeted; that seems fairly fundamental.

2 - is there a good, consistent way to prevent explosions from missiles / projectiles "leaking" past a module's shields & hitting the main hull?
I've got a frigate with a secondary shield as a system, and if a missile w/ a big enough explosion (it's pretty close to the main hull so an atropos can do it in my case) hits the outer shield, it'll deal damage to both the outer shield & main ship in 2 separate instances (one for the missile on the module, one for the explosion on the main ship) with nothing really connecting the two for me to throw into a damageTakenModifier listener.

Hmm - that sounds like a bug. Are you positive this is what's happening? Looking at the code, it seems like when a missile hits something and explodes, the explosion treats... ahh, crap, I see. What it was doing is making sure the explosion could not hit 1) any of the target's child modules, and 2) any of its parents' child modules. But it was not including the parent - which, in vanilla, didn't matter because the parent hull is always undamageable so it never came up. Fixed!
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8914 on: July 09, 2022, 02:22:14 PM »

Hmm - that sounds like a bug. Are you positive this is what's happening? Looking at the code, it seems like when a missile hits something and explodes, the explosion treats... ahh, crap, I see. What it was doing is making sure the explosion could not hit 1) any of the target's child modules, and 2) any of its parents' child modules. But it was not including the parent - which, in vanilla, didn't matter because the parent hull is always undamageable so it never came up. Fixed!

Glad to see that fixed. I had noticed it still happening with Roider armor but never got around to proving and reporting it.
Logged

Inhilicon

  • Lieutenant
  • **
  • Posts: 61
  • I like when the ship
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8915 on: July 09, 2022, 06:23:10 PM »

Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8916 on: July 09, 2022, 06:27:13 PM »

Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
consider 4-5 wings of piranha releasing their load

that is similar to what you're describing. If you think that doesn't strain a modern computer, you're fine.

It's not like the projectiles are scripted to do something else right? haha...

Inhilicon

  • Lieutenant
  • **
  • Posts: 61
  • I like when the ship
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8917 on: July 09, 2022, 06:39:15 PM »

Hi! I was wondering if making a weapon that spits out a lot of projectiles causes some form of strain for modern computers. I would think no, but I was thinking that if I have three of this same weapon I'm making, would it cause problems when there are multiple users of such a weapon? This is a three to five-barreled weapon that fires 10 or 6 times in a quick barrage.
consider 4-5 wings of piranha releasing their load

that is similar to what you're describing. If you think that doesn't strain a modern computer, you're fine.

It's not like the projectiles are scripted to do something else right? haha...

That's right! They are just standard hurty projectiles with nothing else to them. Thanks for the lightning fast reply, friend.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8918 on: July 09, 2022, 08:11:00 PM »

That's quite literally what ShipTypeHints.STATION is for! Not sure why you have it in a try/catch, though, that should not be necessary.

Does that go for modded stations, too, and how about telling if it's a module?  Regardless, I'm relieved to know I might not need that try/catch block.

JAL28

  • Commander
  • ***
  • Posts: 217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8919 on: July 10, 2022, 08:04:16 AM »

Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8920 on: July 10, 2022, 09:06:36 AM »

Also, I've noticed a duplication in the API: FighterWingSpec and FighterWingSpecAPI.  Will either of these be deprecated?  I want to use the former in my mod because it has the setRange(float range) method.

Edit: I think FighterWingSpec might be obfuscated.

Edit 2: Yes, it is obfuscated.  May I proxy this method?

Edit 3: And the getRange() method?

Edit 4: Proxy ready!  Awaiting permission.
« Last Edit: July 10, 2022, 10:02:55 AM by Liral »
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8921 on: July 10, 2022, 09:32:56 AM »

you could make it take no hull damage (by setting the hull damage taken multiplier to 0) but I don't think that's what you want. Aside from that, no - if something can get damaged, it can have a hull bar and can be targeted; that seems fairly fundamental.

yeah, that's fair- I was gonna use or well, try to opengl to put a second health bar in a "proper" place, but instead i'll just make it invincible & have it kill itself when the main ship dies (it's not really meant to die before the main ship anyway)

and thanks for fixing up that bug! honestly, I'm surprised it's not come up / been fixed earlier, people on discord were pretty happy to see it fixed.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8922 on: July 10, 2022, 12:05:54 PM »

Does that go for modded stations, too, and how about telling if it's a module?  Regardless, I'm relieved to know I might not need that try/catch block.

It should go for modded stations too, yeah - if a station doesn't have that hint, that's a bug.

For telling it's a module, you're right, there isn't anything specific, but the way you're checking for it looks good to me.

Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.

I don't think so, sorry!

Also, I've noticed a duplication in the API: FighterWingSpec and FighterWingSpecAPI.  Will either of these be deprecated?  I want to use the former in my mod because it has the setRange(float range) method.

Edit: I think FighterWingSpec might be obfuscated.

Edit 2: Yes, it is obfuscated.  May I proxy this method?

Edit 3: And the getRange() method?

Edit 4: Proxy ready!  Awaiting permission.

Yeah, go for it! And, thank you for letting me know; added get/setRange() to FighterWingSpecAPI.

and thanks for fixing up that bug! honestly, I'm surprised it's not come up / been fixed earlier, people on discord were pretty happy to see it fixed.

*thumbs up* Yeah, a bit surprised myself.
Logged

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8923 on: July 10, 2022, 01:18:21 PM »

It should go for modded stations too, yeah - if a station doesn't have that hint, that's a bug.

Woo, thanks!

Quote
For telling it's a module, you're right, there isn't anything specific, but the way you're checking for it looks good to me.

Thank you again!

Quote
Yeah, go for it! And, thank you for letting me know; added get/setRange() to FighterWingSpecAPI.

Yaaaaay!  :D

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8924 on: July 10, 2022, 02:06:09 PM »

Is there a way to change the text/descriptor of a mission based on a mod being enabled?

Example: Mission has text A and ships B by default, but have text C and ships D when mod 1 is enabled.

You can switch which ships are added in the mission's script and I think the second mod could replace the mission's description file. That would only work for 1 submod, though.
Logged
Pages: 1 ... 593 594 [595] 596 597 ... 706