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 ... 378 379 [380] 381 382 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5685 on: November 19, 2019, 10:45:13 AM »

Aha. That's... interesting, to say the least. Especially considering there's no "isHoldFireOneFrame" member variable in that class.

I don't have a lot of confidence in that actually working, but then I'm not familiar with kotlin. But basically I can't really help out much here if there's a layer of code and compilation here that I don't understand and that isn't officially supported and, for all I know, something could be going wrong in that layer, if that makes sense.

Also, I'm not sure what the problem is; "appears ineffectual" isn't quite enough to go on :)
Logged

Armithaig

  • Lieutenant
  • **
  • Posts: 54
    • View Profile
    • Amaranth
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5686 on: November 19, 2019, 11:14:48 AM »

Eh, sorry I talk weird. Since my IDE's set up for kotlin was doing what was convenient for me and not you, for that'll apologise.

Here's a working java example, mini-mod and video demonstration.
Code
package data.shipsystems.scripts;

import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.impl.combat.BaseShipSystemScript;
import com.fs.starfarer.api.plugins.ShipSystemStatsScript;
import com.fs.starfarer.api.combat.ShipAPI;
import com.fs.starfarer.api.combat.ShipCommand;

public class SomeSystemStats extends BaseShipSystemScript {

public void apply(MutableShipStatsAPI stats, String id, State state, float effectLevel) {
ShipAPI ship = (ShipAPI)stats.getEntity();
       
ship.blockCommandForOneFrame(ShipCommand.FIRE);
ship.setHoldFireOneFrame(true);
}

public StatusData getStatusData(int index, State state, float effectLevel) {
if (index == 0) {
return new StatusData("i should be holding fire", false);
}
return null;
}
}

EDIT: Thanks legend!
« Last Edit: November 19, 2019, 12:00:35 PM by Armithaig »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5687 on: November 19, 2019, 11:41:35 AM »

Ah, I see - thank you for the example. Fixed on my end, for now you'll need to use the deprecated USE_SELECTED_GROUP, though might want to block both for good measure.
Logged

shoi

  • Admiral
  • *****
  • Posts: 650
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5688 on: November 19, 2019, 12:38:17 PM »

How robust is modding for characters at the moment?

To elaborate, I mean for individuals on stations and NPC fleet commanders.

Are persistent NPC fleet commanders possible at the moment? As most fleets eventually return to their planet of origin, is that commander deleted from the game as well when that occurs?

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5689 on: November 19, 2019, 05:57:48 PM »

Yes they are replaced. See the bottom of my post for the code snippet of the replace array in case I messed something up there.

I had originally thought it was another one of those operating-system-specific deliminator issues like from .9 but the really weird thing is that it only affects some markets according to the report rather than all markets defined in the file. You'd think it would be universal to the markets if it wasn't being replaced and all of them were being appended.

It works fine for me though so I'm kind of at a loss as to how to proceed with troubleshooting.  :-\

I'll try a few more things to reproduce it a bit later.

Ah, my bad, missed that. ... really not sure, then, sorry!

No worries thanks for looking!  :)

I figured it out, I think! It does indeed seem to be an operating system-specific error with the replace array path deliminator like I encountered in .9.

I took out the replace section for the markets and I was able to reproduce the error so that is what is happening on the technical level- the duplicate market entries cause the economy of those markets to completely collapse because the replacement of the JSON files isn't occurring.

I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5690 on: November 19, 2019, 06:02:01 PM »

I am counseling the user to try a different path deliminator in order to see if that solves it. I will give more info here, if that is desirable, to determine the exact details of what operating system has this behavior and what path deliminator works for it.

Hopefully this will help everyone else encountering this as well.

Yeah, please let me know! I *thought* this was supposed to be fixed for 0.9.1a, hmm.
Logged

scarface

  • Commander
  • ***
  • Posts: 137
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5691 on: November 19, 2019, 06:25:40 PM »

Hi, i made a new ship. several in a row in fact. and none are being attacked by enemy ships. why? i always redid the entire thing and it fixed itself, doesnt work anymore. any ideas?

edit:solved. i always accidentally clicked on vast bulk hullmod
« Last Edit: November 20, 2019, 10:53:26 AM by scarface »
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5692 on: November 19, 2019, 06:38:08 PM »

My best guess is there's something wrong with the collision bounds or collision radius of your ships. Those are the only two things I can think of that tell other ships when they should and shouldn't shoot at your ships.

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
I'm not sure about the specifics you mentioned, but I'm pretty sure you can create, edit, and assign fleet commanders, so you should be able to override any vanilla behavior related to fleet commanders that you need to change. However It might get pretty complicated if you need to change too much.

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5693 on: November 19, 2019, 09:56:03 PM »

Okay, after several attempts at making the fleet inflater work for controlling the Shikome numbers, I switched tactics and approached this from the angle of just stripping out and replacing the excessive Shikomes. With a good deal of help from Vayra and Sundog we've now gotten a sort of working script?

So, first off this strips out the Shikomes. But it's behaving weirdly, and only strips them out after you directly interact with the fleet. It's not really clear why this should be happening; since it's semi-functional we can roll with this, but it is obviously less than ideal. Any insight would be greatly appreciated.
Code: java
package data.campaign.fleets;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.combat.ShipVariantAPI;
import com.fs.starfarer.api.fleet.FleetMemberAPI;
import com.fs.starfarer.api.util.IntervalUtil;
import java.util.List;

