Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 217 218 [219] 220 221 ... 710

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

Galwail

  • Ensign
  • *
  • Posts: 31
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3270 on: May 07, 2017, 06:50:23 PM »

Hi, quick modding question:

I'm trying to write a small mod, that changes the offices level up skill picks. I have written my own OfficerLevelupPlugin implementation and it works fine. The problem is, that I want my mod to be compatible with the Starsector+ mod, which uses its own OfficerLevelupPlugin implementation. Is there any way to handle this conflict? Is there any way to force the game to load a specific implementation of OfficerLevelupPlugin regardless of the content of the settings.json file?
Logged

Pushover

  • Captain
  • ****
  • Posts: 292
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3271 on: May 07, 2017, 11:24:52 PM »

Found the culprit. The sim_opponents didn't copy properly.

EDIT: Spoke too son. Nope.

Could it be the tutorial? There's an instance in RogueMinerMiscFleetManager.java when it creates the miner guard fleet. I wouldn't think that it would load, though.
Logged

Mongreal

  • Ensign
  • *
  • Posts: 46
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3272 on: May 08, 2017, 12:05:42 AM »

Thanks Alex, I'll keep trying different things until that work.
Actually, I'm wondering if the weapon that will use such a script should be burst firing or just a regular one.
Seems like the burst mecanism may be usefull to determine if we're firing in the same spooling up sequence, but that may also be the thing that prevent the script from working.

I've tried variation of that :
Spoiler
Code
cooldown = weapon.getCooldown();
        if (weapon.isFiring() && cooldown >= minCooldown) {
            firerate = 1 / cooldown;
            nextFirerate = firerate + increment;
            nextCooldown = 1 / nextFirerate;
            weapon.setRemainingCooldownTo(nextCooldown);
        }
[close]
Dunno if isFiring() is better than getChargeLevel() >= 1f, but I don't see any change ingame.


Edit : Found something that seems to work better, by using intervals :
Spoiler
Code
charge = weapon.getChargeLevel();
        if (charge >= 0.9f) {
            if (!hasFired){
                fireInterval.advance(amount);
                if (fireInterval.intervalElapsed()) {
                    fireInterval.setInterval(0f, 1f);
                    hasFired = true;}
            }
            if (hasFired = true) {
                spoolUpInterval.advance(amount);
                if (!spoolUpInterval.intervalElapsed()) {
                        cooldown = weapon.getCooldown();
                        if (cooldown >= minCooldown) {
                            firerate = 1 / cooldown;
                            nextFirerate = firerate + (increment * spoolUpInterval.getElapsed());
                            nextCooldown = 1 / nextFirerate;
                            weapon.setRemainingCooldownTo(nextCooldown);
                        }
                    spoolUpInterval.advance(amount);
                } else if (spoolUpInterval.intervalElapsed() && charge >= 0.5f) {
                    cooldown = minCooldown;
                }
            }
        }
