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 ... 561 562 [563] 564 565 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8430 on: January 20, 2022, 09:33:41 AM »

Ah - thank you for clarifying. Hmm, I'm not even sure that was ever intentional, might have been some kind of fallback code - but regardless, I don't think this can be done now, sorry!
Logged

itBeABruhMoment

  • Commander
  • ***
  • Posts: 157
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8431 on: January 21, 2022, 01:19:14 PM »

How do you determine if a ship is officered from its FleetMemberAPI? I couldn't find a chain of methods ending with some sort of "hasOfficer" method.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8432 on: January 21, 2022, 02:49:21 PM »

Check out com.fs.starfarer.api.impl.campaign.skills.WolfpackTactics.isFrigateAndOfficer()

Note that the isDefault() method will also return false if the person is isAICore(), if that's a meaningful distinction for you.
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8433 on: January 22, 2022, 01:18:14 AM »

If I'm getting a stack overflow on trying to save my game, what would be a good way to find what's causing it?
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8434 on: January 22, 2022, 10:01:46 AM »

Presumably, you're getting a stack trace to go along with it? It's either going to be infinite recursion, which you can usually tell from the trace where it happens, or, if that's not it, it's probably the stack legitimately being too large for the amount of memory allocated to it, in which case increasing the (off the top of my head) -Xss would be the solution.
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 #8435 on: January 22, 2022, 10:03:47 AM »

Is DMOD_EFFECT_MULT currently modifiable using MutableFleetStatsAPI? Using modifyMult or modifyPercent doesn't seem to do anything:

Code
    public static final float DMOD_EFFECT_REDUCTION = 0.5f;

    MutableFleetStatsAPI.getDynamic().getMod(Stats.DMOD_EFFECT_MULT).modifyMult(id, DMOD_EFFECT_REDUCTION);

I've also tried:

Code
    public static final float DMOD_EFFECT_REDUCTION = 50f;

    MutableFleetStatsAPI.getDynamic().getMod(Stats.DMOD_EFFECT_MULT).modifyPercent(id, -DMOD_EFFECT_REDUCTION);

And I've also tried MutableFleetStatsAPI.getDynamic().getStat(Stats.DMOD_EFFECT_MULT) just in case - though I'd think this was a mod and not a stat.

The test for this is Faulty Power Grid since its easier to see whether the max flux is reduced by 20% or 10% with the skill.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8436 on: January 22, 2022, 10:15:11 AM »

No, it's not a fleet stat. Generally if you look at the source of Stats.java the variables are grouped together by what kind of thing they affect, and there's some comments explaining what section is for what.
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 #8437 on: January 22, 2022, 10:39:03 AM »

No, it's not a fleet stat. Generally if you look at the source of Stats.java the variables are grouped together by what kind of thing they affect, and there's some comments explaining what section is for what.

Ah I missed:

   // ships

At the top of that list!  Thanks for clarifying.

Hmm, can you think of anything off hand that would go wrong if I created an everyFrameScript that did nothing but had public methods to apply/unapply this affect to all ships in the fleet?

Nvm, as I was typing this I immediately thought of one: it wouldn't handle a player adding or removing ships from the fleet unless I set up some kind of tracker and that's already getting too complicated. I'll just find a better effect for the skill.
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 #8438 on: January 22, 2022, 12:06:05 PM »

No, it's not a fleet stat. Generally if you look at the source of Stats.java the variables are grouped together by what kind of thing they affect, and there's some comments explaining what section is for what.

Sorry for the follow up post but I'm curious as to why implementing the same logic using ShipSkillEffect in order to access MutableShipStatsAPI instead of MutableFleetStatsAPI and then setting the script to run with ALL_SHIPS_IN_FLEET also doesn't seem to work.

It know that process works with other skills.

And I also tried modifying it with just the ship with the officer. Still doesn't seem to work.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8439 on: January 22, 2022, 12:09:29 PM »

Sorry for the follow up post but I'm curious as to why implementing the same logic using ShipSkillEffect in order to access MutableShipStatsAPI instead of MutableFleetStatsAPI and then setting the script to run with ALL_SHIPS_IN_FLEET also doesn't seem to work.

It know that process works with other skills.

As you say, it works with other skills, so the most likely answer is you didn't set something up correctly.

In particular, make sure that ALL_SHIPS_IN_FLEET is specified for that effect in the .skill file, too.
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 #8440 on: January 22, 2022, 01:18:47 PM »

As you say, it works with other skills, so the most likely answer is you didn't set something up correctly.

In particular, make sure that ALL_SHIPS_IN_FLEET is specified for that effect in the .skill file, too.

