Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.95.1a is out! (12/10/21); Blog post: Uniquifying the Factions, Part 2 (04/30/22)

Pages: 1 ... 395 396 [397] 398 399 ... 594

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

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5940 on: January 16, 2020, 05:13:37 PM »

I'm not sure I understand the question. If it's about missions you've added, then you could add timeouts to those, or not, as you choose, right? So I'm probably missing something.

Nothing I've added that I know of. I'm still trying to determine whether the issue stemmed from missions or generic trade to pirate bases without a tariff. Their issue was gaining 500k credits in 10 minutes through exploitative trade upon a new game start. The description I have available is on the bottom of this page:

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20468
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5941 on: January 16, 2020, 05:23:42 PM »

Ahh, I see. There's some stuff I need to work out there - apparently Derinkuyu suffers from the same or a related issue on new game start, but you could remove procurement missions entirely by removing them from the generic mission manager on every game load:

GenericMissionManager manager = GenericMissionManager.getInstance();

And then iterate over manager.getCreators() to remove whatever you like. And then, possibly, replace it with your own version.
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 #5942 on: January 16, 2020, 05:49:59 PM »

Ahh, I see. There's some stuff I need to work out there - apparently Derinkuyu suffers from the same or a related issue on new game start, but you could remove procurement missions entirely by removing them from the generic mission manager on every game load:

GenericMissionManager manager = GenericMissionManager.getInstance();

And then iterate over manager.getCreators() to remove whatever you like. And then, possibly, replace it with your own version.

Thanks for the information!  :)

I don't think I will go to that length most likely as it has the potential to break in future updates and be harder to maintain, but it's really awesome that this is possible.
Logged

Razor98566

  • Ensign
  • *
  • Posts: 28
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5943 on: January 17, 2020, 11:10:36 AM »

Hello there,
I'm currently following a tutorial (this one: http://fractalsoftworks.com/forum/index.php?topic=3877.0) to make my factions spawn on the map and do stuff.

Since this tutorial is a little old now there are a few things in my way. The functions "addOrbitalStation" and '"createFleet" are no longer available and now I'm wondering how I can circumvent this and make my code work.

Here's what's in my gen and spawnpoint files so far:
colGen.java:
Spoiler
Code
package data.scripts.world;

import java.awt.Color;
import java.util.List;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.CargoAPI;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import com.fs.starfarer.api.campaign.SectorGeneratorPlugin;
import com.fs.starfarer.api.campaign.StarSystemAPI;
import com.fs.starfarer.api.fleet.FleetMemberType;
import com.fs.starfarer.api.impl.campaign.procgen.SectorProcGen;
import com.fs.starfarer.api.campaign.FactionAPI;
import com.fs.starfarer.campaign.Faction;
import com.fs.starfarer.api.EveryFrameScript;

@SuppressWarnings("unchecked")
public class colGen implements SectorGeneratorPlugin {

public void generate(SectorAPI sector) {
   
StarSystemAPI system = sector.getStarSystem("Corvus");

SectorEntityToken stock = system.getEntityByName("Abandoned Storage Facility");
   
SectorEntityToken token = system.createToken(0, 0);

SectorEntityToken caprica = system.addPlanet("bsg_caprica", token, "New Caprica", "Barren",5,  5, 20, 15);

                *this is where I would like to add the station*
                SectorEntityToken station1 = system.add
                *Can be ignored, I gotta fix ColSpawnPoint first xD*
system.addSpawnPoint(new ColSpawnPoint());

FactionAPI bsg_colonies = sector.getFaction("bsg_colonies");
bsg_colonies.setRelationship("hegemony", 1);
bsg_colonies.setRelationship("tritachyon", -1);
bsg_colonies.setRelationship("pirates", 0);
bsg_colonies.setRelationship("independent", 0);
bsg_colonies.setRelationship("bsg_cylons", -100);
bsg_colonies.setRelationship("player", 1);
}
}
[close]

ColSpawnPoint.java:
Spoiler
Code
package data.scripts.world;

import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.FleetAssignment;
import com.fs.starfarer.api.campaign.LocationAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;

import data.scripts.world.BaseSpawnPoint;

