Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 650 651 [652] 653 654 ... 711

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

ctuncks

  • Commander
  • ***
  • Posts: 127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9765 on: April 09, 2023, 06:58:52 PM »

Not clones of weapons, but clones of their spec so it can be changed. I think it's been used to, for example, make the fire points move / fire angles change to create beams that sweep, that sort of thing.

WeaponAPI.ensureClonedSpec() is the method that makes a copy of the spec in combat.

So if I wanted a hullmod that implements spec changes such as
Code
weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ONLY);
I would need to use
Code
WeaponAPI.ensureClonedSpec()
and my previous line under
Code
public void advanceInCombat(ShipAPI ship, float amount) {
and that should create spec clones of weapons that meet the conditions only on ships with the hullmod and as soon as combat is over they revert to their default spec?

I just finished up writing and testing this:
Code
public void advanceInCombat(ShipAPI ship, float amount) {

        if (!ship.isAlive()) return;

        List weapons = ship.getAllWeapons();
        Iterator iter = weapons.iterator();
        while (iter.hasNext()) {
            WeaponAPI weapon = (WeaponAPI) iter.next();

            // Not Missile check
            boolean notMissile = weapon.getType() != WeaponAPI.WeaponType.MISSILE;

            // PD tag checkers
            boolean pdAlsoOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.PD_ALSO);
            boolean pdAlsoCon = weapon.hasAIHint(WeaponAPI.AIHints.PD_ALSO);
            boolean antiFtrOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.ANTI_FTR);
            boolean antiFtrCon = weapon.hasAIHint(WeaponAPI.AIHints.ANTI_FTR);
            boolean pdOnlyOrig = weapon.getSpec().getAIHints().contains(WeaponAPI.AIHints.PD_ONLY);
            boolean pdOnlyCon = weapon.hasAIHint(WeaponAPI.AIHints.PD_ONLY);

            // PD Tag Amalgamation
            boolean posCheck = (pdAlsoOrig || pdAlsoCon || antiFtrOrig || antiFtrCon || pdOnlyOrig || pdOnlyCon);

            if (notMissile && posCheck) {

                weapon.ensureClonedSpec(); {
                    weapon.getSpec().getAIHints().add(WeaponAPI.AIHints.PD);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ALSO);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.PD_ONLY);
                    weapon.getSpec().getAIHints().remove(WeaponAPI.AIHints.ANTI_FTR);
                    weapon.getSpec().addTag("pd_up");
                }
            }
        }

It seems to do what I want it to do; setting the PD tag on any weapon that has the PD_ALSO, PD_ONLY or ANTI_FTR whilst removing these tags and as soon as the hullmod is removed it reverts back to normal, can anyone spot any potentially disastrous issues in the above code?
« Last Edit: April 10, 2023, 01:18:42 AM by ctuncks »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9766 on: April 10, 2023, 07:33:30 AM »

This looks good to me! Nice!

(*not to say that I might not be missing something looking it over)
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9767 on: April 10, 2023, 10:41:58 AM »

Just wondering, would you be willing to say where / how the little armour grid readout in the bottom left of the UI is rendered?
Asking in particular because I've made a little thing that renders the player's (and their target's) armour grid over the ships & I've never been entirely happy with the way it's just a square (even though it's technically accurate for the full grid), I'll put an example screenshot below.

example
[close]

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9768 on: April 11, 2023, 10:44:48 AM »

IIRC it uses the ship sprite as a stencil to only render the grid that overlaps the sprite, if that's what you're asking. As in, using GL_STENCIL_TEST etc.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9769 on: April 11, 2023, 01:50:19 PM »

huh, will need to look into that more, I've done some messing with the stencil test but not much, ty!

bananana

  • Commander
  • ***
  • Posts: 229
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9770 on: April 12, 2023, 05:06:25 AM »

is it possible to move individual barrel of a weapon via script?
like when it fires in alternating mode and barrels recoil one by one
but without firing, just move it directly via everyframe script?
Logged
Any and ALL sprites i ever posted on this forum are FREE to use. even if i'm using them myself. Don't ever, EVER ask for permission, or i will come to your home and EAT YOUR DOG!!!
i do NOT want to see my name appear in the credits section of any published mod and will consider it a personal insult.

jujuteux

  • Ensign
  • *
  • Posts: 43
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9771 on: April 12, 2023, 02:04:08 PM »

