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: Codex Overhaul (05/11/24)

Pages: 1 ... 579 580 [581] 582 583 ... 712

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

Ruddygreat

  • Admiral
  • *****
  • Posts: 528
  • Seals :^)
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8700 on: April 28, 2022, 07:34:50 AM »

Is there a way to get where the AI (or player) wants a ship's omni shields to be, even if the ship has no shields at all (or an alternate system that replaces shields)?

I've seen getShieldTarget() in ShipAPI & I'm hoping that that's what I want, though I've not yet had the time to check if it actually is.

EDIT : I've managed to check (with the below code in a hullmod) and it seems to return null no matter what, any ideas?

Code
    @Override
    public void advanceInCombat(ShipAPI ship, float amount) {
        CombatEngineAPI engine = Global.getCombatEngine();
        float totalArc = ship.getShield().getActiveArc();
        if (ship.getShield().isOn() && ship.getShieldTarget() != null) {
            engine.addNebulaParticle(ship.getShieldTarget(), ship.getVelocity(), 1f, 1f, 1f,1f, amount, Misc.getPositiveHighlightColor());
        }
        if (ship.getOriginalOwner() != -1) {
            log.debug("the ship's shield target is " + ship.getShieldTarget());
            /*
            tried getShieldTarget.toString() as well and it always crashed
            */
        }
    }
« Last Edit: April 28, 2022, 03:49:02 PM by Ruddygreat »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8701 on: April 29, 2022, 01:14:06 PM »

Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?

I don't believe so, at least nothing comes to mind offhand.

Is there a way to alter how much damage the AI thinks a weapon would do?
I know the AI can't see scripted damage, but is there a way to say "this does X more damage than it's listed damage"?

Yes, but it's a bit complicated- Use an onFireEffect to increase the projectile's damage so that it properly represents the scripted damage it deals, then reduce it back down to the original value when it actually deals damage using a listener.

(Ah!)


so, I tried that exact same thing with a purely vanilla assignment AI, and I suspect it might actually be a vanilla problem.

I made a test mod for you to replicate this.
Only thing required is that you are in a different system than Askonia, and load into the game with the mod enabled.

it'll spawn a fleet that goes to cruor, orbits it for a day, and should then return - but actually gets stuck in-system for no discernible reason.

Hoping to get this resolved, if not now, at least in the next version :)