[close]
With that bit of code, the weapon is actually spooling up, but there is some unpredictible "cut" in the firing sequence. Also, the spool up ramp seems pretty long, looks like the firerate increase only once every three seconds or more. Any ideas on how to reduce that ramp, and why does the gun can randomly stop firing (with resuming it's spool up sequence or starting another one from 0)


Small update (but I'm still stuck !) :
I was tried to clean up my code, and end up with something that should work... If I manage to calculate if the weapon fired when the cooldown of the last shoot ended (so, the player/AI keep firing with that weapon), or if the delay was at least frame longer (meaning that during the same amount of time (here, cooldown of the last shoot elasped + 1 frame), the fire button wasn't pressed) and I can't find how to get that.
The cleaned code for the firerate (should work better with getCooldownRemaining, doesn't require a interval to ramp up or down, juste a +/- in front of the value that have to increment/decrement the firerate. Also check if we were already at the max/min firerate/cooldown, and spooling up/down ramps are more easy to work with) :
Spoiler
Code
cooldown = weapon.getCooldownRemaining();
            nextFirerate = 0f;
            firerate = 1 / cooldown;
            if (firedLastInterval) {
                if (cooldown > minCooldown) {
                    nextFirerate = firerate + modifier;     //* spoolingInterval.getElapsed())
                } else {
                    weapon.setRemainingCooldownTo(minCooldown);
                }
            } else if (!firedLastInterval) {
                if (cooldown < maxCooldown) {
                    nextFirerate = firerate - modifier;     //* spoolingInterval.getElapsed())
                } else {
                    weapon.setRemainingCooldownTo(maxCooldown);
                }
            }
            if (nextFirerate != 0f) {
                nextCooldown = 1 / nextFirerate;
                weapon.setRemainingCooldownTo(nextCooldown);
            }
[close]
« Last Edit: May 08, 2017, 06:14:29 AM by Mongreal »
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3273 on: May 08, 2017, 02:07:55 AM »

If you can upload the mod somewhere and send me a link, I can take a quick look.

Well, I just f**** up massively, since I compressed the entire mod and put it on a USB to continue work on the mod on my laptop (I travel around) and now I can't find it.
Meaning, that until I get back home (not before Firday) I can't do s***.


But I do have SOME files on the USB, so I might at least do something.
Come to think of it, given the changes to sensors, will this work?


Code
package data.hullmods;

import java.util.HashMap;
import java.util.Map;

import com.fs.starfarer.api.combat.BaseHullMod;
import com.fs.starfarer.api.combat.MutableShipStatsAPI;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.ShipAPI;

public class AmplifiedSensors2 extends BaseHullMod {

private static Map mag = new HashMap();
static {
mag.put(HullSize.FIGHTER, 50f);
mag.put(HullSize.FRIGATE, 75f);
mag.put(HullSize.DESTROYER, 100f);
mag.put(HullSize.CRUISER, 125f);
mag.put(HullSize.CAPITAL_SHIP, 150f);
}

public String getDescriptionParam(int index, HullSize hullSize) {
if (index == 0) return "" + ((Float) mag.get(HullSize.FRIGATE)).intValue();
if (index == 1) return "" + ((Float) mag.get(HullSize.DESTROYER)).intValue();
if (index == 2) return "" + ((Float) mag.get(HullSize.CRUISER)).intValue();
if (index == 3) return "" + ((Float) mag.get(HullSize.CAPITAL_SHIP)).intValue();
return null;
}


public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {

stats.getSightRadiusMod().modifyPercent(id, (Float) mag.get(hullSize));
stats.getAutofireAimAccuracy().modifyPercent(id, 25f);
stats.getSensorStrength().modifyPercent(id, 1000f);
}


}

Logged

SainnQ

  • Commander
  • ***
  • Posts: 219
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3274 on: May 08, 2017, 04:25:36 AM »

Where would I look to tweak the size of a given factions mods?

I'm not a fan of there being something like 6-7 Independent stations, but only one proper military station, and a subpar one at that.
Logged

Cosmitz

  • Admiral
  • *****
  • Posts: 758
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3275 on: May 08, 2017, 01:42:58 PM »

LE: Nevermind.  Game doesn't crash at load when parsing the ship_data.csv if it cannot find the ship system attached to it. It crashes within the game when it has to.
« Last Edit: May 08, 2017, 02:17:39 PM by Cosmitz »
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3276 on: May 08, 2017, 01:50:32 PM »

Is there a way to ensure a tidally locked planet has the right facing to the star? I have a texture with clear day and night sides, but the planet always seems to be generated with a random angle.
Logged
 

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3277 on: May 08, 2017, 03:24:39 PM »

Where would I look to tweak the size of a given factions mods?

I'm not a fan of there being something like 6-7 Independent stations, but only one proper military station, and a subpar one at that.

data/econ/economy.json and related files.

Is there a way to ensure a tidally locked planet has the right facing to the star? I have a texture with clear day and night sides, but the planet always seems to be generated with a random angle.

I'd say your best bet is to run a script post-procgen and do the tidal-locking there (i.e. set rotation to 0, set the angle to whatever is necessary, attach a custom script that would keep this up-to-date with the orbital position, etc).
Logged

Cosmitz

  • Admiral
  • *****
  • Posts: 758
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3278 on: May 08, 2017, 08:31:18 PM »

I'm making a shipsystem, all fine and dandy, adds flux dissipation and a flat hard flux dissipation. The script. https://pastebin.com/GXTKrN7A

However... I'd like to force a vent at the end of the ship system. Maybe even with a forced short overload of 2-3 seconds. However, my knowledge of java is disasterous. I'd assume something like this?

public ShipSystemStatsScript.StatusData getStatusData(int index, ShipSystemStatsScript.State state, float effectLevel) {
      if (state == ShipSystemStatsScript.State.OUT) somethingsomething.FluxTrackerAPI().forceOverload(0) ?

I just don't know. Will prolly hit the books tomorrow.
Logged

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3279 on: May 09, 2017, 03:52:26 AM »

Would still want an answer to my previous question, and I have more:

- I just took a glance at stations, can they have more than 3 sections? Anything specific I have to watch out for when making new stations?

- say I wanted to spaw a powerful alien fleet after 300 days or when a player reaches lvl10. What is the code for those conditional checks?
I have this script:

Code
package data.scripts.world;

import com.fs.starfarer.api.EveryFrameScript;
import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.*;
import data.scripts.world.FleetSpawner;
import data.scripts.plugins.SectorScans;

import java.awt.*;
import java.util.GregorianCalendar;


public class TimeManager implements EveryFrameScript, SpawnPointPlugin {
    private static final float BASE_INTERVAL = 1.0f;
    private static final int FIRST_DAY_IN_WEEK = GregorianCalendar.SUNDAY;
    private float heartbeatInterval;
    private long lastHeartbeat;
    private  int days;
    private GregorianCalendar calendar = new GregorianCalendar();

    //private SectorAPI Player = Global.getSector();
    //private DataSafe.PlayerData data = DataSafe.getPlayerData(Player);

    private CampaignFleetAPI playerFleet;

    private static final Color HIGHLIGHT_COLOR = Global.getSettings().getColor("buttonShortcut");
    private static final Color RED = Global.getSettings().getColor("darkRedTextColor");
    private static final Color GREEN = Global.getSettings().getColor("textFriendColor");
    private static final Color YELLOW= Global.getSettings().getColor("darkYellowTextColor");
    private static final Color CYAN = Global.getSettings().getColor("textNeutralColor");

    private StarSystemAPI starSystem;

    public TimeManager()
    {
        lastHeartbeat = Global.getSector().getClock().getTimestamp();
        heartbeatInterval = (1.0f - (Global.getSector().getClock().getHour() / 24f));
    }

    private void runHourly()
    {



    }

    private void runDaily()
    {
        //playerFleet = Global.getSector().getPlayerFleet();

        relationshipChecker();
        SectorScans.probing();

        informer();
        loan_checker();
        FleetSpawner.WDW_spawner();
        FleetSpawner.MAR_spawner();
        FleetSpawner.FFS_spawner();
        FleetSpawner.pirate_spawner();
        FleetSpawner.isa_rsf_invaders_spawn();
        FleetSpawner.aliens_spawner();
        FleetSpawner.rock_spawner();
        FleetSpawner.AI_spawner();

        //Global.getSector().getCampaignUI().addMessage("A day has passed...");

    }

    private void runWeekly()
    {
        productionManager();
        //FleetSpawner.patrol_spawner();
FleetSpawner.vnsmain_spawner();
    }

    private void runEach20()
    {

        days = 0;
    }

    private void runMonthly()
    {

       
    }


    private void runYearly()
    {

    }



    public void advance(SectorAPI sectorAPI, LocationAPI locationAPI)
    {
        if (sectorAPI.getClock().getElapsedDaysSince(lastHeartbeat) >= heartbeatInterval)
        {
            doIntervalChecks(sectorAPI.getClock().getTimestamp());
            checkSynched();
        }
    }

    private void doIntervalChecks(long time)
    {
        lastHeartbeat = time;
        runDaily();
        days++;
        calendar.setTimeInMillis(time);

        /*if (days == 20)
        {
            runEach20();
        } */

        if (calendar.get(GregorianCalendar.DAY_OF_WEEK) == FIRST_DAY_IN_WEEK)
        {
            runWeekly();
        }

        if (calendar.get(GregorianCalendar.DAY_OF_MONTH) == 1)
        {
            runMonthly();

            if (calendar.get(GregorianCalendar.DAY_OF_YEAR) == 1)
            {
                runYearly();
            }
        }
    }

    private void checkSynched()
    {
        // Compensate for day-synch code in constructor
        if (heartbeatInterval != BASE_INTERVAL)
        {
            heartbeatInterval = BASE_INTERVAL;
        }
    }


    private void shipConstructor()
    {

    }


    private void relationshipChecker()
    {
        float pirate = Global.getSector().getPlayerFleet().getFaction().getRelationship("pirates");
        float indy = Global.getSector().getPlayerFleet().getFaction().getRelationship("independent");
        float wdw = Global.getSector().getPlayerFleet().getFaction().getRelationship("WDW");
        float mar = Global.getSector().getPlayerFleet().getFaction().getRelationship("MAR");

        if (indy < -0.6f && !Global.getSector().getEntityById("pixie").hasTag("most_wanted"))
        {
            Global.getSector().getPlayerFleet().getFaction().setRelationship("UIN", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("XLE", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("RSF", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("ISA", RepLevel.HOSTILE);
            Global.getSector().getPlayerFleet().getFaction().setRelationship("VNS", RepLevel.HOSTILE);

            Global.getSector().getCampaignUI().addMessage("For your continuous aggression against Free Traders Guild you are being put at 'most wanted' list by all major factions!", Color.RED);

            Global.getSector().getEntityById("pixie").addTag("most_wanted");
        }

        else if (indy > -0.15f && Global.getSector().getEntityById("pixie").hasTag("most_wanted"))
        {
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("UIN", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("XLE", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("RSF", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("ISA", +0.15f);
            Global.getSector().getPlayerFleet().getFaction().adjustRelationship("VNS", +0.15f);

            Global.getSector().getCampaignUI().addMessage("Your attempts to repair relationship with the Free Traders Guild was noticed by the major factions.", Color.YELLOW);

            Global.getSector().getEntityById("pixie").removeTag("most_wanted");
        }

    }



    @Override
    public boolean isDone() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public boolean runWhilePaused() {
        return false;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void advance(float v) {
        //To change body of implemented methods use File | Settings | File Templates.
    }

}

But how would I check player level and current day?
Logged

vorpal+5

  • Captain
  • ****
  • Posts: 286
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3280 on: May 10, 2017, 07:39:11 AM »

Is there any possibility to play in slow motion / bullet time? I know what you people think about that, probably, but really, I would really enjoy that. I would even be prepare for a paypal donate if it happened, really!
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3281 on: May 10, 2017, 08:24:48 AM »

If you have some really basic Java knowledge, you can take the Fleet Building Tounament's mission and reverse engineer the slow-mo key function.

http://fractalsoftworks.com/forum/index.php?topic=11539.0
Logged
 

Deshara

  • Admiral
  • *****
  • Posts: 1578
  • Suggestion Writer
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3282 on: May 10, 2017, 11:05:35 AM »

so in my question to rebalance some of the vanilla weapons, I've come upon a thing; I want to remove the rocket pod's shot spread, or at least its set-in-stone shot spread. Where is that behavior located? I see nothing in the weapons data that would indicate it
EDIT: never mind got an answer in the discord, barrel angle offset in the annihilator weapon file
« Last Edit: May 10, 2017, 11:17:16 AM by Deshara »
Logged
Quote from: Deshara
I cant be blamed for what I said 5 minutes ago. I was a different person back then

Histidine

  • Admiral
  • *****
  • Posts: 4688
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3283 on: May 11, 2017, 05:55:24 AM »

Is there a difference between the SECTOR and ENSURE_DELIVERY message priorities?

Do tariffs have any impact on NPC trade?

Does killing trade fleets actually affect trade flows in any way in 0.8?

- say I wanted to spaw a powerful alien fleet after 300 days or when a player reaches lvl10. What is the code for those conditional checks?
[...]
But how would I check player level and current day?
Player level: Global.getSector().getPlayerPerson().getStats().getLevel();
Current day: You can get the day/month/year displayed (e.g. 31 Jan 208) with a CampaignClockAPI (Global.getSector().getClock()), but for actually getting ingame time since start of game I don't know how to other than manually using advance() in a script added at the start of the game
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24127
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #3284 on: May 11, 2017, 10:36:58 AM »

Is there a difference between the SECTOR and ENSURE_DELIVERY message priorities?

Yes, SECTOR will expire after about a month of being undeliverable, while ENSURE_DELIVERY will stick around for 10k days before being discarded.

Also SECTOR is capped to 100 light-years - a holdover from when that was more than big enough to cover anything.

Do tariffs have any impact on NPC trade?

IIRC it does not.

Does killing trade fleets actually affect trade flows in any way in 0.8?

It does, but it's pretty obscure. Losses of trade fleets increase the "weight" of a market-market connection, making all trade along it flow with more difficulty.
Logged
Pages: 1 ... 217 218 [219] 220 221 ... 710