Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Pages: 1 ... 118 119 [120] 121 122 ... 711

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

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1785 on: October 25, 2014, 11:45:37 PM »

fixed:

Code: java
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1786 on: October 25, 2014, 11:50:26 PM »

Ah, ok. So Sundog it appears that I will need to use the primaryEntity.setMarket(newMarket); to associate the market back to the planet in the first place. You would think setting the primary entity would do it both ways...ah well. Let's give it a shot.
Ah, you didn't catch my edit. I should have made a new reply to make sure you noticed :(

My dynamically generated market still isn't working right either. Are you getting stacks of 50 supplies and fuel in your black market that sell for 1 credit each? That's the most obvious symptom of my current problem. It seems like my market isn't connected to the rest of the economy at all even when I connect it to every other market  :-\

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1787 on: October 25, 2014, 11:53:21 PM »

fixed:

Code: java
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
That's a strange fix. I don't get it, but I'll try it!  :)

Edit: Oh, I see now. We were just trying to do different things.
« Last Edit: October 25, 2014, 11:57:54 PM by Sundog »
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1788 on: October 26, 2014, 12:34:13 AM »

Hm, no, can't say I'm getting the same issue with supplies/fuel worth 1 supply, let me post my whole code once I figure out why I'm not seeing tarrifs on this market...
Logged

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1789 on: October 26, 2014, 12:49:56 AM »

Ok fixed that tarrif issue.

Here is the current code:

Code: java
private void addMarketplace(String factionID, SectorEntityToken primaryEntity, ArrayList<SectorEntityToken> connectedEntities, String name, int size, ArrayList<String> marketConditions, ArrayList<String> submarkets, float tarrif) {
        EconomyAPI globalEconomy = Global.getSector().getEconomy();

        String planetID = primaryEntity.getId();
       
        //generate the market ID
        String marketID = planetID + "_market";
       
        //generate the market
        MarketAPI newMarket = Global.getFactory().createMarket(marketID, name, size);
       
        //set the faction associated with the market
        newMarket.setFactionId(factionID);
       
        //set the primary entity related to the market
        newMarket.setPrimaryEntity(primaryEntity);
       
        //set the base smuggling value (starting value)
        newMarket.setBaseSmugglingStabilityValue(0);
       
        //set the starting tarrif, could also make this value an input
        newMarket.getTariff().modifyFlat("generator", tarrif);
       
        //add each sub-market types to the mark
        if (null != submarkets){
            for (String market: submarkets){
                newMarket.addSubmarket(market);
            }
        }
       
        //add each market conditions
        for (String condition : marketConditions) {
            newMarket.addCondition(condition);
        }
       
        //add all connected entities to this marketplace, moons/stations etc.
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                newMarket.getConnectedEntities().add(entity);
            }
        }
       
        //add the market to the global market place
        globalEconomy.addMarket(newMarket);
       
        //get the primary entity and associate it back to the market that we've created
        primaryEntity.setMarket(newMarket);
       
        //get all associated entities and associate it back to the market we've created
        if (null != connectedEntities) {
            for (SectorEntityToken entity : connectedEntities) {
                entity.setMarket(newMarket);
            }
        }
    }

Here is an example usage of the method

Code: java
        PlanetAPI rocky2 = system.addPlanet("uaf_shizuka", star, "Shizuka", "rocky_unstable", 175, 60, 3432, 125);
        PlanetAPI rocky2moon1 = system.addPlanet("uaf_shizuka_kai", rocky2, "Shizuka Kai", "rocky_metallic", 305, 10, 100, 3);

        addMarketplace("uaf_d",
                rocky2,
                new ArrayList<>(Arrays.asList((SectorEntityToken) rocky2moon1)),
                "Ryoko Mining Facility",
                3,
                new ArrayList<>(Arrays.asList(Conditions.ARID, Conditions.ORE_COMPLEX, Conditions.OUTPOST, Conditions.FRONTIER, Conditions.STEALTH_MINEFIELDS, Conditions.POPULATION_3)),
                new ArrayList<>(Arrays.asList(Submarkets.SUBMARKET_STORAGE, Submarkets.SUBMARKET_BLACK, Submarkets.SUBMARKET_OPEN)),
                0.3f
        );
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1790 on: October 26, 2014, 08:38:49 AM »

Turns out my market was having issues not because it's attached to fleet, but because it was created after the economy was initialized.

A few questions regarding market connections:
 - Should connections be created based on proximity?
 - Are there other factors we should take into consideration when deciding whether or not to create a connection?
 - For example, should hostile markets be connected to each other?
 - Do they change over time, or are they static?

