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 ... 615 616 [617] 618 619 ... 706

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

boggled

  • Admiral
  • *****
  • Posts: 1127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9240 on: October 05, 2022, 10:21:52 AM »

In CampaignPlanet, the following methods are used to get and set the planet type:

Code
public String getTypeId() { return this.graphics.getType(); }

public void setTypeId(String var1) { this.type = var1; }

If you call setTypeId(), getTypeId() will continue to return the old value from graphics (which is a Planet object) until readResolve() is called and a new Planet object with the new type is set.

Code
protected Object readResolve() {
    super.readResolve();
    this.graphics = new Planet(this.type, this.radius, 0.0F, new Vector2f());

It appears that readResolve() can only be called when the save file is loaded, and there's no other way to update the Planet object with the new type until then, as type is private and has no setter method (and reflection is blocked).

This creates an issue because the Farming industry appears to use getTypeId() to figure out whether it's an aquaculture or not, and if the player terraforms the planet to or from a water world, then farming/aquaculture will be the wrong version until they reload the save.

It's possible I'm missing something - is there any way to update the type string stored in the graphics Planet object immediately for terraforming purposes?
Logged

Great Wound

  • Captain
  • ****
  • Posts: 268
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9241 on: October 05, 2022, 01:57:55 PM »

Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9242 on: October 05, 2022, 07:13:22 PM »

I would like to add a weapon icon to a hull mods description through Tooltip.addImage

but...
WeaponSpecAPI.getHardpointSpriteName() and WeaponSpecAPI.getTurretSpriteName() might sometimes return weapons without barrels/recoil/missiles (like Needler)

and the ToolTipMakerAPI.addImage only accepts string not SpriteAPI. Does one exist where I can addImage through SpriteAPI or alternatively is there a way to grab the sprite image when it's displayed in codex or refit

Liral

  • Admiral
  • *****
  • Posts: 717
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9243 on: October 05, 2022, 11:05:33 PM »

I might have found a bug in the API: MissileSpecAPI.setFlightTime(float time) and MissileSpecAPI.setFlightTime(float time) do not change the flight time and flameout time of the MissileSpecAPI of every associated WeaponSpecAPI.

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9244 on: October 06, 2022, 12:28:36 AM »

Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",
The simplest way is to make the projectile a torpedo, although that does have some side effects.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9245 on: October 06, 2022, 07:40:55 AM »

I absolutely see that battling drift away behavior in vanilla.

If you ever manage to snag a vanilla save where that's happening, I'd love to take a closer look! I don't think it's necessarily the same issue that NikoTheGuyDude is running into, though, the fleet movement in that video looked pretty fast and just different, to me at least. (I've seen some "battle drift" behavior before, though those causes iirc had been fixed.)

It's possible I'm missing something - is there any way to update the type string stored in the graphics Planet object immediately for terraforming purposes?

I'm not sure. What I can tell you is I was recently trying to do this, ran into no end of trouble, and added a PlanetAPI.changeType() method that takes care of a bunch of thorny under-the-hood details.


Am I missing a trick with weapon projectiles (.proj files)? Trying to create a ballistic projectile that splits on proximity:
   "behaviorSpec":{"behavior":"MIRV"
doesn't appear to work with:
   "specClass":"projectile",

You're right, it doesn't. IIRC the only behavior that works for ballistics is whatever the flak and simular use for proximity explosions.


I would like to add a weapon icon to a hull mods description through Tooltip.addImage

but...
WeaponSpecAPI.getHardpointSpriteName() and WeaponSpecAPI.getTurretSpriteName() might sometimes return weapons without barrels/recoil/missiles (like Needler)

and the ToolTipMakerAPI.addImage only accepts string not SpriteAPI. Does one exist where I can addImage through SpriteAPI or alternatively is there a way to grab the sprite image when it's displayed in codex or refit

There *is* no one sprite for weapons with barrels or missiles, it's composited together from the various pieces depending on how the weapon is set up. Your best bet might be to add something like TooltipMakerAPI.showCargo(), though that likely won't do quite what you want.

I might have found a bug in the API: MissileSpecAPI.setFlightTime(float time) and MissileSpecAPI.setFlightTime(float time) do not change the flight time and flameout time of the MissileSpecAPI of every associated WeaponSpecAPI.

The spec is clone()'ed when it's assigned to the various weapons. (Edit: having different missile stats in weapon_data.csv for weapons that share the same missile spec doesn't work, though, I don't think. I don't remember the details, if we're being honest! Now I'm wondering if maybe it *would* work now and if the clone() call is a more recent change. Regardless, though, not a bug!)
« Last Edit: October 06, 2022, 07:44:21 AM by Alex »
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 #9246 on: October 06, 2022, 08:07:12 AM »

The spec is clone()'ed when it's assigned to the various weapons. (Edit: having different missile stats in weapon_data.csv for weapons that share the same missile spec doesn't work, though, I don't think. I don't remember the details, if we're being honest! Now I'm wondering if maybe it *would* work now and if the clone() call is a more recent change. Regardless, though, not a bug!)

Glad it's not a bug!   On the other hand, modifying the EngineSpecAPI of the ShipHullSpecAPI of the MissileSpecAPI of one WeaponSpecAPI modifies the same of all such MissileSpecAPI, despite their being cloned.  In other words, if I double the acceleration of the missile of the Harpoon (Single) and then double the acceleration of the missile of the Harpoon (double) then the acceleration of the Harpoon (double) will be four times what it originally was instead of two.  That is, the following code,

Code
private static void getEngineSpec(final WeaponSpecAPI weaponSpec) {
    return ((MissileSpecAPI) (weaponSpecAPI.getProjectileSpecAPI)).getEngineSpecAPI();
}

private static void doubleAcceleration(final WeaponSpecAPI weaponSpec) {
    engineSpec.setAcceleration(2 * getEngineSpec(weaponSpec).getAcceleration());
}

final WeaponSpecAPI
    harpoonMRMSingle = Global.getSettings().getWeaponSpec("harpoon_mrm_single"),
    harpoonMRM = Global.getSettings().getWeaponSpec("harpoon_mrm");

println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

doubleAcceleration(harpoonMRMSingle);
println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

doubleAcceleration(harpoonMRM);
println("single: " + getAcceleration(harpoonMRMSingle));
println("rack: " + getAcceleration(harpoonMRM));

would print

Code
single: 1000
rack: 1000

single: 2000
rack: 2000

single: 4000
rack: 4000

 :o
« Last Edit: October 06, 2022, 02:08:25 PM by Liral »
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9247 on: October 06, 2022, 08:17:18 AM »

There *is* no one sprite for weapons with barrels or missiles, it's composited together from the various pieces depending on how the weapon is set up. Your best bet might be to add something like TooltipMakerAPI.showCargo(), though that likely won't do quite what you want.

Hmmmm that could work since I just need a sprite.. I'm just more afraid of the new CargoAPI constantly made and not being GCed. Thanks!

Cry0genic

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9248 on: October 06, 2022, 11:33:29 AM »

How do I edit the save file to change the ownership of a station constructed by TASC?

Console command seemingly doesn't work because the string for its ID is too long at Epsilon Kupe Star System20734MiningStationMarket.

I am unable to change the ownership of the station properly by editing the <factionid> to the ID of the faction in question and <playerowned> to false.  So far, editing both fields made it so that the faction colors changed in the UI, but not in the campaign layer, where it's still designated to belong to the player.

Can someone explain which fields do I need to change to fully transfer the market into another faction?
« Last Edit: October 07, 2022, 09:33:04 AM by Cry0genic »
Logged

alaricdragon

  • Commander
  • ***
  • Posts: 145
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9249 on: October 06, 2022, 04:31:45 PM »

hey all.
I'm trying to edit the upkeep cost of hazard pay on an world right now, and i cant seem to find anything about changing hazard pay at all
is there an way i can replace the hazard pay function with one of my own?
or if that's not possible is there a way to add an income / upkeep cost to an market with code?
thank you all for the help given in the past. i wish you all an good day.
Logged

Timid

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

Are we still sure the difference between hardpoints and turrets still accurate?

There seems to be -50% recoil for hardpoints.
Hitpoints are doubled on hardpoints.
And they seem to render on top of turrets more,
but I question the turn rate penalties since I'm grabbing the weapon's hardpoint and turret turn rate and it's roughly -95% not -50%

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9251 on: October 06, 2022, 07:13:47 PM »

How do I edit the save file to change the ownership of a station constructed by TASC?

Console command seemingly doesn't work because the string for its ID is too long at Epsilon Kupe Star System20734MiningStationMarket.

I am unable to change the ownership of the station properly by editing the <factionid> to the ID of the player and <playerowned> to false.  So far, editing both fields made it so that the faction colors changed in the UI, but not in the campaign layer, where it's still designated to belong to the player.

Can someone explain which fields do I need to change to fully transfer the market into another faction?
The Nex console command should just work if you use the human name with underscores instead of spaces (doesn't need to be an exact match), e.g. I just tested it with setmarketowner togar_mining_station hegemony

The issue you had with save editing is probably because you need to change the market faction as well as the entity faction (and ideally the submarket faction, and the factions of the people on the comm board... you can see where this gets troublesome)
Logged

Cry0genic

  • Ensign
  • *
  • Posts: 8
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9252 on: October 07, 2022, 09:35:02 AM »

The Nex console command should just work if you use the human name with underscores instead of spaces (doesn't need to be an exact match), e.g. I just tested it with setmarketowner togar_mining_station hegemony

The issue you had with save editing is probably because you need to change the market faction as well as the entity faction (and ideally the submarket faction, and the factions of the people on the comm board... you can see where this gets troublesome)

Thank you for the help. It works now, and yes, I can see how troublesome it'd be to manually change everything one at a time through the save file, to say nothing of how long it takes to process the million+ lines present every time it's opened.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9253 on: October 07, 2022, 10:14:52 AM »

On the other hand, modifying the EngineSpecAPI of the ShipHullSpecAPI of the MissileSpecAPI of one WeaponSpecAPI modifies the same of all such MissileSpecAPI, despite their being cloned.

Probably means the clone is not a "deep" copy, meaning for the engine slots (and possibly other things) it just copies references to the same objects instead of cloning the objects. You're pretty deep into "should not rely on this internal behavior and it could change at some random time without notice" territory, though :)


I'm just more afraid of the new CargoAPI constantly made and not being GCed. Thanks!

Unless you're storing the reference to that CargoAPI somewhere that's already leaking, this shouldn't be any kind of concern?


hey all.
I'm trying to edit the upkeep cost of hazard pay on an world right now, and i cant seem to find anything about changing hazard pay at all
is there an way i can replace the hazard pay function with one of my own?
or if that's not possible is there a way to add an income / upkeep cost to an market with code?
thank you all for the help given in the past. i wish you all an good day.

It's not adjustable on a per-market basis, short of changing the market's hazard rating. You can modify both income and upkeep pretty easily, though.

MarketAPI.getIncomeMult()
Industry.getIncome()
Industry.getUpkeep()

Etc. I'd recommend looking at how these and related are used to get an idea.


Are we still sure the difference between hardpoints and turrets still accurate?

There seems to be -50% recoil for hardpoints.
Hitpoints are doubled on hardpoints.
And they seem to render on top of turrets more,
but I question the turn rate penalties since I'm grabbing the weapon's hardpoint and turret turn rate and it's roughly -95% not -50%

Looking at the code, it seems like the turn rate of hardpoints should be set to a quarter of turreted/hidden weapons. There's a complication here that the turn rate gets a 5x boost when the weapon is not firing (unless it has a special AI hint), and the boosted rate is capped to 360 degrees per second, and this bonus only applies to turrets/hidden slots, not to hardpoints.
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 #9254 on: October 07, 2022, 02:39:58 PM »

Probably means the clone is not a "deep" copy, meaning for the engine slots (and possibly other things) it just copies references to the same objects instead of cloning the objects. You're pretty deep into "should not rely on this internal behavior and it could change at some random time without notice" territory, though :)

Thanks.  Ok, I'll check at each version!  (I hope the clone does become deep, now that you mention it)
Pages: 1 ... 615 616 [617] 618 619 ... 706