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 ... 622 623 [624] 625 626 ... 706

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

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9345 on: November 13, 2022, 05:18:29 PM »

Just wondering where the values for the fluff text and actual scripts are for the "deal with prisoners" skill/ability?

(Working on a mod that gives the option of trying to recruit prisoners either as crew or marines for credits, instead of torturing them into serving you.)
(Named) prisoners are a mod feature, so you'll want to adapt one of the two mods (a specific one) that implement this functionality.

Capture Officers and Crew doesn't have a public source that I could find in 15 seconds. Although you shouldn't be working from this mod anyway.
For Take No Prisoners, look in the src folder for the code (maybe ask presidentmattdamon for help if you can't find a specific function). Dialog text is in data/campaign/rules.csv.
Logged

Silveressa

  • Ensign
  • *
  • Posts: 23
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9346 on: November 13, 2022, 08:26:37 PM »


Capture Officers and Crew doesn't have a public source that I could find in 15 seconds. Although you shouldn't be working from this mod anyway.
For Take No Prisoners, look in the src folder for the code (maybe ask presidentmattdamon for help if you can't find a specific function). Dialog text is in data/campaign/rules.csv.

Thanks for this, it's been a while since I played SS, and I'd forgotten that feature was from a mod and not part of the core gameplay  :P. Regardless, now I know its another modders work  I don't plan on working from their mods specifically, but more using one of them as an example of how to organize the coding and layout so it functions as desired.
Logged

vicegrip

  • Commander
  • ***
  • Posts: 184
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9347 on: November 18, 2022, 12:11:05 AM »

I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

Also what are the string values that are returned for getAICoreId()? For example if the AI core is an alpha, does it return "alpha" or something else?

Finally, is there a way to replace the description of a ship with a new one upon adding a hullmod?

« Last Edit: November 18, 2022, 01:07:03 AM by vicegrip »
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9348 on: November 18, 2022, 05:44:06 PM »

is there a way to completely intercept an input and stop the game from acting on it?
I'm making an in-combat GUI & I'd like to have text fields in it if possible. (well, they'd be possible anyway, albeit extremely janky)
my best guess is that consume()'ing both the down & up event would do it, though I've not been able to think of a good way of tracking what event trails from another
(also, why is the list of keycodes seemingly non-standard? the VK_etc constants in java.awt.event didn't seem to match up with the ones the game returns)

I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

checking for the automated ship hullmod should be enough here, there's no way (afaik) to have an ai core pilot a ship otherwise.
« Last Edit: November 18, 2022, 05:48:51 PM by Ruddygreat »
Logged

vicegrip

  • Commander
  • ***
  • Posts: 184
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9349 on: November 18, 2022, 06:07:00 PM »

I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

checking for the automated ship hullmod should be enough here, there's no way (afaik) to have an ai core pilot a ship otherwise.

The idea for the mod is to convert certain modded automated ships into human pilotable versions, but have the conversion hullmod instillation be invalid if the ship has an AI captain (especially an integrated one), but valid if the ship is currently unpiloted, so sadly just checking for the automated hullmod won't do. Although I suppose having an is ship being captained check is fine too.

I also had plans to make hullmods that would give bonuses that scale with the AI core grade, so it would be helpful to know how to check for captain status rather than just the hullmod's existence.
« Last Edit: November 18, 2022, 06:08:31 PM by vicegrip »
Logged

Audax

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9350 on: November 19, 2022, 01:42:05 AM »

Is it possible to get a projectileSpec or weaponSpec without spawning the weapon or projectile in combat? trying to get stats of a projectile for calculations purposes before spawning it in.
« Last Edit: November 19, 2022, 02:43:17 AM by Audax »
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9351 on: November 19, 2022, 08:03:03 AM »

Is it possible to get a projectileSpec or weaponSpec without spawning the weapon or projectile in combat? trying to get stats of a projectile for calculations purposes before spawning it in.

yeah, Global.getSettings.getWeaponSpec("weaponId"); will return the weapon you want, then weaponSpecAPI.getProjectileSpec(); can get you the projectile.

Audax

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9352 on: November 19, 2022, 10:50:19 AM »

yeah, Global.getSettings.getWeaponSpec("weaponId"); will return the weapon you want, then weaponSpecAPI.getProjectileSpec(); can get you the projectile.
Nice, ty
« Last Edit: November 19, 2022, 10:56:48 AM by Audax »
Logged

Amazigh

  • Captain
  • ****
  • Posts: 284
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9353 on: November 19, 2022, 11:19:39 PM »

Is there a way to set a weapon to render under engine glows?

If not, (which is how it appears to be) would it be possible to add one? (pretty please alex)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9354 on: November 20, 2022, 10:30:13 AM »

I am trying to create a hullmod which either can or cannot be applied depending on whether the current ship captain is an AI core. How do I call the getCaptain().isAICore() method of FleetMemberAPI within the hullmod class to determine the captain of the current ship on the fitting screen?

See: WolfpackTactics.isFrigateAndOfficer() for an example of this sort of thing.


Also what are the string values that are returned for getAICoreId()? For example if the AI core is an alpha, does it return "alpha" or something else?

The id of the ai core "commodity" (from commodities.csv); see: the Commodities class, which has a bunch of data members with these ids for easy reference, e.g. Commodities.ALPHA_CORE etc.


Finally, is there a way to replace the description of a ship with a new one upon adding a hullmod?

Not that I can think of!


is there a way to completely intercept an input and stop the game from acting on it?
I'm making an in-combat GUI & I'd like to have text fields in it if possible. (well, they'd be possible anyway, albeit extremely janky)
my best guess is that consume()'ing both the down & up event would do it, though I've not been able to think of a good way of tracking what event trails from another

Hmm, maybe - consume() should in theory do it but I think that by the time you're getting these events the game has already acted on them in that frame? Not 100%; depends on where you're doing this from etc, I'd suggest just giving it a try?

(also, why is the list of keycodes seemingly non-standard? the VK_etc constants in java.awt.event didn't seem to match up with the ones the game returns)

They're constants from the org.lwjgl.input.Keyboard class IIRC; depending on what exactly you're talking about.


Is there a way to set a weapon to render under engine glows?

If not, (which is how it appears to be) would it be possible to add one? (pretty please alex)

I don't think so. Ahh, sorry, it'd be kind ofquite a pain!
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9355 on: November 20, 2022, 03:39:02 PM »

Hmm, maybe - consume() should in theory do it but I think that by the time you're getting these events the game has already acted on them in that frame? Not 100%; depends on where you're doing this from etc, I'd suggest just giving it a try?

They're constants from the org.lwjgl.input.Keyboard class IIRC; depending on what exactly you're talking about.

I'm doing it in the processInputPreCoreControls method of a baseEveryFrameCombatPlugin, rn I'm just checking for isKeyDownEvent() & consuming them (and I'd been hoping that that'd pre-emptively eat the input), I'll look for a workaround.

and ty for pointing me there, that seems to be the right class!

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9356 on: November 20, 2022, 06:26:31 PM »

Ah - if it's processInputPreCoreControls(), then it might do what you're expecting. I mean, the thing to do would be to test if it does?
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 #9357 on: November 22, 2022, 08:20:25 AM »

We are re-implementing the code that calculates damage to the hit cell and surrounding cells of an ArmorGridAPI and resulting damage (without any other modifiers) to the hull for our Starsector research project but do not quite know how it works and cannot find any reference implementation or a rigorous specification for one, so I have proposed one below.  Is it exactly correct?   :D

Code
    private static float getPooledArmor(
        final int iHit,
        final int jHit,
        final ArmorGridAPI armorGrid,
    ) {
        float pooledArmor = 0;
        for (int i = 0; i < 5; i++)
            for (int j = 0; i < 5; j++)
                if ((i == 0 || i == 5) && (j == 0 || j == 5)) //skip corners
                    continue;
                else if (i == 0 || i == 5 || j == 0 || j == 5) //edges contribute half value
                    pooledArmor += 0.5 * armorGrid.getArmorValue(iHit + i, jHit + j);
                else //center 9 contribute full value
                    pooledArmor += armorGrid.getArmorValue(iHit + i, jHit + j);
        return pooledArmor;
    }
   
    private static float getHullDamage(
        final float damage,
        final float pooledArmor,
        final float armorRating,
        final float minimumArmorFactorForHullDamageReduction
    ) {
        return damage
               * damage
               / (damage + Math.max(pooledArmor, armorRating * minimumArmorFactorForHullDamageReduction));
    }
   
    private static float getArmorDamage(
        final boolean isBeam,
        final float damage,
        final float pooledArmor,
        final float maxArmorDamageReductionFactor,
        final DamageType damageType
    ) {
        float hitStrengthAgainstArmor = damage * (isBeam ? 0.5f : 1);
        switch (damageType) {
            case KINETIC: hitStrengthAgainstArmor *= 0.5;
            case HIGH_EXPLOSIVE: hitStrengthAgainstArmor *= 2;
            case FRAGMENTAETION: hitStrengthAgainstArmor *= 0.25f;
        }
        return hitStrengthAgainstArmor
               * Math.max(1 - maxArmorDamageReductionFactor,
                          hitStrengthAgainstArmor / (hitStrengthAgainstArmor + pooledArmor));
    }
   
    private static void damageArmorGrid(
        final int iHit,
        final int jHit,
        final float armorDamage,
        final ArmorGridAPI armorGrid
    ) {
       for (int i = 0; i < 5; i++)
            for (int j = 0; i < 5; j++)
                if ((i == 0 || i == 5) && (j == 0 || j == 5)) //skip corners
                    continue;
                else if (i == 0 || i == 5 || j == 0 || j == 5) //edges take half damage
                    armorGrid.setArmorValue(i, j, Math.max(0, armorGrid.getArmorValue(i,j) - 0.5 * armorDamage));
                else //center 9 take full damage
                    armorGrid.setArmorValue(i, j, Math.max(0, armorGrid.getArmorValue(i,j) - armorDamage)); 
    }
   
    private static void applyDamage(
        final boolean isBeam,
        final int iHit,
        final int jHit,
        final float damage,
        final float minimumArmorFactorForHullDamageReduction,
        final float maxArmorDamageReductionFactor,
        final DamageType damageType,
        final ShipAPI ship
    ) {
        final ArmorGridAPI armorGrid = ship.getArmorGrid();

        //calculate damage
        final float pooledArmor = getPooledArmor(armorGrid, iHit, jHit);
        final float hullDamage = getHullDamage(damage, pooledArmor, armorGrid.getArmorRating(), minimumArmorFactorForHullDamageReduction);
        final float armorDamage = getArmorDamage(isBeam, damage, pooledArmor, maxArmorDamageReductionFactor, damageType);
       
        //apply damage
        damageArmorGrid(iHit, jHit, armorDamage, armorGrid);
        ship.setHitpoints(Math.max(ship.getHitpoints() - hullDamage, 0)); //obviously makes ship disappear rather than explode, but we don't care about that effect
    }
« Last Edit: November 22, 2022, 08:32:45 AM by Liral »
Logged

Audax

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9358 on: November 22, 2022, 08:35:16 AM »

How to change the explosion effect when a missile runs out of flight time or fizzling?

Raif Redacted

  • Ensign
  • *
  • Posts: 22
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9359 on: November 22, 2022, 07:38:46 PM »

Is it possible to create a new category of hullmod that applies a logistics-style two-at-once rule? I want to split the logistics hullmods into two categories: Supply and Science. Basically, toss the "find us more room for people and things, and be more efficient at it!" into one pile and then "Go do science for us!" into the other, but still apply the current logistics rule to both.
Logged
Pages: 1 ... 622 623 [624] 625 626 ... 706