Debido

  • Admiral
  • *****
  • Posts: 1183
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1791 on: October 26, 2014, 08:45:10 AM »

 - Should connections be created based on proximity? - Yes
 - Are there other factors we should take into consideration when deciding whether or not to create a connection? Nope, but if you liked you could tied say...10 planets in a star system together as a 'single market' if you really wanted to. In the vanilla game, the connected entities aren't quite what you think maybe? Connected entities are for example the Jangala planet and it's station. They are connected entities as far as the market is concerned, so if you click on either you get the same market dialog screen
 - For example, should hostile markets be connected to each other? No, see above explanation
 - Do they change over time, or are they static? Nope, it just ties together one or more entities so that the market dialog presented is the exact same.
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1792 on: October 26, 2014, 10:14:43 AM »

Ok. I thought you had misunderstood my question at first, but it turns out that I was under the false assumption that connected markets were other markets that your market could trade with rather than markets that are connected the way Jangala and it's station share a market.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1793 on: October 26, 2014, 01:31:42 PM »

About the fuel/supplies on black market: it's an issue in vanilla as well, the reason is the black market adds some fuel/supplies regardless of there being any supply/demand for it locally. If there isn't, the prices kind of break. Going to fix it for vanilla one way or another - maybe by adding some low-level fuel/supplies demand to every market.
Logged

Sundog

  • Admiral
  • *****
  • Posts: 1727
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1794 on: October 26, 2014, 01:38:36 PM »

I don't know if this is the case all the time, but in one instance I waited about two months after dynamically creating a station to see if the prices would adjust after a while, and they did. So at least the issue is temporary  :)

Toxcity

  • Admiral
  • *****
  • Posts: 561
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1795 on: October 26, 2014, 03:04:40 PM »

Is it possible for ship skins to have different engine types, like lowtech to hightech? I didn't see any in vanilla, but just wanted to double check if it was possible.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1796 on: October 26, 2014, 10:12:40 PM »

I don't know if this is the case all the time, but in one instance I waited about two months after dynamically creating a station to see if the prices would adjust after a while, and they did. So at least the issue is temporary  :)

Yeah, if you're adding markets dynamically, it'll take a while for the simulation to catch up and stabilize. If you're just adding them on game start, what you want to do is add the markets in ModPlugin.onNewGame(). This is called before the economy is loaded, so any markets you configure there will run for initialStepsToRun (from economy.json) and thus will be stabilized by the time the game starts.

Is it possible for ship skins to have different engine types, like lowtech to hightech? I didn't see any in vanilla, but just wanted to double check if it was possible.

It's not, no.
Logged

MShadowy

  • Admiral
  • *****
  • Posts: 911
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1797 on: October 26, 2014, 10:35:25 PM »

Alright, having a problem with getting some market conditions to behave properly.  The following scripts do compile in Netbeans, and the game will load up to the menu properly with them in the jar.

However, if this set of market data is called in a systems economy it crashes when starting a campaign; the code snippets should look familiar to Alex, they're basically cribbed from what I believe are the standard WorldFarming.java:

Spoiler
Code: java
package data.scripts.campaign.econ;

import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

public class ms_worldFarming extends BaseMarketConditionPlugin {
    
    private final float foodMult, machineryMult, maxFood;
    
    public ms_worldFarming(float foodMult, float machineryMult) {
        this.foodMult = foodMult;
this.machineryMult = machineryMult;
this.maxFood = Float.MAX_VALUE;
    }
    
    public ms_worldFarming(float foodMult, float machineryMult, float maxFood) {
        this.foodMult = foodMult;
this.machineryMult = machineryMult;
this.maxFood = maxFood;
    }
    
    @Override
    public void apply(String id) {
float pop = getPopulation(market);
float foodProduced = pop * foodMult;
if (foodProduced > maxFood) foodProduced = maxFood;
float organicsProduced = foodProduced * ms_conditionData.FARMING_ORGANICS_FRACTION;
float machineryNeeded = pop * machineryMult;

market.getCommodityData(Commodities.ORGANICS).getSupply().modifyFlat(id, Math.max(1, organicsProduced));
market.getCommodityData(Commodities.FOOD).getSupply().modifyFlat(id, Math.max(1, foodProduced));
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, Math.max(1, machineryNeeded));
    }

    @Override
    public void unapply(String id) {
market.getCommodityData(Commodities.ORGANICS).getSupply().unmodify(id);
market.getCommodityData(Commodities.FOOD).getSupply().unmodify(id);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().unmodify(id);
    }
}
[close]

And one of the world specific ones:

Spoiler
Code: java
package data.scripts.campaign.econ;

class ms_worldSemiArid extends ms_worldFarming {
    
