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 ... 412 413 [414] 415 416 ... 706

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

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6195 on: March 19, 2020, 01:30:53 AM »

Solved one problem, got the next.
I want to modify the export value for goods provided by a single market.

Is that doable? (please don't say next version :P )
Logged

Harpuea

  • Lieutenant
  • **
  • Posts: 58
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6196 on: March 19, 2020, 06:00:53 AM »

How exactly does setSprite() work? Any one know? I tried messing around a hullmod and the ship always turn transparent.

Code
{
"graphics":{
"paintjobs":{
"diableavionics_vapor":"graphics/da/ships/diableavionics_vapor_white.png",
},
}
}

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;
import com.fs.starfarer.api.combat.ShipAPI.HullSize;
import com.fs.starfarer.api.combat.CollisionClass;

public class Paintjob extends BaseHullMod {

    private float CenterX = 0f;
private float CenterY = 0f;

@Override
    public void applyEffectsBeforeShipCreation(HullSize hullSize, MutableShipStatsAPI stats, String id) {
    }
   
    @Override
    public String getDescriptionParam(int index, HullSize hullSize) {
        return null;
    }
   
    @Override
    public void applyEffectsAfterShipCreation(ShipAPI ship, String id) {
    CenterX  = ship.getSpriteAPI().getCenterX();
    CenterY   = ship.getSpriteAPI().getCenterY();
    ship.setSprite("paintjobs", "diableavionics_vapor"); //need settings.sjon file
    ship.getSpriteAPI().setCenterX(CenterX);
    ship.getSpriteAPI().setCenterY(CenterY);
    }
   
    @Override
    public boolean isApplicableToShip(ShipAPI ship)
    {
   
return ( ship.getHullSpec().getHullId().startsWith("diableavionics_vapor"));
    }
}

[attachment deleted by admin]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6197 on: March 19, 2020, 10:23:39 AM »

Solved one problem, got the next.
I want to modify the export value for goods provided by a single market.

Is that doable? (please don't say next version :P )

Only market.getIncomeMult(), I'm afraid - which affects both exports and baseline colony income. You could also compute it separately and add it as its own item in the monthly income report, but with that approach, it would not show up in "income" field in the colony screen or the colony list.

@Harpuea: hmm, I just tried "ship.setSprite("newGame", "mixed");" and that worked, so I'm not sure. This kind of sounds like the sprite you're using doesn't exist (i.e. a typo in the path?) or is not a 24-bit png or is corrupted in some way etc.
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6198 on: March 19, 2020, 10:49:25 AM »

Only market.getIncomeMult(), I'm afraid - which affects both exports and baseline colony income. You could also compute it separately and add it as its own item in the monthly income report, but with that approach, it would not show up in "income" field in the colony screen or the colony list.

Hm, not the answer I was hoping for, but kinda what I expected.
Any chance of having an API hook for that in the next version? I was trying to assign a dynamic export value to luxury goods, so the export value/unit would increase based on the presence of some conditions.

Thanks,
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6199 on: March 19, 2020, 10:54:02 AM »

Probably not, to be honest. I'll keep it in mind in case I happen to be doing other stuff in that area of the code, though.
Logged

Harpuea

  • Lieutenant
  • **
  • Posts: 58
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6200 on: March 19, 2020, 12:13:31 PM »

Quote
@Harpuea: hmm, I just tried "ship.setSprite("newGame", "mixed");" and that worked, so I'm not sure. This kind of sounds like the sprite you're using doesn't exist (i.e. a typo in the path?) or is not a 24-bit png or is corrupted in some way etc.

It was an issue with color mode. Thank you very much.

[attachment deleted by admin]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6201 on: March 19, 2020, 12:17:20 PM »

Glad you got it working!
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6202 on: March 20, 2020, 03:58:31 PM »

The industry limit can be adjusted via dynamic stat mods in this version (0.9.1a) already, which might prove useful for anyone reading this while searching the thread.
Code
market.getStats().getDynamic().getMod(Stats.MAX_INDUSTRIES).modify...

for my actual question:
I'd like to set Recreational Drugs as legal on a market via a condition.
Code
market.getCommodityData(Commodities.DRUGS).setSupplyLegal(true);
doesn't seem to do it. What am I missing?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6203 on: March 20, 2020, 04:41:54 PM »

for my actual question:
I'd like to set Recreational Drugs as legal on a market via a condition.
Code
market.getCommodityData(Commodities.DRUGS).setSupplyLegal(true);
doesn't seem to do it. What am I missing?

Taking a quick look at the code, that only works the other way - to make something that would otherwise be legal, illegal. It's not used in vanilla as far as I can tell and I'm not even sure it works correctly.
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6204 on: March 20, 2020, 05:05:58 PM »

I take it there's no current way to achieve that then?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6205 on: March 20, 2020, 05:12:38 PM »

I don't believe so, but it depends on the specifics of what you're doing. For example if the drugs are being produced by a specific industry, then having it return true from isSupplyLegal() *should* make them legal on that market as far as getting income from exports.

(You could also set the market to free port, though that of course has other implications...)
Logged

MeinGott

  • Ensign
  • *
  • Posts: 35
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6206 on: March 21, 2020, 02:48:27 AM »

Hello, two things:

Is there a way to change when enemy retreats? I fly with big fleet and when I meet small enemy, I deploy matching force of my ships, so that I dont overpower them but keep it fair. Of course enemy retreats because calculations take into account my whole fleet. Same thing when I join a friend in a fight, I deploy only one ship, but enemies turn tails. And so, how do I make AI braver? Its ok if only in battle - fleeing on campaign screen is permitted :) 

Second thing - I suspect Alex actually enjoys helping modders, seeing how often he replies here, what a guy!

Thanks
Logged

SirHartley

  • Global Moderator
  • Admiral
  • *****
  • Posts: 839
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6207 on: March 21, 2020, 06:38:06 AM »

I don't believe so, but it depends on the specifics of what you're doing. For example if the drugs are being produced by a specific industry, then having it return true from isSupplyLegal() *should* make them legal on that market as far as getting income from exports.

(You could also set the market to free port, though that of course has other implications...)

I'm trying to make the general import and export of drugs (only drugs, not organs) legal for a specific market, via a condition that can be applied by the player through a menu.
This should affect all industries, not just mine - which it currently doesn't as I'd like to avoid that if possible :)
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6208 on: March 21, 2020, 10:16:05 AM »

