Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Hyperspace Topography (10/12/22)

Pages: 1 ... 616 617 [618] 619 620 ... 637

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

Liral

  • Admiral
  • *****
  • Posts: 529
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9255 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)

Timid

  • Admiral
  • *****
  • Posts: 583
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9256 on: October 07, 2022, 09:10:03 PM »

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?
I'm only using this
Code
                CargoAPI FakeCargo = Global.getFactory().createCargo(false);
                FakeCargo.addWeapons(weapon.getId(), 1);
                tooltip.showCargo(FakeCargo, 1, true, opad);
in a addPostDescriptionSection for a hullmod.

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.
Interesting.. is this 5x boost applied as an mult or modifyPercent and how does it get capped? like a math.max? Does this apply overall like no weapons should turn more than 360 degrees?

Or is this like if a weapon can spin 200 degrees, the 5x boost can only apply +160 degrees or +360 degrees?


Edit
Is there also a way to grab a ProjectileSpecAPI or a MissileSpecAPI from a MIRV sub ammunition missile while in a refit screen?

I'm unsure how I could grab it through
Code
((MissileSpecAPI)weapon.getSpec().getProjectileSpec()).getBehaviorJSON().getString("projectileSpec")
I tried
Code
Global.getSettings().getSpec(MissileSpecAPI.class, "sabot_warhead2", true)
and
Code
Global.getSettings().getJSONObject("sabot_warhead2")

Or is this feature unsupported?

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 21225
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9257 on: October 09, 2022, 06:06:16 PM »

I'm only using this
Code
                CargoAPI FakeCargo = Global.getFactory().createCargo(false);
                FakeCargo.addWeapons(weapon.getId(), 1);
                tooltip.showCargo(FakeCargo, 1, true, opad);
in a addPostDescriptionSection for a hullmod.

Barring some terrible bug in vanilla, you've got nothing to worry about there.

Interesting.. is this 5x boost applied as an mult or modifyPercent and how does it get capped? like a math.max? Does this apply overall like no weapons should turn more than 360 degrees?

Or is this like if a weapon can spin 200 degrees, the 5x boost can only apply +160 degrees or +360 degrees?

IIRC it's a separate multiplier applied after all other modifiers (so, equivalent to modifyMult, but not actually that). And, yeah, 200 would turn into 360.


Edit
Is there also a way to grab a ProjectileSpecAPI or a MissileSpecAPI from a MIRV sub ammunition missile while in a refit screen?

I'm unsure how I could grab it through
Code
((MissileSpecAPI)weapon.getSpec().getProjectileSpec()).getBehaviorJSON().getString("projectileSpec")
I tried
Code
Global.getSettings().getSpec(MissileSpecAPI.class, "sabot_warhead2", true)
and
Code
Global.getSettings().getJSONObject("sabot_warhead2")

Or is this feature unsupported?

You'd need to call getSpec(MissileSpec.class - using an internal core class. You could then cast the result to MissileSpecAPI. (So, basically: unsupported "properly".)
Logged

SirHartley

  • Admiral
  • *****
  • Posts: 644
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9258 on: October 11, 2022, 08:25:07 AM »

Orbital station code (OrbitalStation) will fetch any entity with the station tag as valid entity for the defensive station:

Code
	protected void ensureStationEntityIsSetOrCreated() {
if (stationEntity == null) {
for (SectorEntityToken entity : market.getConnectedEntities()) {
if (entity.hasTag(Tags.STATION)) {
stationEntity = entity;
usingExistingStation = true;
break;
}
}
}

if (stationEntity == null) {
stationEntity = market.getContainingLocation().addCustomEntity(
null, market.getName() + " Station", Entities.STATION_BUILT_FROM_INDUSTRY, market.getFactionId());
SectorEntityToken primary = market.getPrimaryEntity();
float orbitRadius = primary.getRadius() + 150f;
stationEntity.setCircularOrbitWithSpin(primary, (float) Math.random() * 360f, orbitRadius, orbitRadius / 10f, 5f, 5f);
market.getConnectedEntities().add(stationEntity);
stationEntity.setMarket(market);
}
}

