Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 601 602 [603] 604 605 ... 710

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

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9030 on: August 19, 2022, 11:05:59 AM »


for reference, the panel currently. tooltips are just skill names, no description or anything. manually placed the elite icons over the skills that are elite, too.
Logged

Gabs

  • Ensign
  • *
  • Posts: 10
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9031 on: August 19, 2022, 03:01:59 PM »

Hello, I've been trying to dynamically render cargo sprites based on different settings, right now i've been trying to change the sprites based on the stack size, but the stack.getSize() does not update properly when splitting the item, or moving it around in the cargo screen.
Any ideas on how to properly get this value, even when changing/moving the stack?

[attachment deleted by admin]
Logged

KayelGee

  • Ensign
  • *
  • Posts: 1
    • View Profile
Scaling weapons sprites is behaving strange
« Reply #9032 on: August 21, 2022, 02:47:43 PM »

Hello, I got a little annoyed that ships look blurry when zoomed in so I wrote a batch script that upscaled all images 2x with ffmpeg nearest neighbor filter.
That works great for ships because they are automatically scaled down to a fixed size ingame.

Weapons don't work out of the box so I tried writing a mod that scales them down.
I've used the following code to scale the weapons down:
Code
public class UpscaleCombatPlugin extends BaseEveryFrameCombatPlugin {
    private CombatEngineAPI engine;
    private List<WeaponAPI> adjustedWeapons;

    @Override
    public void init(CombatEngineAPI engine){
        this.engine = engine;
        for(ShipAPI ship: engine.getShips()){
            System.out.println(ship.getName());
        }
        adjustedWeapons = new ArrayList<WeaponAPI>();
    }

    @Override
    public void advance(float amount, List<InputEventAPI> events) {
        if (engine == null || engine.getCombatUI() == null) return;

        if (engine.getCombatUI().isShowingCommandUI()) return;

        for(ShipAPI ship: engine.getShips()){
            adjustShip(ship);
        }
    }

    private void adjustShip(ShipAPI ship){
        List<WeaponAPI> weapons = ship.getAllWeapons();
        for (WeaponAPI weapon: weapons) {
            if (adjustedWeapons.contains(weapon)) continue;

            adjustSprite(weapon.getSprite(), 2.0f);
            adjustSprite(weapon.getUnderSpriteAPI(), 2.0f);
            adjustSprite(weapon.getBarrelSpriteAPI(), 2.0f);
            adjustSprite(weapon.getGlowSpriteAPI(), 2.0f);
            adjustedWeapons.add(weapon);
        }
    }

    private void adjustSprite(SpriteAPI sprite, float factor) {
        if (sprite == null) return;

        float width = sprite.getWidth() / factor;
        float height = sprite.getHeight() / factor;
        sprite.setSize(width, height);
        sprite.setCenter(sprite.getCenterX()/ factor, sprite.getCenterY() / factor);
    }

}
It works kinda.
The weapon bases work without issue.
The barrels work for hardpoints as far as I can tell.

Turret barrels don't seem to use the CenterY value after the sprite size was changed(no matter to what value I change CenterY for a turret barrel it won't move vertically).
Is there a way to work around that that I'm not aware?

Also animated weapons(chaingun for example) don't work(I could run the resize every frame by saving the sprites to a list or something along those lines).
Is there a way to get all sprites of an animation beforehand?

Also this doesn't work in the refit screen and I can't seem to find a way to do it via the api.
Is there a way to access a ship in the refit screen somehow?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9033 on: August 21, 2022, 03:16:52 PM »

Any ideas on how to properly get this value, even when changing/moving the stack?

Hmm, I don't think you actually can.

Hello, I got a little annoyed that ships look blurry when zoomed in so I wrote a batch script that upscaled all images 2x with ffmpeg nearest neighbor filter.

(Just so you're aware, that'd be increasing the game's VRAM use, potentially fairly significantly. Though if it it's just vanilla ships, it probably doesn't matter very much.)

Turret barrels don't seem to use the CenterY value after the sprite size was changed(no matter to what value I change CenterY for a turret barrel it won't move vertically).
Is there a way to work around that that I'm not aware?

If it works for the base sprite but doesn't for e.g. barrels, then the answer is probably "no" - I suspect it's probably getting set again after you've changed it. (Checking quickly: yep, looks like it.) Your best bet would be to change the .wpn files.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9034 on: August 21, 2022, 03:39:29 PM »

What are the ForceCarrier— methods in ShipAPI? Do they control carriers or fighters? Which am I supposed to use them on? Can I pass a null target?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9035 on: August 21, 2022, 03:44:25 PM »

The setForceCarrierTargetTime() and setForceCarrierTarget() methods force the carrier to target a specific ship with its fighters and allow you to specify a duration for this.

The setForceCarrierPullBackTime() allows you to force the carrier to pull back its fighters for X seconds.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9036 on: August 21, 2022, 04:13:22 PM »

It seems like setForceCarrierTarget(null) has no effect even if a targetTime is set. Could it instead cause the "free roam" behavior as when a player carrier has its fighters set to engage with nothing targeted?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9037 on: August 21, 2022, 05:23:17 PM »

Oh, sorry, I didn't notice that part of the question. "null" means "do not set a forced target", so it will use its normal targeting behavior.

You might be able to achieve free-roam behavior by calling ship.setPullBackFighters(false) and unsetting the AIFlags.CARRIER_FIGHTER_TARGET flag every frame. That flag's custom data is the actual target.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3021
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9038 on: August 21, 2022, 06:12:23 PM »