What application do you use to make your .bin files for musics?
i've been losing my mind trying to find one that isn't long since dead, doesn't work or even supports .bin files
i even just tried opening a .bin file, putting the .ogg files in there and saving but that doesn't work either for starsector

i'm making a hullmod that makes the game play a music during combat but it doesn't work except for playUISound, which won't pause when the game is paused

here's an excerpt of code:
Code
    boolean ranOnce = false;
    boolean startnext = false;
    float fastcounter = 0;
    List<Beat> beatList; //timecode, size

    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        Global.getLogger(this.getClass()).info("corburn spam");
        Global.getSoundPlayer().playSound("system_corrupt_burn_drive_activate", 1f, 1f, ship.getLocation(), ship.getVelocity());
        if(Global.getCombatEngine().getTotalElapsedTime(false) < 5f){
            return;
        }
        if(startnext){//runs once, starts at false until ranOnce check ran
            Global.setSoundPlayer(Global.getSoundPlayer());
            Global.getLogger(this.getClass()).info("cara2");
            Global.getSoundPlayer().playSound("caramelldansen", 1f, 1f, ship.getLocation(), ship.getVelocity());
            Global.getSoundPlayer().pauseMusic();
            startnext = false;

        }
        if(!ranOnce){//runs once, starts at false
            Global.getLogger(this.getClass()).info("cara1");
            Global.getSoundPlayer().playSound("caramelldansen", 1f, 1f, ship.getLocation(), ship.getVelocity());
            ranOnce = true;
            startnext = true;
        }

        startCounter += amount;

        if(isFuntime(startCounter)){
            counter += amount;

            if(counter>0.4f){
                counter -= 0.4f;
                Global.getLogger(this.getClass()).info("corrburn loop");
                Global.getSoundPlayer().playSound("system_corrupt_burn_drive_activate", 1f, 1f, ship.getLocation(), ship.getVelocity());

                ship.getSpriteAPI().setColor(Color.getHSBColor((float) Math.random(), 1f, 1f));

                createRipple(ship, 1f);

            }
        }

for some unknown reason, the game won't play that first everyframe spam, the startnext check nor the ranOnce
but will happily run the "corrburn loop" done every 0.4s (no it's not a clipping issue i think, that sound is like 5s long)

here's what the log looks like (with some excerpts for ease of read
Spoiler
40957 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
40958 [Thread-9] INFO  sound.OooO  - Playing music with id [miscallenous_main_menu.ogg]
61123 [Thread-3] INFO  com.juj.hullmods.RaveMod  - cara1
61125 [Thread-3] INFO  com.juj.hullmods.RaveMod  - cara2
62127 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_main_menu.ogg]
62478 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [miscallenous_main_menu.ogg]
62479 [Thread-9] INFO  sound.OooO  - Playing music with id [miscallenous_main_menu.ogg]
63906 [Thread-3] INFO  exerelin.combat.RestoreCommanderPlugin  - Fleet data is null, skipping
(...)
63910 [Thread-3] INFO  exerelin.combat.RestoreCommanderPlugin  - Fleet data is null, skipping
65207 [Thread-7] INFO  sound.public  - Cleaning up music with id [miscallenous_main_menu.ogg]
65481 [Thread-9] INFO  sound.public  - Creating streaming player for music with id [battle_ambience_01.ogg]
65482 [Thread-9] INFO  sound.OooO  - Playing music with id [battle_ambience_01.ogg]
85370 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
85770 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
86169 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
86554 [Thread-3] INFO  com.juj.hullmods.RaveMod  - corrburn loop
(...)
[close]

i thought it was the sound player wanting to get some air at first as the combat starts, so i gave it a 5s delay before starting, but it did precisely nothing extra, it's like the thread waits for the hullmod to play a sound to somehow wipe it off the face of the earth until it decides only the loop is allowed
(it does the same if i swap that other sound with the music)
Logged

ctuncks

  • Commander
  • ***
  • Posts: 127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9772 on: April 13, 2023, 06:17:52 AM »

Been mucking about with a timer script in java, but can't seem to get it to work when applying it to a hullmod. Has anyone had any luck in setting up a simple timer to pull a float from?
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9773 on: April 13, 2023, 06:46:39 AM »

is there a reliable way to determine what fighters have been spawned through FighterLaunchBayAPI.setExtraDeployments() & which ones were just spawned normally?
I've tried checking the index of the fighters in the wing but that just updates automatically (and also currently launching / returning fighters don't get included in the list), so I'm kinda stumped