    public ms_worldSemiArid() {
        super(ms_conditionData.MS_WORLD_SEMI_ARID_FARMING_MULT, ms_conditionData.MS_WORLD_SEMI_ARID_MACHINERY_MULT);
    }

}
[close]

Which gives this... helpful error message:

Spoiler
Code: java
27329 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OOO0.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncherjava.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.loading.scripts.ScriptStore.Ó00000(Unknown Source)
at com.fs.starfarer.loading.M.String(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.<init>(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more
Caused by: java.lang.IllegalAccessException: Class com.fs.starfarer.loading.scripts.ScriptStore can not access a member of class data.scripts.campaign.econ.ms_worldSemiArid with modifiers "public"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:109)
at java.lang.Class.newInstance(Class.java:373)
... 22 more
[close]

Alternatively I tried dumping the script directly into the world specific java and ignoring the idea of a seperate core file to call the planet specific details from; this is from before I set up a market condition file:

Spoiler
Code: java
package data.scripts.campaign.econ;

import com.fs.starfarer.api.impl.campaign.ids.Commodities;
import com.fs.starfarer.api.impl.campaign.econ.BaseMarketConditionPlugin;

class ms_worldSemiArid extends BaseMarketConditionPlugin {
    
    @Override
    public void apply(String id) {
float pop = getPopulation(market);
float foodProduced = pop * 0.15f;
//if (foodProduced > maxFood) foodProduced = maxFood;
float organicsProduced = foodProduced * 0.05;
float machineryNeeded = pop * 0.0008f;

market.getCommodityData(Commodities.ORGANICS).getSupply().modifyFlat(id, Math.max(1, organicsProduced));
market.getCommodityData(Commodities.FOOD).getSupply().modifyFlat(id, Math.max(1, foodProduced));
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().modifyFlat(id, Math.max(1, machineryNeeded));
    }

    @Override
    public void unapply(String id) {
market.getCommodityData(Commodities.ORGANICS).getSupply().unmodify(id);
market.getCommodityData(Commodities.FOOD).getSupply().unmodify(id);
market.getDemand(Commodities.HEAVY_MACHINERY).getDemand().unmodify(id);
    }

}
[close]

This results in the following error:

Spoiler
Code: java
32498 [Thread-5] ERROR com.fs.starfarer.combat.String  - java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
java.lang.RuntimeException: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
at com.fs.starfarer.title.OoOO.dialogDismissed(Unknown Source)
at com.fs.starfarer.ui.do.dismiss(Unknown Source)
at com.fs.starfarer.ui.impl.J.dismiss(Unknown Source)
at com.fs.starfarer.campaign.save.J.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.OOO0.super(Unknown Source)
at com.fs.starfarer.ui.H.processInput(Unknown Source)
at com.fs.starfarer.ui.O0Oo.o00000(Unknown Source)
at com.fs.starfarer.B.void.class$super(Unknown Source)
at com.fs.A.A.Ò00000(Unknown Source)
at com.fs.starfarer.combat.String.o00000(Unknown Source)
at com.fs.starfarer.StarfarerLauncherjava.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.RuntimeException: Problem loading class [data.scripts.campaign.econ.ms_worldSemiArid]
at com.fs.starfarer.loading.scripts.ScriptStore.Ó00000(Unknown Source)
at com.fs.starfarer.loading.M.String(Unknown Source)
at com.fs.starfarer.campaign.econ.MarketCondition.<init>(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.Market.addCondition(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
at com.fs.starfarer.campaign.econ.B.o00000(Unknown Source)
... 13 more
Caused by: java.lang.InstantiationException: data.scripts.campaign.econ.ms_worldSemiArid
at java.lang.Class.newInstance(Class.java:364)
... 22 more
[close]

In both instances the super function seems to play a role, but the why escapes me.

For now, that's all; thanks for any help you can offer.

(Edited to add code=java for readability -Alex)
« Last Edit: October 26, 2014, 10:39:21 PM by Alex »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1798 on: October 26, 2014, 10:41:06 PM »

Can you try putting your stuff in a package other than data.scripts? I have a feeling that's messing with things. Not entirely sure though, this is just a first-order shot at a "hopefully easy fix".
Logged

Lcu

  • Commander
  • ***
  • Posts: 213
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #1799 on: October 27, 2014, 02:03:01 AM »

Is it okay if the shield radius is larger than the center of mass radius? (or should i post this question in the ship editor thread?)

Also another question, can the "SYSTEM" weapon slot be used to define the take off location for ship system drones?
« Last Edit: October 27, 2014, 02:16:02 AM by Lcu »
Logged
Spoiler
66766766
66766766
66666766
66766766
66766766
Ctrl+F, type 6
[close]
Pages: 1 ... 118 119 [120] 121 122 ... 711