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 ... 396 397 [398] 399 400 ... 706

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

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5955 on: January 21, 2020, 04:06:41 PM »

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).
Thank you for the quick reply! I tried something like this to check if the fleet has the hullmod I need, but it seems my checks are failing:
Spoiler
Code
private boolean doesFleetHaveGravEngines(ShipAPI ship) {


log.info("Check Fleet Member");
if(ship.getFleetMember() != null) {
log.info("Fleet member exist :: check fleet data");
if(ship.getFleetMember().getFleetData() != null) {
CampaignFleetAPI fleet = ship.getFleetMember().getFleetData().getFleet();

log.info("Fleet data exist :: check fleet");
if(fleet != null) {
log.info("Fleet exist :: check members");


List<FleetMemberAPI> members = fleet.getFleetData().getMembersListCopy();

log.info("Member count" + members.size() + ":: check individually");
for(FleetMemberAPI member : members) {
log.info("Member found" + member.getHullId() + ":: check if has Grav engines");
if(member.getVariant().hasHullMod("aria_GravEngines")) {
log.info("Found member with grav engines; returning");
return true;
}
}
}
}
}
return false;
}
[close]
The logs only get to this line,

Code
log.info("Check Fleet Member");

...which means that the ship doesn't have a fleet member? I tried this both in the mission preparation screen and in the campaign, with the same behavior on both...

EDIT2: Oh, and in case it's relevant, I call the above function in this part of the hullmod API:
Spoiler
Code
	@Override
public boolean isApplicableToShip(ShipAPI ship) {
if(!doesFleetHaveGravEngines(ship)) return false;
if(ship.getVariant().hasHullMod("aria_GravEngines")) return false;

return true;
}
[close]
...and again in getUnapplicableReason()

I'd do an EveryFrameScript and query the sector clock for the date periodically. Or use a DelayedActionScript, if you know the exact number of days to wait.
Thank you for this too! I just tried this out now and it's just what I needed!
« Last Edit: January 21, 2020, 05:04:08 PM by creature »
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5956 on: January 21, 2020, 04:59:17 PM »

- Sorry I messed up and pressed quote instead of modify -
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5957 on: January 21, 2020, 05:17:48 PM »

Hmm. stats.getFleetMember() will definitely return null *sometimes* - the applyEffectsBeforeShipCreation() method will get called many times for various reasons. But when actually applying the effects to the actual spawned ship's stats, it will return the fleet member - at least, in the dev version I've got running...
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5958 on: January 21, 2020, 06:10:03 PM »

Hmm, it returned null for all of maybe 5-10 seconds I waited in the Fleet Manager screen... By the way, I was calling the function in isApplicableToShip(), not applyEffectsBeforeShipCreation(), in case that made any difference.

Edit: Also tried to migrate the check to applyEffectsBeforeShipCreation(), didn't work.

Like so:

Code
		log.info("Checking inside before ship creation");
if(doesFleetHaveGravEngines(stats)) {
    stats.getSensorProfile().modifyMult(id, 1 + PROFILE_BONUS*0.01f);
    stats.getFuelUseMod().modifyMult(id, 1 + FUEL_CONSUMPTION_BONUS*0.01f);
}
« Last Edit: January 21, 2020, 06:18:21 PM by creature »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5959 on: January 21, 2020, 06:17:18 PM »

Yeah, that makes a difference. For the ship, I'm not sure the fleet member is set reliably at all. But for isApplicableToShip(), it's always going to be the player's fleet which you can get with Global.getSector() etc
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5960 on: January 21, 2020, 06:19:26 PM »

Oh, I could use that if it's more reliable. I don't mind if it's a player-only hullmod since I want it to influence mostly just fuel use.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5961 on: January 21, 2020, 06:23:22 PM »

To clarify, you can still use the other way when you apply the effects, so that non-player ships with this don't get a strange-looking stat tooltip, if that might possibly be an issue. But the isApplicableToShip method would only be called when it's in the player's fleet.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5962 on: January 21, 2020, 06:44:09 PM »

Hmm, I still couldn't get the .getFleetMember() calls to return correctly either way, but thankfully, the call to get the player fleet does, and that accomplishes what I needed to do! Thanks again for your help!
Logged

