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 ... 314 315 [316] 317 318 ... 706

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

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4725 on: July 24, 2019, 10:58:56 PM »

How does that interact with other mods that might add portrait by appending to the base file?

It'll override whatever they're doing.

General modding etiquitte tip: Don't do this.  ;D



@xenoargh: Oof. That's complexity beyond my comprehension unfortunately. Definitely a lost cause.
« Last Edit: July 24, 2019, 11:13:29 PM by AxleMC131 »
Logged

Nia Tahl

  • Admiral
  • *****
  • Posts: 790
  • AI in disguise
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4726 on: July 25, 2019, 05:18:46 AM »

Is there any method to force a ship's shield to remain deployed while the ship system is active? Working on a system that provides a significant boost to shield effectiveness, but I'd like it to lock you into that for the full duration so you can get punished by overloading if you yolo into heavy fire with it.

Edit: Nevermind, found this:
Code
ship.blockCommandForOneFrame(ShipCommand.TOGGLE_SHIELD_OR_PHASE_CLOAK);
« Last Edit: July 25, 2019, 05:50:45 AM by Nia Tahl »
Logged
My mods: Tahlan Shipworks - ScalarTech Solutions - Trailer Moments
It's all in the presentation

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4727 on: July 25, 2019, 06:26:53 AM »

Complaint
I recently had a bug which resulted from ActionStage's enoughMadeIt() check not taking into account whether the fleet was spawned with ignoreMarketFleetSizeMult, when calculating how many ships made it vs. how many should have. This means that a sufficiently high fleet size mult on the origin market will cause the stage to fail even if no fleet took any losses.

It's pretty straightforward to add my own check in derived classes, but might be good for the vanilla code to do it as well. Perhaps mark the fleet as having ignored size mult as a memory flag, then have enoughMadeIt() check for that?

Question
How many things in vanilla currently use MemFlags.FLEET_BUSY?

I was trying to make a RaidAssignmentAI/RouteFleetAssignmentAI not constantly replace the fleet's current assignment with the default assignment (whatever is using getRaidDefaultText())
without marking the fleet as busy.
I didn't want to make the fleet busy because some of my other stuff checks busy state. Specifically, I have a "follow me" fleet ability that makes nearby friendly fleets follow the player around, but not if they're busy. But now I'm thinking I may need to have the ability make the affected fleets busy, so they don't run off to do other things.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4728 on: July 25, 2019, 07:37:03 AM »

A quick grep of the API reveals that MemFlags.FLEET_BUSY is referred to in seven files. 

At a glance (and forgive me for glossing over the logic it's presented in here; this is an area of the game I haven't looked at since I refactored Exerelin years ago) it looks like the best route might be to give them that flag (as you were saying at the end there) and assign them to follow the target (in this case, the player's CampaignFleetAPI). 

It appears that MemFlags.FLEET_BUSY is being used to prevent subsystems of the AI state machine from interrupting a given behavioral state until it exits and un-sets the flag.
« Last Edit: July 25, 2019, 07:40:55 AM by xenoargh »
Logged
Please check out my SS projects :)
Xeno's Mod Pack

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4729 on: July 25, 2019, 07:52:43 AM »

@AxleMC:

Try this, maybe?

ShipVariantAPI thisVariant = stats.getVariant();
ShipVariantAPI thisModuleVariant = Global.getSettings().getVariant("variant_we_want");
if (thisModuleVariant != null)
thisVariant.setModuleVariant("weapon_slot_you_wanna_change_module_for", thisModuleVariant);
thisVariant.setSource(VariantSource.REFIT);

That might satisfy all the requirements.  The UI stuff is (probably!) not necessary in a Refit context.  If that doesn't work, I'm guessing that it just doesn't work there, period, because the data's getting overwritten with a clone of the original Variant by Alex's code in a later operation you can't observe.
Logged
Please check out my SS projects :)
Xeno's Mod Pack

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4730 on: July 25, 2019, 12:06:42 PM »

EDIT: I guess the real question I'm asking is: "What is the difference between sorting, inflating, and syncing a fleet (with setOnlySyncMemberLists enabled vs disabled) and what do each of those actually do/what logic do they use/when do they happen?"  :P
« Last Edit: July 25, 2019, 01:05:43 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4731 on: July 25, 2019, 01:10:18 PM »

Complaint
I recently had a bug which resulted from ActionStage's enoughMadeIt() check not taking into account whether the fleet was spawned with ignoreMarketFleetSizeMult, when calculating how many ships made it vs. how many should have. This means that a sufficiently high fleet size mult on the origin market will cause the stage to fail even if no fleet took any losses.

It's pretty straightforward to add my own check in derived classes, but might be good for the vanilla code to do it as well. Perhaps mark the fleet as having ignored size mult as a memory flag, then have enoughMadeIt() check for that?

Ahh, that's a really good point. Added a $spawnFPMult to fleet memory; this is set in FleetFactoryV3 and is the number-of-ships multiplier. So in enoughMadeIt() that's used instead of checking the market's value.


Question
How many things in vanilla currently use MemFlags.FLEET_BUSY?

I was trying to make a RaidAssignmentAI/RouteFleetAssignmentAI not constantly replace the fleet's current assignment with the default assignment (whatever is using getRaidDefaultText())
without marking the fleet as busy.
I didn't want to make the fleet busy because some of my other stuff checks busy state. Specifically, I have a "follow me" fleet ability that makes nearby friendly fleets follow the player around, but not if they're busy. But now I'm thinking I may need to have the ability make the affected fleets busy, so they don't run off to do other things.

Hmm - a bunch? Stuff like capturing comm relays etc in the campaign, pirates investigating dropped-off cargo pods, a couple of other things. Basically anything specific that tells the rest of the game not to co-opt the fleet for something *else* specific.