now, I am adding a second station to the planet, and it fetches it and breaks.
could you maybe change that small section of code to

Code
if (entity.hasTag(Tags.STATION) && !entity.hasTag("NO_ORBITAL_STATION")) {
stationEntity = entity;
usingExistingStation = true;
break;
}

Many thanks,
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 21225
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9259 on: October 14, 2022, 09:38:55 AM »

Hmm, I'm not 100% sure that would fully resolve the issue. Even if it did, this is the sort of thing that I might easily break by making some other changes - I'd kind of recommend providing your own implementation of OrbitalStation if you're doing something like this.
Logged

SirHartley

  • Admiral
  • *****
  • Posts: 644
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9260 on: October 14, 2022, 09:48:46 AM »

That's what I did - I implemented my exact change, but I can't exactly adjust modded stations that are extending the OrbitalStation class.
It did resolve the issue without problem.
Logged

Liral

  • Admiral
  • *****
  • Posts: 529
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9261 on: October 14, 2022, 02:16:31 PM »

While seeking the instance of a class my decompiler calls com.fs.starfarer.coreui.refit.C to work the dark magic of calling the inherited remove and addTooltip instance methods to replace the hardcoded armor tooltip of the refit screen

Code
package com.fs.starfarer.coreui.refit;

import ...

public class C extends v implements com.fs.starfarer.coreui.refit.L.o {
    ...
    public void addTooltips() {
        ...
        var6 = new StandardTooltipV2Expandable(var4, false) {
            public void createImpl(boolean var1) {
                this.addPara("Armor reduces the damage taken by a percentage that depends on the relative strength of the armor compared to the amount of damage, and blocks damage from getting through to the hull.", 0.0F);
                this.addPara("Each hit reduces the amount of armor that remains in the affected area, making each successive hit more and more powerful.", 10.0F);
                this.addPara("Damage applied in a single hit is much more effective at stripping away armor than the same damage distributed over multiple hits.", 10.0F);
                this.addPara("The \"hit strength\" of beam weapons - which do not score separate hits, but deal damage continuously - is based on their damage/second.", 10.0F);
                this.addPara("The effective armor value can not go below %s of its original value, even if it's stripped away entirely, and damage reduction from armor can not exceed %s.", 10.0F, var5, new String[]{Math.round(StarfarerSettings.String.class() * 100.0F) + "%", Math.round(StarfarerSettings.ÓÔ0000() * 100.0F) + "%"});
            }
        };
        this.addTooltip(this.öÓØ000, var6);
        ...
    }
    ...
}

to describe the armor mechanic conversion of my mod, I clambered up an intriguing obfuscated dependency tree to a class of the same name in a different package and found this "special shout out".

Quote from: Alex

"Nobody will ever pirate starfarer, because starfarer is not pirateable. It is not pirateable because I am so god damned good at writing top secret code like this. Are you not amazed by how truly awesome this code is. Well if you are not, balls to you then. Youve got some nerve, mister. Oh and another thing, just because I have this string in here does not mean that the crackers that will trying to cracj this software won't crack it. THey will crack it, but when they discover this special shout out they will not go on any further with their cracking efforts. They will simply say: Wow. These guys had heart. I will not"

;D

Do you know where the instance of com.fs.starfarer.coreui.refit.C is stored so I can call these methods to change the tooltip?
« Last Edit: October 14, 2022, 02:50:24 PM by Liral »
Logged

DanzyDanz

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9262 on: October 14, 2022, 06:46:36 PM »

Don't know if this has ever been asked before, but how do you make a DP increase hullmod? Trying to start a hard mode ish game and haven't gotten any luck tweaking some mod files
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 21225
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9263 on: October 14, 2022, 06:58:05 PM »

That's what I did - I implemented my exact change, but I can't exactly adjust modded stations that are extending the OrbitalStation class.
It did resolve the issue without problem.

Ah! Added.

Do you know where the instance of com.fs.starfarer.coreui.refit.C is stored so I can call these methods to change the tooltip?

Sorry, no clue! I'd have to go digging around in obfuscation mappings. Probably not the best thread to ask for help with these, this kind of stuff is extremely "at your own risk".

