Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 25 26 [27] 28 29 ... 42

Author Topic: API request thread (please read OP before posting!)  (Read 219272 times)

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #390 on: September 23, 2019, 10:44:42 PM »

When is zero not zero?  When using setShield on a ShipAPI:

ship.setShield(ShieldAPI.ShieldType.FRONT, 0f, 1f, 0f);

...this results in a non-zero-arc shield.  It's tiny, but it's still there.

Can we just have a ShieldType.OTHER, that is a "shield" but doesn't actually do anything, other than be raiseable / droppable?
Logged
Please check out my SS projects :)
Xeno's Mod Pack

MesoTroniK

  • Admiral
  • *****
  • Posts: 1731
  • I am going to destroy your ships
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #391 on: September 23, 2019, 11:42:05 PM »

Every frame...

setActiveArc and setArc to 0.0f to beat the rounding function or whatever is going on under the hood.

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #392 on: September 23, 2019, 11:54:32 PM »

Oh, that's ... weird.  I'll give it a go, thank you!
Logged
Please check out my SS projects :)
Xeno's Mod Pack

AnyIDElse

  • Ensign
  • *
  • Posts: 1
  • *Confused Cat Noise*
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #393 on: November 07, 2019, 08:08:08 PM »

something like:
      stats.getCargoMod().modifyFlat(id, ship.getVariant().getNumFluxCapacitors());
won't work.

Actually, almost every campaign-related MutableShipStatsAPI modifications with dynamic values like:
      stats.getFuelMod().modifyFlat(id, dynamicValueA);
      stats.getMaxCrewMod().modifyFlat(id, dynamicValueB);
      stats.getSensorProfile().modifyFlat(id, dynamicValueC);
      stats.getSuppliesPerMonth().modifyFlat(id, dynamicValueD);
won't work.

I hope these issues can be fixed or changed in next updates...
Logged
Waiting For The Solstice.

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #394 on: November 07, 2019, 11:34:23 PM »

something like:
      stats.getCargoMod().modifyFlat(id, ship.getVariant().getNumFluxCapacitors());
won't work.

Actually, almost every campaign-related MutableShipStatsAPI modifications with dynamic values like:
      stats.getFuelMod().modifyFlat(id, dynamicValueA);
      stats.getMaxCrewMod().modifyFlat(id, dynamicValueB);
      stats.getSensorProfile().modifyFlat(id, dynamicValueC);
      stats.getSuppliesPerMonth().modifyFlat(id, dynamicValueD);
won't work.

I hope these issues can be fixed or changed in next updates...

... Until you have to account for the case where a modder tries to modify a mutable stat by itself, and the game crashes with an infinity error of some kind.

Spoiler

If you're trying to adjust stat X based on stat Y (specifically within a hullmod), you can actually get some information by translating ship stats backwards from the applyEffectsAfterShipCreation() method into the applyEffectsBeforeShipCreation() method. Disassemble Reassemble has a hullmod that exploits just that, letting you replace a ship's fighter bays with cargo capacity, and the cargo bonus scales with the number of bays the ship has.

[close]
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #395 on: November 09, 2019, 03:06:45 PM »

Hi Alex!

I would be interested in a way to set either a wing as builtin or as UI-locked.

Use case is a hull mod to add a dedicated launch bay for a particular wing.

Example usage (in hull mod):
Code
public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
        stats.getNumFighterBays().modifyFlat(id, 1f);

        boolean isUILocked_Or_BuiltIn = true;

        int wingIndex = stats.getNumFighterBays().getModifiedInt() - 1;
        stats.getVariant().setWingId(this.wingIndex, wingId, isUILocked_Or_BuiltIn);
}

I couldn't work out a way to do it in the existing API but someone let me know if it is possible :)

Cheers,
Zaphide
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #396 on: November 09, 2019, 03:26:15 PM »

It'd be fantastic if the DModMult (I don't remember the exact name) used by Safety Procedures could be un-hardcoded. For what I've seen it's all set up to be variable, but its defined as a final so we can't change it.

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #397 on: November 09, 2019, 05:00:46 PM »