public class ColSpawnPoint extends BaseSpawnPoint {

public ColSpawnPoint(SectorAPI sector, LocationAPI location,
        float daysInterval, int maxFleets, SectorEntityToken anchor) {
        super(sector, location, daysInterval, maxFleets, anchor);
        }

@Override
protected CampaignFleetAPI spawnFleet() {
        //if ((float) Math.random() < 0.5f) return null;
        String type = null;
        float r = (float) Math.random();
        if (r > .6f) {
           type = "patrol";
        } else if (r > 0.25f) {
           type = "raid";
        } else if (r > 0.10f) {
           type = "attack";
        } else {
           type = "systemDefense";
        }

        //
        CampaignFleetAPI fleet = getSector().createFleet("bsg_colonies", type);
        getLocation().spawnFleet(getAnchor(), 0, 0, fleet);

        fleet.setPreferredResupplyLocation(getAnchor());
        if (type.equals("patrol") || type.equals("raid") || type.equals("attack")) {
           fleet.addAssignment(FleetAssignment.RAID_SYSTEM, null, 10);
           fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
        } else {
           if ((float) Math.random() > 0.8f) {
              fleet.addAssignment(FleetAssignment.PATROL_SYSTEM, null, 30);
              fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
        } else {
              fleet.addAssignment(FleetAssignment.DEFEND_LOCATION, getAnchor(), 20);
              fleet.addAssignment(FleetAssignment.GO_TO_LOCATION_AND_DESPAWN, getAnchor(), 1000);
           }
        }
        return fleet;
   }
}
[close]

I'm using IntelliJ, just in case it matters ^^

Logged

Histidine

  • Admiral
  • *****
  • Posts: 3841
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5944 on: January 17, 2020, 05:15:13 PM »

That tutorial is 8 years old and can be assumed not to work.
You should look at a recent vanilla or mod example. Look in [starsector-core]\data\scripts\world\systems (Galatia.java for adding markets through code, other files for markets added with economy json files*)

*data/campaign/econ
Logged

ottodeluxe

  • Ensign
  • *
  • Posts: 9
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5945 on: January 18, 2020, 06:13:33 AM »

I didn't find anything after fiddling around a bit, and neither did I find an answer with the search function, so it's "ask someone who has a clue"-time:

I am trying to make a hull mod that buffs various aspects of a ship depending on the number of crew aboard. My problem is, I don't know how to get the current number of crew on a given ship to determine the bonus.
So far, I have tried to get the CrewFraction from the FleetMemberAPI, and multiplying the fraction by the minimum crew to get the total. However, my call to ship.getMember() always returns null. Is the FleetMemberAPI only available in combat? If so, is there any way to get the actual number of crew on a specific ship for use in a hull mod?

my idea in code:
Spoiler
   public float getCrew(ShipAPI ship) {
      FleetMemberAPI memberAPI = ship.getFleetMember();
      float crewFraction = memberAPI.getCrewFraction();
      float neededCrew = memberAPI.getMinCrew();
      float totalCrew = neededCrew * crewFraction;
      return totalCrew;
   }
[close]

My second guess is, that CrewCompositionAPI.getCrew() would also do what I want, but again, I have not found a way to access it.

edit: This does actually work, but seems to be a convoluted and not very fool-proof way. Duplicate names would cause a problem.

Spoiler
   public float getCrew(ShipAPI ship) {
      logger.info(ship);
      FleetMemberAPI memberAPI = ship.getFleetMember();
      logger.info("first try: " + memberAPI);
      List<FleetMemberAPI> ships = Global.getSector().getPlayerFleet().getFleetData().getMembersListCopy();
      for (FleetMemberAPI fleetShip : ships){
         logger.info(fleetShip);
         if (fleetShip.getShipName().equals(ship.getName())) {
            memberAPI = fleetShip;
            logger.info("found match");
         }
      }
      logger.info("second try: " + memberAPI);
      currentMember = memberAPI;
      float crewFraction = memberAPI.getCrewFraction();
      float neededCrew = memberAPI.getMinCrew();
      float totalCrew = neededCrew * crewFraction;
      crew = totalCrew;
      return totalCrew;
   }
[close]
« Last Edit: January 18, 2020, 07:34:48 AM by ottodeluxe »
Logged

scmp

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5946 on: January 18, 2020, 10:04:29 AM »

I'm trying to make my first mod which just adds a new star system into the game. I'm running into two (probably related) problems.

This is the first.
Spoiler
[close]

and when I try to launch the game I get this error.
Spoiler
[close]

I've been googling to no avail. Any help please?
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 6403
  • Harpoon Affectionado
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5947 on: January 18, 2020, 10:10:00 AM »

Hi!

1) You need to make sure that your package structure matches the file location in the source.