Hmm, no, after extensive testing I'm 99.9% sure that this just doesn't work as intended. :( I changed it to only affect the flagship and added functionality test controls:

Code
# control 1 - ensures things are applied to flagship correctly - should make shield efficiency 0.8 instead of 1.0
"scope":"PILOTED_SHIP",
"effectGroups":[
{
"requiredSkillLevel":1,
"effectBasedOnLevel":false,
"effects":[
#{"type":"CHARACTER_STATS", "script":"data.scripts.skills.ArcheusFieldRepairs$Level1"},
#{"type":"ALL_SHIPS_IN_FLEET", "script":"data.scripts.skills.ArcheusFieldRepairs$Level2"},
{"type":"SHIP", "script":"data.scripts.skills.ArcheusFieldRepairs$Level5"},
{"type":"SHIP", "script":"com.fs.starfarer.api.impl.campaign.skills.ShieldModulation$Level2"},
]
},

Code
	public static class Level5 implements ShipSkillEffect {
public void apply(MutableShipStatsAPI stats, HullSize hullSize, String id, float level) {
stats.getDynamic().getMod(Stats.DMOD_EFFECT_MULT).modifyMult(id, 1 - DMOD_EFFECT_REDUCTION / 100);
stats.getMaxSpeed().modifyFlat(id, (1 - DMOD_EFFECT_REDUCTION / 100) * 10);
}

public void unapply(MutableShipStatsAPI stats, HullSize hullSize, String id) {
stats.getDynamic().getMod(Stats.DMOD_EFFECT_MULT).unmodify(id);
stats.getMaxSpeed().unmodify(id);
}

public String getEffectDescription(float level) {
return "Reduces the negative effects of d-mods by " + (int) DMOD_EFFECT_REDUCTION + "%";
}

public String getEffectPerLevelDescription() {
return null;
}

public ScopeDescription getScopeDescription() {
return ScopeDescription.ALL_SHIPS;
}
}

 // control 2 and math double check - should raise test speed by 4 after degraded engines factored in and proves that data.scripts.skills.ArcheusFieldRepairs$Level5 is being ran

Results: (I even tested in the simulator to make sure it wasn't just the tooltip not being updated.)

Spoiler



[close]

 - It doesn't show up in the officer tooltip because CombatOfficer isn't set to TRUE in skill_data.csv, but that doesn't prevent the actual effects from taking place as is verified by shield modulation level 2 being applied correctly as well as the small speed boost by my script. I also tested modifyPercent() and getStat() instead of getMod() under these conditions. Same results.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8441 on: January 22, 2022, 03:33:52 PM »

What am I looking at that shows the dmod effect multiplier not applying?

Rugged Construction works, and the effects of skills are applied before hullmods, so I strongly suspect you've got something hooked up wrong somewhere.

Also, of note, you've got this:
{"type":"SHIP", "script":"data.scripts.skills.ArcheusFieldRepairs$Level5"},

Which does not match what you've been saying about wanting it to apply fleetwide.
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 #8442 on: January 22, 2022, 04:27:36 PM »

What am I looking at that shows the dmod effect multiplier not applying?

Rugged Construction works, and the effects of skills are applied before hullmods, so I strongly suspect you've got something hooked up wrong somewhere.

The negative armor malus is unaffected while the speed has been boosted slightly (in the code they are both applied at the same time so if one runs the other also has to run). I explain in the comments of the code what results I'm expecting for the controls, but based on the d-mods on the ship there should be changes to the armor, flux and speed values once the officer is added on.

So, essentially, I was applying the shield modulation effect in the same skill effect group in the json to make sure I knew that if that applied then it was at least attempting to apply the d-mod effect.

Then, inside the d-mod effect I was applying a small speed boost using the same final static variable and putting that inside the "apply" portion of the skill extension to make sure it was getting there.

All this boils down to the idea that the issue has to be somewhere in this line:

stats.getDynamic().getMod(Stats.DMOD_EFFECT_MULT).modifyMult()

 - because I know via the controls that all the rest works - including the math that sets the d-mod effect multiplier. So either I needed to use getStat() instead of getMod() as the old Containment Procedures implied in the commented out portion of the code, or attempt to apply the modification using modifyPercent() instead of modifyMult() on even though that would be a bit counter-intuitive.

I tried all of that and nothing seemed to work. But!

*checks Rugged Construction*

Ok I'm going to simply copy paste that line into the skill and check to see if it works. (And also add the relevant "unapply" portion but that shouldn't make a difference for the test.)

I'll post the results back here in a bit.

*EDIT*
Doesn't seem to work according to the tooltip. The speed is the same regardless of the presence of the officer.

Quote
Also, of note, you've got this:
{"type":"SHIP", "script":"data.scripts.skills.ArcheusFieldRepairs$Level5"},

Which does not match what you've been saying about wanting it to apply fleetwide.

I was attempting to apply it to the officer ship first and get that working correctly and then go from there. I understand that I'd need "ALL_SHIPS_IN_FLEET" for a fleetwide effect, etc, sorry if I was being unclear in the change of goal.
« Last Edit: January 22, 2022, 05:19:38 PM by Morrokain »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8443 on: January 22, 2022, 06:51:00 PM »

I didn't have a chance to look in any detail, but one more thing to note: d-mod tooltips actually show you the value *after* the dmod effect modifier is applied, in case that matters.
Logged

SafariJohn

  • Admiral
  • *****
  • Posts: 3010
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #8444 on: January 22, 2022, 07:28:20 PM »

Should perhaps show that like other stats: yellow (+green/-red). In the Roider dev I've done that on a hullmod tooltip to show armor modules' armor and hull stats.
Logged
Pages: 1 ... 561 562 [563] 564 565 ... 706