Hi Alex!

I would be interested in a way to set either a wing as builtin or as UI-locked.

Use case is a hull mod to add a dedicated launch bay for a particular wing.

Example usage (in hull mod)...

I couldn't work out a way to do it in the existing API but someone let me know if it is possible :)

Cheers,
Zaphide

Simplest advice: You also need to tell the game that the ship has a built-in wing of that type.  You start as you have with "ship.getVariant().setWingId(...)", and immediately follow it with "ship.getHullSpec().getBuiltInWings().add(WING_ID)". It doesn't add a new wing, but instead does the equivalent of what you're asking for: it locks that wing you set in as a built-in.

If you want a more detailed look at a working setup, I've got a hullmod kicking around that does exactly that (which I'm quite proud of ;) ). It's much like Converted Hangar, but it adds a built-in wing instead of just a free bay. But beyond that, it's compatible with Converted Hangar, and for that reason is a bit more complex and consists of two independent hullmods.

Take a look at these two hullmod scripts for the full reference:
https://bitbucket.org/AxleMC131/starsector_modding/downloads/DroneHullmod.java
https://bitbucket.org/AxleMC131/starsector_modding/downloads/DroneHullmodManager.java
The first one is the actual hullmod the player installs, and the second one is an invisible auto-install hullmod that allows the first one to work alongside Converted Hangar without breaking anything. They're heavily annotated so you should be able to make sense of them, but if you have any questions feel free to ask in PM.
Logged

Zaphide

  • Admiral
  • *****
  • Posts: 799
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #398 on: November 09, 2019, 08:29:06 PM »

Hi Alex!

I would be interested in a way to set either a wing as builtin or as UI-locked.

<snip>

Simplest advice: You also need to tell the game that the ship has a built-in wing of that type.  You start as you have with "ship.getVariant().setWingId(...)", and immediately follow it with "ship.getHullSpec().getBuiltInWings().add(WING_ID)". It doesn't add a new wing, but instead does the equivalent of what you're asking for: it locks that wing you set in as a built-in.
<snip>

Thanks Axle! Didn't realise I could add it to the built-in's List directly (and also set the wing index). I used your example (tyvm) to do a bit of exploring.

This seems to be something that kind of works but is not exactly directly supported by the API:
- I can't seem to add a fighter bay to a ship if it has an existing built-in wing (the hullmod just doesn't get added at all, no error in log or anything)
   - EDIT: Actually I was wrong about this, seems to work fine :P
 - If I use getHullSpec().getBuiltInWings.add("my_wing_id"), any existing wings also become locked (can get around this by shuffling things around like your example)
- This basically means only using one of these add-built-in-wing type hull mods at any given time
   - EDIT: I think this should be OK if a seperate second hull-mod to manage the removal of the built-in wing is used for each hull-mod type that adds a built-in wing

Given this, I suspect built-in wings are handled a little differently than normal wings and so perhaps it is not so straight-forward an API request :P

EDIT: Actually, it seems fine to add and remove built-in wings if there are already built in wings. Not sure how I was getting that issue. So, only really need to work with the shuffling around of non-built-in wings, which is possible with another hull mod to track (as per your neat example) :)

@Alex, probably OK to not worry about this now :D
« Last Edit: November 09, 2019, 09:10:55 PM by Zaphide »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #399 on: November 09, 2019, 08:31:43 PM »

(Hmm, this might be a better fit for the misc modding questions thread or a separate thread in modding? Haven't really had a chance to dig into it, though; will see if I can check it out tomorrow. If I get sidetracked and don't, please feel free to poke me via PM in a day or so.)
Logged

Armithaig

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
    • Amaranth
Re: API request thread (please read OP before posting!)
« Reply #400 on: November 21, 2019, 03:36:19 PM »

com.fs.starfarer.api.combat.ShipSystemSpecAPI
  • JSONObject getSpecJson()