2) You need to have correct import statements in order for your code to recognize external classes (like the one's from starsector). I see you are using an IDE, though I don't know which one. In Netbeans imports can be done automatically once the starfarer api zip has been linked as a library.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 3841
    • View Profile
    • Bitbucket profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5948 on: January 19, 2020, 01:33:12 AM »

Is there a way to suppress a SectorEntityToken from using the drop groups normally defined for that entity type in salvage_entity_gen_data.csv?
(I'm specifying my own random drops in code)
Logged

MeinGott

  • Ensign
  • *
  • Posts: 33
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5949 on: January 19, 2020, 06:38:23 AM »

Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20468
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5950 on: January 19, 2020, 09:35:48 AM »

I didn't find anything after fiddling around a bit, and neither did I find an answer with the search function, so it's "ask someone who has a clue"-time:

I am trying to make a hull mod that buffs various aspects of a ship depending on the number of crew aboard. My problem is, I don't know how to get the current number of crew on a given ship to determine the bonus.
So far, I have tried to get the CrewFraction from the FleetMemberAPI, and multiplying the fraction by the minimum crew to get the total. However, my call to ship.getMember() always returns null. Is the FleetMemberAPI only available in combat? If so, is there any way to get the actual number of crew on a specific ship for use in a hull mod?

It seems like if you used the second way, but instead of the name, used ship.getFleetMemberId(), that should work.


Is there a way to suppress a SectorEntityToken from using the drop groups normally defined for that entity type in salvage_entity_gen_data.csv?
(I'm specifying my own random drops in code)

Hmm - you could create a version of the sal_salvageOptionSelected rule that doesn't call "SalvageEntity performSalvage" and instead calls... whatever you like, to generate the salvage. See ScientistAICoreIntel.genLoot() for a quick example doing something similar, though it doesn't go the same exact route because the interaction flow there is not the standard salvage interaction.


Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you

See: hil.wpn for how that's defined, in particlar you're looking for "pierceSet".
Logged

jeffg10

  • Ensign
  • *
  • Posts: 33
  • Cheesus Crist
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5951 on: January 19, 2020, 12:49:36 PM »

So, basically i took the "Tore Up Plenty" mod and tired to update it to no avail (presumably due to my lack of modding experience) BUT as a last effort i just took the OG file and updated the mod_info.jason and tup.version files to the current version and the mod seems to work properly? is this intended / normal behavior or is it due to the technically simple nature of the mod?

Edit: Missions work, but Campaign still crashes, press F
« Last Edit: January 19, 2020, 01:31:17 PM by jeffg10 »
Logged
"Someone else might have wept or screamed in frustration or even given up right there and perished. But I didn't have the right to do any of those things, not while my people were in danger. Like it or not, I would have to explore this harsh world on my own."

creature

  • Captain
  • ****
  • Posts: 359
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5952 on: January 20, 2020, 07:20:50 PM »

Is there a way for a hullmod check if there is a ship with a certain other hullmod within the player's fleet?

I want a hullmod to give different effects to a ship if there are other ships in the fleet with that other hullmod.
Logged

MeinGott

  • Ensign
  • *
  • Posts: 33
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5953 on: January 21, 2020, 06:24:04 AM »

Hello
What parameter in weapon files decides whether beam is interrupted by passing missiles or goes through?
thank you

See: hil.wpn for how that's defined, in particlar you're looking for "pierceSet".

There doesnt appear to be any difference in action between wpn file with full pierceSet defined and the one without it alltogether. I assumed pierceSet contains flags for objects that are supposed to be pierced through, was I wrong?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 20468
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5954 on: January 21, 2020, 08:46:06 AM »

Is there a way for a hullmod check if there is a ship with a certain other hullmod within the player's fleet?

I want a hullmod to give different effects to a ship if there are other ships in the fleet with that other hullmod.

Hmm - stats.getFleetMember().getFleetData().getFleet() or some such? Making sure to separate that out into steps and check that each return value is not null, otherwise this would be asking for a crash in some random circumstance (i.e. that hullmod being on a ship in a main-menu mission, or some such).


There doesnt appear to be any difference in action between wpn file with full pierceSet defined and the one without it alltogether. I assumed pierceSet contains flags for objects that are supposed to be pierced through, was I wrong?

No, you're correct. I'm not sure what's not working out in your specific case but this works for the HIL mounted on a ship, so I'd start with that and try to figure out what the differences are.
Logged
Pages: 1 ... 395 396 [397] 398 399 ... 594