Don't know if this has ever been asked before, but how do you make a DP increase hullmod? Trying to start a hard mode ish game and haven't gotten any luck tweaking some mod files

Take a look at com.fs.starfarer.api.impl.campaign.skills.DerelictContingent.Level1 - that's where the Derelict Operations skill does the decrease. Could also look at SupportDoctrine.
Logged

Wisdomcube2000

  • Ensign
  • *
  • Posts: 3
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9264 on: October 14, 2022, 07:10:27 PM »

Trying to make my own version of the phase cloak with the intention of changing the color. So I copied over the details in ship_systemscsv and the phasecloak system file (I changed next to nothing). In game it works, you hear the sound effects, you see the unique system name/details, but none of the glow effects work. I noticed even if I alter the _glow image names to something else that would normally have the game yelling at you about it missing, it doesn't care about those missing. Can anyone direct me to what I need to change? Thanks in advance.
Logged

Liral

  • Admiral
  • *****
  • Posts: 529
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9265 on: October 14, 2022, 09:08:17 PM »

Sorry, no clue! I'd have to go digging around in obfuscation mappings. Probably not the best thread to ask for help with these, this kind of stuff is extremely "at your own risk".

:(

Timid

  • Admiral
  • *****
  • Posts: 583
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9266 on: October 15, 2022, 04:14:29 AM »

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.

Okay so.. this is weird!

If the weapon is a turret/hidden weapon and doesn't have that special AI hint, its turn rate is clamped to 360 degrees. Like even if you have a weapon that is 400 degrees, placing it on a turret/hidden mount would always limit to 360,

BUT if you have the special AI hint or you're placing it on a hardpoint, this 360 limit doesn't exist at all. In fact you can set 9999 turn rate in weapon.csv and get 9999(or 2499)  turn rate.

Does it seem like there should be a hard limit of 360 degree regardless of mount or ai hint then?

creature

  • Captain
  • ****
  • Posts: 371
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9267 on: October 15, 2022, 06:15:03 AM »

Hi, is there a way to reference isActive() from a shipsystem set to replace shields (right click shipsystem) in the same way you can do it for the normal shipsystem via ship.system.isActive()?
Logged

Ruddygreat

  • Captain
  • ****
  • Posts: 317
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9268 on: October 15, 2022, 06:00:59 PM »

Hi, is there a way to reference isActive() from a shipsystem set to replace shields (right click shipsystem) in the same way you can do it for the normal shipsystem via ship.system.isActive()?

ship.getPhaseCloak.yadayada(), alternate defence systems are just phase cloaks in a janky trench coat

as for my acutal question - how often does a renderPlugin's render() method get called per-frame?
it seems to happen once while the game is unpaused & twice while the game is paused, though that also doesn't seem quite right



here's 3 cutouts from something I'm drawing w/ the stencil buffer (so it's all one huge coloured quad in the background), the leftmost section is with the alpha being divided by 2 if the engine is paused, the middle is what it looks like when running normally & the rightmost is what it looks like with the normal alpha while the game is paused.
a 4th result I got was when I had the plugin only actually render stuff every other time render() was called if the game was paused - it had the brightness of the left one but flickered every other frame (might've just done it wrong ngl, 2 am coding doesn't lead to good code :p)

particularly though, why is the leftmost one (88,62,89) slightly darker than the middle one (95,65,97) if they should in theory have the same alpha as one is being rendered twice? (though, I guess that 2 layers of wouldn't quite blend to the same as one w/ double alpha somehow?)
« Last Edit: October 15, 2022, 06:02:56 PM by Ruddygreat »
Logged

creature

  • Captain
  • ****
  • Posts: 371
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9269 on: October 15, 2022, 06:06:40 PM »

ship.getPhaseCloak.yadayada(), alternate defence systems are just phase cloaks in a janky trench coat
This works, thanks!

I have another question - is it possible to rotate modules for a specific ship only? When I use this for example:

Code
SHIELD_MODULE.getStationSlot().setAngle(baseFacingRight+this.facingOffsetRight*smoothedAnimLast);

All ships of that type have that slot rotated at the same time, which is definitely not what I want.
Logged
Pages: 1 ... 616 617 [618] 619 620 ... 637