Moved from DroneLauncherShipSystemAPI to allow for easy access of custom fields in .system files.
Realise's possible to do as much with generic JSON read functions, but if the game's already holding a json spec in memory which the DroneLauncher'd hint at, wasteful to load up the same file twice.

If top-level custom fields in system files're undesirable, perhaps like factions/terrain under a { "custom": { } } matched with
  • JSONObject getCustom()
Logged

tomatopaste

  • Captain
  • ****
  • Posts: 307
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #401 on: December 09, 2019, 07:07:36 PM »

This request is prompted by a weapon I recently scripted with custom projectile velocities and motion.
Demonstration
[close]
As you can see the range indicator as defined by the weapon .csv is misleading due to the range calculation being messed up by the non-linear velocity.

My request is DamagingProjectileAPI.setIsFading(boolean fading) or DamagingProjectileAPI.forceStartFading() to be able to make the projectile fade manually without having to mess around with weapon settings, ultimately creating a range indicator that is misleading to the player and the ai  :D
Logged

boggled

  • Admiral
  • *****
  • Posts: 1136
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #402 on: December 13, 2019, 04:09:10 PM »

I've been working on a terraforming mod and station construction mod, and there's a few minor API changes that would greatly improve the user experience for these types of mods:

-Function to change the type ID of a planet (ex. from water to terran). Doesn't even need to change the graphics, textures, industries, etc. in any way; only the planet type that gets returned for getTypeId() in PlanetAPI.

-Function for getting the OrbitAPI of an asteroid field (so stations and/or other structures can be built in it and maintain the same orbit so as to stay within it over time).

-Function to disable installing AI cores in an industry. There are many mods with industries that remove themselves after they finish building, or where it doesn't make sense to have AI core bonuses.

The planet type ID change in particular seems very easy to implement and would remove a major barrier discouraging people from creating mods that interact with planet types (ex. terraforming mods). Thank you for considering these suggestions!

Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24128
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #403 on: December 13, 2019, 04:29:45 PM »

-Function to change the type ID of a planet (ex. from water to terran). Doesn't even need to change the graphics, textures, industries, etc. in any way; only the planet type that gets returned for getTypeId() in PlanetAPI.

-Function to disable installing AI cores in an industry. There are many mods with industries that remove themselves after they finish building, or where it doesn't make sense to have AI core bonuses.

Figured I might as well add these while I was thinking about it.

Industry.boolean canInstallAICores()
PlanetAPI.setTypeId() -> just sets the string, doesn't do anything else like updating the actual visuals etc.


-Function for getting the OrbitAPI of an asteroid field (so stations and/or other structures can be built in it and maintain the same orbit so as to stay within it over time).

This should already be doable, no? Via AsteroidFieldTerrainPlugin.getEntity().getOrbit()?
Logged

boggled

  • Admiral
  • *****
  • Posts: 1136
    • View Profile
Re: API request thread (please read OP before posting!)
« Reply #404 on: December 14, 2019, 06:30:13 AM »

-Function to change the type ID of a planet (ex. from water to terran). Doesn't even need to change the graphics, textures, industries, etc. in any way; only the planet type that gets returned for getTypeId() in PlanetAPI.

-Function to disable installing AI cores in an industry. There are many mods with industries that remove themselves after they finish building, or where it doesn't make sense to have AI core bonuses.

Figured I might as well add these while I was thinking about it.

Industry.boolean canInstallAICores()
PlanetAPI.setTypeId() -> just sets the string, doesn't do anything else like updating the actual visuals etc.


-Function for getting the OrbitAPI of an asteroid field (so stations and/or other structures can be built in it and maintain the same orbit so as to stay within it over time).

This should already be doable, no? Via AsteroidFieldTerrainPlugin.getEntity().getOrbit()?

That worked! I kept getting a null pointer exception until I cast the CampaignTerrainPlugin as an AsteroidFieldTerrainPlugin. Thanks for all your help!
Logged
Pages: 1 ... 25 26 [27] 28 29 ... 42