Is there a way to change when enemy retreats? I fly with big fleet and when I meet small enemy, I deploy matching force of my ships, so that I dont overpower them but keep it fair. Of course enemy retreats because calculations take into account my whole fleet. Same thing when I join a friend in a fight, I deploy only one ship, but enemies turn tails. And so, how do I make AI braver? Its ok if only in battle - fleeing on campaign screen is permitted :) 

IIRC the AI doesn't consider enemy reserves when deciding whether to retreat from the battlefield.

I'm not sure if it's in the current release or not, but: CombatTaskManagerAPI.setPreventFullRetreat(false) would do the job.

Otherwise, there's BattleCreationContext.aiRetreatAllowed, but getting to that would be more complicated.

Second thing - I suspect Alex actually enjoys helping modders, seeing how often he replies here, what a guy!

(Ha! Let's just say I'm glad to help.)

I'm trying to make the general import and export of drugs (only drugs, not organs) legal for a specific market, via a condition that can be applied by the player through a menu.
This should affect all industries, not just mine - which it currently doesn't as I'd like to avoid that if possible :)

Ah, gotcha. Nothing comes to mind, unfortunately.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6209 on: March 21, 2020, 08:16:28 PM »

Is there a way to make commodities be treated as crew/marines for cargo purposes (use crew capacity, can't be dumped with other cargo)?
Logged
Pages: 1 ... 412 413 [414] 415 416 ... 706