Been mucking about with a timer script in java, but can't seem to get it to work when applying it to a hullmod. Has anyone had any luck in setting up a simple timer to pull a float from?

I'd use the vanilla intervalUtil class, with the min & max time set to the same value.
though you'll also encounter some wierd behaviour here since there's only once instance of every hullmod running at a time, the timer will advance faster the more ships have it

Vanilla implementations solve this by putting the interval into the ship's customData, though I generally prefer to use an advanceableListener attached to the ship (in applyAfterShipCreation) to entirely replace the hullmod's advance() method.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9774 on: April 13, 2023, 12:20:33 PM »

is it possible to move individual barrel of a weapon via script?
like when it fires in alternating mode and barrels recoil one by one
but without firing, just move it directly via everyframe script?

I don't think so, sorry! It's a single sprite and the game slices it up into pieces and moves them independently and none of that is exposed.

is there a reliable way to determine what fighters have been spawned through FighterLaunchBayAPI.setExtraDeployments() & which ones were just spawned normally?

If you check fighter.getFighterTimeBeforeRefit() and it's not some astronomically high value chances are it's an extra deployment. Unless the system that spawned it gives those deployments an astronomically high uptime.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9775 on: April 13, 2023, 02:11:35 PM »

If you check fighter.getFighterTimeBeforeRefit() and it's not some astronomically high value chances are it's an extra deployment. Unless the system that spawned it gives those deployments an astronomically high uptime.

ty, that does work!
though that still doesn't count fighters that are in the launch / landing animation, guessing that's because they technically aren't part of the wing yet or somethng?
Specifically concerned with the launch / landing because I want to have a visual effect immediately apply to the additional fighters when they're launched (and an extra thing when they get recalled)
(also also, would there be a way to have them all immediately launch, instead of the slight delay that setFastReplacements still incurs?)

Lukas04

  • Captain
  • ****
  • Posts: 371
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9776 on: April 15, 2023, 08:42:41 AM »

How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.
Logged
My Mods

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24149
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9777 on: April 15, 2023, 09:23:53 AM »

though that still doesn't count fighters that are in the launch / landing animation, guessing that's because they technically aren't part of the wing yet or somethng?
Specifically concerned with the launch / landing because I want to have a visual effect immediately apply to the additional fighters when they're launched (and an extra thing when they get recalled)
(also also, would there be a way to have them all immediately launch, instead of the slight delay that setFastReplacements still incurs?)

The launched ones should be part of the wing; returning fighters stop being part of the wing when they start to return, i.e. well before the landing animation.

I don't think there's any way to have them all launch right away.

How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.

There's com.fs.starfarer.ui.newui.OptionPanel.Option

What're you trying to do, exactly? Perhaps I can extend the API to make it possible in a more straightforward way.
Logged

Lukas04

  • Captain
  • ****
  • Posts: 371
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9778 on: April 15, 2023, 02:37:32 PM »



How would you cast the return value from "getSavedOptionList" in OptionsPanelAPI in to a non obfuscated equivelance?
I only found the "Option" (from com.fs.starfarer.api.campaign.rules) class but that doesnt seem to be connected to the returned value.

There's com.fs.starfarer.ui.newui.OptionPanel.Option

What're you trying to do, exactly? Perhaps I can extend the API to make it possible in a more straightforward way.

We were looking in to if it would be possible to add "pages" to the dialog options in market screens, as different mods tend to add so many that it runs out of space, so the idea was to get the market dialog through the campaign ui, copy all options, and paste them across different pages if there are enough.

Il look in to what you mentioned.
« Last Edit: April 15, 2023, 04:04:06 PM by Lukas04 »
Logged
My Mods

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 840
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9779 on: April 15, 2023, 02:41:55 PM »

We were looking in to if it would be possible to add "pages" to the dialog options in market screens, as different mods tend to add so many that it runs out of space, so the idea was to get the market dialog through the campaign ui, copy all options, and paste them across different pages if there are enough.
(Small context note - the fact that the options are "overflowing" on the base market menu is one of the most common complaints I've seen in recent months, Lukas has been discussing how to fix it, and adding "pages" that can be toggled with a "Next Page" dialogue option was the most realistic approach we landed on.)
Logged
Pages: 1 ... 650 651 [652] 653 654 ... 711