public class MS_fleetFighterFinagler implements EveryFrameScript {
    /////////////////////////////// CONFIG ///////////////////////////////
    private static final String FIND_ID = "ms_shikome";
    private static final String REPLACE_ID = "ms_skinwalker";
    private static final int FP_THRESHOLD = 6661312; // allowed one shikome per this many FP (not allowed any if not over threshold)
    private final IntervalUtil timer = new IntervalUtil(2f, 5f); // min, max in seconds for check (you want this to run pretty often, but not every frame)
    /////////////////////////////// CONFIG ///////////////////////////////

    private static final String FIND_WING = FIND_ID + "_wing";
    private static final String REPLACE_WING = REPLACE_ID + "_wing";
   
    @Override
    public boolean isDone() {
        return false;
    }

    @Override
    public boolean runWhilePaused() {
        return false;
    }

    @Override
    public void advance(float amount) {
       
        // advance the timer
        timer.advance(amount);
        // if the timer's not over, just give up and try again later
        if (!timer.intervalElapsed()) {
            return;
        }

        // loop through all the fleets around
        for (CampaignFleetAPI fleet : Global.getSector().getCurrentLocation().getFleets()) {

            // there are a whole host of reasons we might not care about checking a given fleet
            if (fleet == null
                    || !fleet.isInflated()
                    || !fleet.isPlayerFleet()
                    || !fleet.isAlive()
                    || fleet.isEmpty()
                    || fleet.isExpired()
                    || fleet.isDespawning()
                    || fleet.getFleetData() == null
                    || fleet.getFleetData().getMembersInPriorityOrder() == null
                    || fleet.getFleetData().getMembersInPriorityOrder().isEmpty()
                    || fleet.getFaction() == null
                    || fleet.getFaction().getKnownFighters() == null
                    || fleet.getFaction().getKnownFighters().isEmpty()
                    || !fleet.getFaction().getKnownFighters().contains(FIND_WING)) {
                continue;
            }

            // setup some variables
            int fp = fleet.getFleetPoints();
            int allowed = fp / FP_THRESHOLD;
            int count = 0; // per fleet

            // loop through all the members of this fleet
            List<FleetMemberAPI> members = fleet.getFleetData().getMembersInPriorityOrder();
            for (FleetMemberAPI member : members) {
               
                // grab the ship variant
                ShipVariantAPI variant = member.getVariant();
                if (variant == null) {
                    continue; // if the ship doesn't have a variant, idfk just skip it
                }
               
                // loop through all its flight decks
                for (int i = 0; i <= member.getNumFlightDecks(); i++) {
                   
                    // count shikome wings
                    if (FIND_WING.equals(variant.getWingId(i))) {
                        count++;
                       
                        // if we have too many shikome wings, replace this one with a skinwalker wing
                        if (count > allowed) {
                            member.getVariant().setWingId(i, REPLACE_WING);
                        }
                       
                    }
                   
                }
            }
        }
    }
}

Thanks again for any help. Cheers!
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1723
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5694 on: November 19, 2019, 11:22:19 PM »

But it's behaving weirdly, and only strips them out after you directly interact with the fleet.
Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.
« Last Edit: November 20, 2019, 12:05:58 AM by Sundog »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5695 on: November 20, 2019, 01:28:52 AM »

How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
Logged

RustyCabbage

  • Captain
  • ****
  • Posts: 347
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5696 on: November 20, 2019, 02:55:49 AM »

How to check if one month has passsed (a monthly check for a script to fire)?

I know it should extend EveryFrameScript but how to track (roughly) a month. By counting frames? Can I use the same method as the monthly stipend (if I can find it, don't know where it is in the code)?
For example: after implementing EveryFrameScript:
Code
static float months = 0;

@Override
public void advance(float amount) {
    months += Global.getSector().getClock().convertToMonths(amount);
    if (months > 1) {
        /*
        YOUR CODE HERE
        */
        months = 0;
    }
}

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5697 on: November 20, 2019, 03:26:18 AM »

Are persistent NPC fleet commanders possible at the moment? As most fleets eventually return to their planet of origin, is that commander deleted from the game as well when that occurs?

I was wondering if it were possible to create real "rival" commanders with level cap akin to the player but not sure if it's even possible
A mod can store an officer in its own data. When creating a new fleet for that officer, you can just replace the the automatically generated fleet commander/flagship officer with your saved officer.
Logged

Ed

  • Captain
  • ****
  • Posts: 442
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5698 on: November 20, 2019, 05:41:36 AM »

Is it possible to change the default empty weapon slot mount sprite of a ship through hullmod? would need to be something that works on all ships, not just mine, so no deco weapons workarounds.
Logged
Check out my ships

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5699 on: November 20, 2019, 05:55:01 AM »

Behaving weirdly how? I suspect that fleets normally won't inflate until you interact with them directly, which means they won't be stripped of Shikomes until the earliest timer elapse after inflation. That could lead to, for example, hovering over a fleet and seeing its shikomes transform to skinwalkers in the fleet tooltip after a brief delay. I was thinking about this problem earlier, and I think I might've thought of a solution (assuming my guess about what's causing the problem in the first place is correct). Instead of periodically iterating over the nearby fleets in the player's current location, it might be possible to run your code at the exact frame (or maybe the next frame) when the fleet inflates. I'm pretty sure CampaignPlugin.pickFleetInflater() is called each time a fleet is inflated, so if you override that you can add the inflated fleet to a collection to be modified shortly thereafter. In fact, I think I might be able to solve a similar inflation-related display bug in ruthless sector this way, so I'll let you know if it works for me.

Edit: Well, that doesn't seem to work, unfortunately. It seems like inflaters are picked for fleets when they respawn rather than when they inflate.

Ah well; I appreciate you taking the time to help. Guess it's gonna be something to think on.
Logged
Pages: 1 ... 378 379 [380] 381 382 ... 706