Thank you for the test mod! Basically the fleet doesn't know what location the player fleet is in - it hasn't seen it jump, so it just has no idea where to go, unless the player fleet is in the same system (in which case the GO_TO_LOCATION assignment knows where to go, but e.g. a fleet looking for the player normally still wouldn't).

This is e.g. so that a pursuing fleet doesn't magically know you've entered hyperspace if you jump out from outside their sensor range. I've changed it so that player-faction fleets can follow your fleets movements regardless. In the meantime, your best bet would be to create a SectorEntityToken, use a script to keep it where the player fleet is, and target the return assignment to that token.

Is there a way to get where the AI (or player) wants a ship's omni shields to be, even if the ship has no shields at all (or an alternate system that replaces shields)?

I've seen getShieldTarget() in ShipAPI & I'm hoping that that's what I want, though I've not yet had the time to check if it actually is.

EDIT : I've managed to check (with the below code in a hullmod) and it seems to return null no matter what, any ideas?

getShieldTarget() is actually going the other way - it lets you override where the shield will point. I don't *think* there's anything that would do what you're looking for.
Logged

IGdood

  • Commander
  • ***
  • Posts: 200
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8702 on: April 30, 2022, 12:58:54 PM »

Since a lot of popular Chinese mods (Polaris, Approlight, ICE etc) got updated recently is there a way to have the game be able to display both English and Chinese?

Thanks
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8703 on: April 30, 2022, 02:50:52 PM »

Since a lot of popular Chinese mods (Polaris, Approlight, ICE etc) got updated recently is there a way to have the game be able to display both English and Chinese?

Thanks

There really, really isn't - afaik the Chinese translation depends on replacing core font files.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8704 on: April 30, 2022, 05:04:14 PM »

is there a way to get the list of recoverable ships shown in the post-battle salvage dialog? i'm trying to show info about the recoverable ships to the player before they pick what ships to recover.

i was going to use FleetEncounterContext.getRecoverableShips, but it appears to reroll the recoverable ships list every time it is called. the list of recoverable ships is also private in both FleetInteractionDialogPluginImpl and FleetEncounterContext, which means that i can't simply extend the class and expose them without reimplementing (i.e. copying) the entire method from either class.
« Last Edit: April 30, 2022, 05:06:21 PM by presidentmattdamon »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8705 on: May 01, 2022, 01:01:31 PM »

If you wanted to go that far, you might be able to copy-paste the getRecoverableShips() method and re-implement that whole interaction. Let me make those fields protected in the meantime; no reason for them to be private...
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8706 on: May 01, 2022, 02:13:28 PM »

If you wanted to go that far, you might be able to copy-paste the getRecoverableShips() method and re-implement that whole interaction. Let me make those fields protected in the meantime; no reason for them to be private...

i was specifically trying to avoid this because other mods (namely nexerelin, which many many many many players use) implement their own dialog and context for other reasons. plus, if you update it then i have to go through and update the method all over again.

but thanks for making it protected, means i can ask histidine to put a getter in. i was trying to put a dialog option after combat where it shows recoverable ships. nexerelin has a trigger that fires every time the encounter dialog changes state, which i've duplicated in my mod for if it isn't enabled.
« Last Edit: May 01, 2022, 02:18:59 PM by presidentmattdamon »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8707 on: May 01, 2022, 02:31:50 PM »

Aaah, ok - I was wondering how this would get along with Nex.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3030
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8708 on: May 01, 2022, 05:47:31 PM »

You can get lost ships by putting a defeat trigger (Misc.addDefeatTrigger()) on the fleet you are interested in and running a rule command like below.

Code: java
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {

    SectorEntityToken entity = dialog.getInteractionTarget();

    if (entity instanceof CampaignFleetAPI) {
        CampaignFleetAPI fleet = (CampaignFleetAPI) entity;

        MemoryAPI mem = memoryMap.get("local");
        BattleAPI battle = (BattleAPI) mem.get("$battle");

        if (battle != null) {
            // Should be able to get the FleetEncounterContext here somehow, but I do not know offhand
            // Otherwise you can reimplement getRecoverableShips()
            FleetEncounterContext context = todo();
            List<FleetMemberAPI> recoverable = context.getRecoverableShips(BattleAPI battle, CampaignFleetAPI winningFleet, CampaignFleetAPI otherFleet)

        }
    }

    return true;
}
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8709 on: May 01, 2022, 08:43:48 PM »

You can get lost ships by putting a defeat trigger (Misc.addDefeatTrigger()) on the fleet you are interested in and running a rule command like below.

Code: java
@Override
public boolean execute(String ruleId, InteractionDialogAPI dialog, List<Misc.Token> params, Map<String, MemoryAPI> memoryMap) {

    SectorEntityToken entity = dialog.getInteractionTarget();

    if (entity instanceof CampaignFleetAPI) {
        CampaignFleetAPI fleet = (CampaignFleetAPI) entity;

        MemoryAPI mem = memoryMap.get("local");
        BattleAPI battle = (BattleAPI) mem.get("$battle");

        if (battle != null) {
            // Should be able to get the FleetEncounterContext here somehow, but I do not know offhand
            // Otherwise you can reimplement getRecoverableShips()
            FleetEncounterContext context = todo();
            List<FleetMemberAPI> recoverable = context.getRecoverableShips(BattleAPI battle, CampaignFleetAPI winningFleet, CampaignFleetAPI otherFleet)

        }
    }

    return true;
}

running getRecoverableShips will re-roll the ships that can be recovered
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3030
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8710 on: May 01, 2022, 08:57:41 PM »

Then the method is bugged, because it is clearly supposed to be determinate.
Logged

presidentmattdamon

  • Commander
  • ***
  • Posts: 249
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8711 on: May 01, 2022, 09:01:14 PM »

Then the method is bugged, because it is clearly supposed to be determinate.

my reasoning is that it has the Misc.getRandom method which rolls using a seed 11 times
Logged

NuclearStudent

  • Ensign
  • *
  • Posts: 20
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8712 on: May 01, 2022, 11:31:53 PM »

I am trying to delete planets. That much is easy. However, I am having trouble finding the nascent gravity well matching the planet so that can be deleted. Alex remarked on twitter that running .getLocationInHyperspace() just returns the location of the system, not the nascent well.

https://pastebin.com/3n1Dp4W9 code I've tried. the printloc returns the hyperspace location of the system itself

Right now I unable to A. find the hyperspace location of the nascent well and B. unable to find it that well corresponds to a particular planet. Any advice would be greatly appreciated.

In brief, you want to check if the entity is an instanceof NascentGravityWellAPI, and then use the .getTarget() method in that interface to check if that well points to the planet you're removing.

Very sorry to bother again, but I'm having a somewhat odd casting error while trying to call the getTarget method on the entity. I can't call the getTarget method on the generic SectorEntityToken, and when I try the cast, I get...this. Which is odd, because I don't know how on earth I'm getting a Location Token.



        List<SectorEntityToken>allEntities=Global.getSector().getHyperspace().getAllEntities();
        for (SectorEntityToken entity:allEntities)
        {
            if (entity instanceof NascentGravityWellAPI)
                log.info("Looking for nascent gravity wells to purge.");
                //note: isInCurrentLocation doesn't work because the well is in hyper, not realspace
                NascentGravityWellAPI nascwell= (NascentGravityWellAPI) entity; //note: yeah the cast is not legit
                if(nascwell.getTarget() == planet);
                {
                    //note: it's nothing in this code block that's causing the cast problem, I tried commenting it out
                    log.info("Purging nascent gravity well.");
                    LocationAPI location = entity.getContainingLocation();
                    log.info("nascent grav well's location is" + location.getLocation());
                    location.removeEntity(entity);
                    break;
                }
        }
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24217
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8713 on: May 02, 2022, 10:05:51 AM »

Then the method is bugged, because it is clearly supposed to be determinate.

my reasoning is that it has the Misc.getRandom method which rolls using a seed 11 times

It should probably be named "generateRecoverableShips" instead of "get"; it's not bugged (at least not in that way) but it's not supposed to be called multiple times as it makes changes to the underlying data.

Very sorry to bother again, but I'm having a somewhat odd casting error while trying to call the getTarget method on the entity. I can't call the getTarget method on the generic SectorEntityToken, and when I try the cast, I get...this. Which is odd, because I don't know how on earth I'm getting a Location Token.



   if (entity instanceof NascentGravityWellAPI)

                if(nascwell.getTarget() == planet);
                 

The first if doesn't have a block after it in curly braces, so only the one line after it will be inside the if. The second if has a semicolon after it meaning the block after it is just... a block that will always run. The if itself only gates the empty ; after it.
Logged

Droll

  • Commander
  • ***
  • Posts: 103
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8714 on: May 02, 2022, 02:40:04 PM »

A quick search yielded me no immediate result so I wanted to ask a question regarding autofit and modded weapons. Specifically, what is required to be in the mod in order for autofit to actually consider the new weapons.

I ask in the context of this mod that I'm trying to patch up for myself. The ships that it adds work fine but when I try to use the autofit loadout feature the weapons added by that specific mod are seemingly ignored (other modded weapons are fine but I couldn't single out what was different). Additionally, my factions own patrols, though they use the hulls just fine, are not using the relevant weapons and fighter LPCs even though they are set to priority on the doctrine screen.

What files/structures does starsector expect to be able to autofit with mod weapons?
« Last Edit: May 03, 2022, 11:27:10 AM by Droll »
Logged
Pages: 1 ... 579 580 [581] 582 583 ... 712