Thaago

  • Global Moderator
  • Admiral
  • *****
  • Posts: 7174
  • Harpoon Affectionado
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5963 on: January 21, 2020, 08:55:03 PM »

Is there any way to make the low CR accidents spawn on demand? I am making a test quest mod that has gotten out of hand and features a cursed golden lobster.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5964 on: January 21, 2020, 09:05:29 PM »

You mean in the campaign, right? When you're out of supplies etc? If so: regrettably (since I'm finding myself suddenly partial to cursed golden lobsters) I don't think so. You could have it show a custom interaction dialog on demand, though, and have <whatever> happen then, including damage to a ship and so on.
Logged

creature

  • Captain
  • ****
  • Posts: 400
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5965 on: January 22, 2020, 04:31:21 AM »

Is it possible to have the same engine effect of shipsystems like Maneuver Jets - where engines that are hidden (contrail = 128) appear, and do them with hullmods?

I tried adding the following code inside the hullmod's advanceInCombat() function:

Code
			ship.getEngineController().fadeToOtherColor(this, color, null, 1f, 0.4f);
ship.getEngineController().extendFlame(this, 0.25f, 0.25f, 0.25f);


            ship.getEngineController().getExtendLengthFraction().advance(amount * 2f);
            ship.getEngineController().getExtendWidthFraction().advance(amount * 2f);
            ship.getEngineController().getExtendGlowFraction().advance(amount * 2f);
for (ShipEngineAPI shipengine : ship.getEngineController().getShipEngines()) {
ship.getEngineController().setFlameLevel(shipengine.getEngineSlot(), 1f);
}

However, aside from the changing the color and making the already visible-by-default engines spikier, it had no effect. I made sure it would be obvious by adding tons of hidden engines, but none appear.
Logged

Hoon

  • Ensign
  • *
  • Posts: 11
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5966 on: January 22, 2020, 05:03:00 AM »

Is there a tag to hide weapons in the Codex? I know for hulls/ships the tag is called HIDE_IN_CODEX, but when I apply this tag in weapons.csv it just crashes the game.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5967 on: January 22, 2020, 08:01:38 AM »

Why can't I add a condition to a PlanetConditionMarket during a dialog?


Is there a tag to hide weapons in the Codex? I know for hulls/ships the tag is called HIDE_IN_CODEX, but when I apply this tag in weapons.csv it just crashes the game.

SYSTEM is the tag you are looking for. IIRC it has some other effects that I can't recall atm, though.
Logged

Alex

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

Is it possible to have the same engine effect of shipsystems like Maneuver Jets - where engines that are hidden (contrail = 128) appear, and do them with hullmods?

Pretty sure those are keyed off the system being active. You might be able to just hide them yourself with code, though, maybe?  I.E. set flameLevel to 0. Haven't looked in that area of the code in a while so not 100% sure.

Why can't I add a condition to a PlanetConditionMarket during a dialog?

Hmm? The PlanetConditionMarket class is internal to the core code and only ever exists when stuff is put into a savefile, in a running game, all planets use the normal Market class under the hood, though it returns true for isPlanetConditionMarketOnly(). So I'm assuming you mean the latter case.

But, could you clarify what "can't" means? That could range from "crash" to "UI doesn't update" to ... a lot of things. Without more info, I can't really say.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #5969 on: January 22, 2020, 09:09:33 AM »

Why can't I add a condition to a PlanetConditionMarket during a dialog?

Hmm? The PlanetConditionMarket class is internal to the core code and only ever exists when stuff is put into a savefile, in a running game, all planets use the normal Market class under the hood, though it returns true for isPlanetConditionMarketOnly(). So I'm assuming you mean the latter case.

But, could you clarify what "can't" means? That could range from "crash" to "UI doesn't update" to ... a lot of things. Without more info, I can't really say.

Yes, I meant the latter, sorry.

Did better testing and found the problem: each BaseHazardCondition requires a condition_gen_data entry. I feel like that should be called out with a comment in BaseHazardCondition.java.
Logged
Pages: 1 ... 396 397 [398] 399 400 ... 706