For what you're doing it sounds like you want to make the affected fleets "busy", yeah. You could also not co-opt fleets that are *already* busy doing something else, so as not to interrupt that.

There's a check you can do why a fleet is busy:
if (Misc.flagHasReason(mem, MemFlags.FLEET_BUSY, <your busy reason string>))

So if that returns true, you'd know that the fleet is busy because you grabbed it already and can keep giving it the follow assignment, for example.



EDIT: I guess the real question I'm asking is: "What is the difference between sorting, inflating, and syncing a fleet (with setOnlySyncMemberLists enabled vs disabled) and what do each of those actually do/what logic do they use?"  :P

Sorting changes to order to largest -> smallest. It will also sync the fleet if it needs to.

Inflating has nothing to do with it and just adjusts fleet member variants.

Syncing a fleet with setOnlySyncMemberLists does member.setFleetData() for all the members, and also sorts the fleet from largest to smallest.

Syncing without setOnlySyncMemberLists does the same thing, and in addition updates the stats of all the fleet members (i.e. taking hullmods into account), and recomputes certain fleetwide stats (such as burn level, various capacities, total fleet points, etc). This happens automatically, i.e. when you add or remove a fleet member, the fleet will be marked as needing to be synced, and will be synced next time an operation that requires the synced data is called.
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4732 on: July 25, 2019, 01:13:43 PM »

Sorting changes to order to largest -> smallest. It will also sync the fleet if it needs to.

Inflating has nothing to do with it and just adjusts fleet member variants.

Syncing a fleet with setOnlySyncMemberLists does member.setFleetData() for all the members, and also sorts the fleet from largest to smallest.

Syncing without setOnlySyncMemberLists does the same thing, and in addition updates the stats of all the fleet members (i.e. taking hullmods into account), and recomputes certain fleetwide stats (such as burn level, various capacities, total fleet points, etc). This happens automatically, i.e. when you add or remove a fleet member, the fleet will be marked as needing to be synced, and will be synced next time an operation that requires the synced data is called.

Awesome, this is really helpful, thanks. What defines "largest -> smallest"? HullSize and then Fleet Points?
« Last Edit: July 25, 2019, 01:48:08 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4733 on: July 25, 2019, 01:15:09 PM »

Hah, that's exactly right, actually.
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4734 on: July 25, 2019, 01:49:02 PM »

Intuitive! :)

If a fleet automatically sorts whenever it's synced, and syncs whenever it's changed, is there any way to guarantee a specific ship will always be the flagship (until it's destroyed, of course) even if/when there are larger ships in the fleet?
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4735 on: July 25, 2019, 02:40:51 PM »

These don't affect the flagship, at least as it's displayed in the fleet tooltip/interaction dialog/etc. What member.isFlagship() may or may not be affected, not 100% sure.

Example:
Code: java
for (FleetMemberAPI member : fleet.getFleetData().getMembersListCopy()) {
if (member.isFrigate()) {
fleet.getFleetData().setFlagship(member);
break;
}
}
fleet.getFleetData().setSyncNeeded();
fleet.getFleetData().syncIfNeeded();
fleet.getFleetData().sort();

After this code runs, the flagship is still a frigate.
Logged

Vayra

  • Admiral
  • *****
  • Posts: 627
  • jangala delenda est
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4736 on: July 25, 2019, 03:51:49 PM »

Wild! Okay, thanks. I might have been trying to solve a problem that isn't there, in that case.  8)

EDIT: Wait, a small flagship will still be sorted to the bottom then though? Or nah.
« Last Edit: July 25, 2019, 03:53:50 PM by Vayra »
Logged
Kadur Remnant: http://fractalsoftworks.com/forum/index.php?topic=6649
Vayra's Sector: http://fractalsoftworks.com/forum/index.php?topic=16058
Vayra's Ship Pack: http://fractalsoftworks.com/forum/index.php?topic=16059

im gonna push jangala into the sun i swear to god im gonna do it

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4737 on: July 25, 2019, 04:16:52 PM »

The flagship has a "star in a circle" icon and its position in the fleet sort order is not affected by its status. If it's a frigate, it'll be with the other frigates, etc.
Logged

AxleMC131

  • Admiral
  • *****
  • Posts: 1722
  • Amateur World-Builder
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4738 on: July 25, 2019, 11:14:05 PM »

@AxleMC:

Try this, maybe?

ShipVariantAPI thisVariant = stats.getVariant();
ShipVariantAPI thisModuleVariant = Global.getSettings().getVariant("variant_we_want");
if (thisModuleVariant != null)
thisVariant.setModuleVariant("weapon_slot_you_wanna_change_module_for", thisModuleVariant);
thisVariant.setSource(VariantSource.REFIT);

That might satisfy all the requirements.  The UI stuff is (probably!) not necessary in a Refit context.  If that doesn't work, I'm guessing that it just doesn't work there, period, because the data's getting overwritten with a clone of the original Variant by Alex's code in a later operation you can't observe.

Yeah that doesn't work either unfortunately. Darn. Thanks for the try anyway.
Logged

xenoargh

  • Admiral
  • *****
  • Posts: 5078
  • naively breaking things!
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #4739 on: July 26, 2019, 08:43:54 AM »

Sorry man, I think that's about all I could see there.  That leaves... direct manipulation of the CampaignFleetAPI member's Variant through an EveryFrameScript, I'm afraid (i.e., a hard, non-fun and non-intuitive-for-players way).
Logged
Please check out my SS projects :)
Xeno's Mod Pack
Pages: 1 ... 314 315 [316] 317 318 ... 706