Looks like not. Would be nice to have a way to force free-roam.

Spoiler
Would be better to have fighters lock in their target in vanilla when going from regroup to engage instead of being constantly slaved to the carrier's target. Then I wouldn't have to try modding it in. ;)
[close]
Logged

Liral

  • Admiral
  • *****
  • Posts: 718
  • Realistic Combat Mod Author
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9039 on: August 24, 2022, 04:40:00 PM »

I wish we had a separate field (and corresponding board column) to put the Starsector version number compatible with each mod rather than typing it into the title of its forum post and that the forum had a dark mode.

Other than that, thanks for all your help so far, Alex!  I couldn't have done all this without you.  You're such a kind game-maker.

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9040 on: August 24, 2022, 04:56:14 PM »

is there a way to easily copy all (or some) of the mutableStats of one ship over to another?

I've got 2 things I wanna use for this - one is to have a shield module copy the stats of it's parent & the other is to have a "rangefinder" beam on an invisible drone for a weapon's visual effect, I *could* currently do it by manually checking everyMutableStat but that would probably melt my brain so I'm hoping for a better way  :P

also, might've asked this before but is there a way to set a carrier as the parent ship of a wing?
« Last Edit: August 24, 2022, 05:07:20 PM by Ruddygreat »
Logged

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9041 on: August 25, 2022, 05:15:17 AM »

Is $global.gaRH_completed or $global.gaRH_failed getting unset somewhere when Hamatsu mission is completed/failed?

Quote
   public void connectWithGlobalFlag(Object from, Object to, String flag) {
      connections.add(new StageConnection(from, to, new GlobalBooleanChecker(flag)));
      // so it gets auto-unset if it's ever set
      changes.add(new VariableSet(getGlobalMemory(), flag, true));
   }
I guess this is what it does...  ::)

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24118
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9042 on: August 25, 2022, 10:26:48 AM »

I wish we had a separate field (and corresponding board column) to put the Starsector version number compatible with each mod rather than typing it into the title of its forum post and that the forum had a dark mode.

Other than that, thanks for all your help so far, Alex!  I couldn't have done all this without you.  You're such a kind game-maker.

<3

(Yeah, modifying the forum in this type of way is a no-go, sorry!)


is there a way to easily copy all (or some) of the mutableStats of one ship over to another?

I've got 2 things I wanna use for this - one is to have a shield module copy the stats of it's parent & the other is to have a "rangefinder" beam on an invisible drone for a weapon's visual effect, I *could* currently do it by manually checking everyMutableStat but that would probably melt my brain so I'm hoping for a better way  :P

I'm not sure, is there a MutableStat.createCopy() in the currently-out version? Or applyMods(MutableStat other)?

If the methods are there, something like:
Code
public void applyMods(MutableStat other) {
getFlatMods().putAll(other.getFlatMods());
getPercentMods().putAll(other.getPercentMods());
getMultMods().putAll(other.getMultMods());
needsRecompute = true;
}


also, might've asked this before but is there a way to set a carrier as the parent ship of a wing?

I don't think so.


Is $global.gaRH_completed or $global.gaRH_failed getting unset somewhere when Hamatsu mission is completed/failed?

Quote
   public void connectWithGlobalFlag(Object from, Object to, String flag) {
      connections.add(new StageConnection(from, to, new GlobalBooleanChecker(flag)));
      // so it gets auto-unset if it's ever set
      changes.add(new VariableSet(getGlobalMemory(), flag, true));
   }
I guess this is what it does...  ::)

Yeah, these types of flags don't stick around after a mission is over. A mission has to explicitly add code to set them, for example GAFindingCoureuse does this:

Code
beginStageTrigger(Stage.COMPLETED);
triggerSetGlobalMemoryValue("$gaFC_missionCompleted", true);
endTrigger();

A variable could also be set in a relevant rule. I don't think anything is set for gaRH, though.
Logged

Ruddygreat

  • Admiral
  • *****
  • Posts: 524
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9043 on: August 25, 2022, 11:59:20 AM »

I'm not sure, is there a MutableStat.createCopy() in the currently-out version? Or applyMods(MutableStat other)?

yes there are, thanks for pointing them out!

though now I've run into a second problem - is there a way to prevent a weapon from reaching 100% charge level & if not, can we get one? (say, something like WeaponAPI.setChargeLevel() to go with getChargeLevel()?)
There seem to be a few ways to technically do it (through setAmmo & setRemainingCooldownTo), but they're kinda janky & won't really work for the thing that I want to do.

Timid

  • Admiral
  • *****
  • Posts: 640
  • Personal Text
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #9044 on: August 25, 2022, 12:30:12 PM »

Yeah, these types of flags don't stick around after a mission is over. A mission has to explicitly add code to set them, for example GAFindingCoureuse does this:

Code
beginStageTrigger(Stage.COMPLETED);
triggerSetGlobalMemoryValue("$gaFC_missionCompleted", true);
endTrigger();

A variable could also be set in a relevant rule. I don't think anything is set for gaRH, though.
Hmmm, guess I'll have to override that rule id, thought returning/keeping the Hamatsu was somewhat significant to be remembered since there's a lingering $global.foundHamatsu permanently forever unexpired.
Pages: 1 ... 601 602 [603] 604 605 ... 710