Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 448 449 [450] 451 452 ... 467

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

WarStalkeR

  • Captain
  • ****
  • Posts: 343
  • Per Aspera Ad Astra!
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6735 on: August 10, 2020, 12:56:23 AM »

Were any feature added that allows me to limit specific weapons to specific ships? I.e. faction A ships can only use faction A weapons.
Logged

"Happiness for everybody, freely, and let no one to leave unhappy!" (c) Strugatsky Brothers
Independent Defense Force is here! And they already in Sector Xplo.

N1MH

  • Ensign
  • *
  • Posts: 18
    • View Profile
    • Email
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6736 on: August 10, 2020, 06:51:50 AM »

As far as I know, there isn't a feature like that in the current version.

A crude workaround you could use is to hand-make the variants yourself and limit the factions to using 'em only via the variantOverrides section in the .faction file.
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 1603
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6737 on: August 12, 2020, 02:02:17 PM »

Is it safe, generally speaking, to modify market industries/conditions/stations during a save load from:

Code
    public void onGameLoad(boolean newGame)

Where newGame is false?

I'm going to all of this trouble so that I can create settings configuration to be able to "enable/disable" vanilla content very, very easily and without any technical skill. So I can preserve the TC experience as the default whilst simultaneously providing a user the option to have a full toybox if that is what they would prefer.

All of this seems to be working correctly from the perspective of disabling components through settings config. I now need to add the logic to re-enable everything and I was hoping I could mostly do that between saves rather than just on a new game.

Anything that deals with a SpecAPI doesn't need this as its read and configured every application start, but for things like knownShips, market components like industries, etc, those are obviously captured and loaded as is when a save is loaded.

As a side note to that, are there any economy-based methods that will for sure need to be called when doing this? For instance, I already call MarketAPI.reapplyIndustries() and MarketAPI.reapplyConditions() respectively - just to be safe.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17422
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6738 on: August 12, 2020, 04:09:57 PM »

Are beams that pierce depending on the targets "soft flux" possible? Such as the way the ion beam does it (with hard flux), but able to do so even if the enemy only has soft flux.

Examples for clarity:

I shoot a Enforcer with >60% flux (soft and hard), the beam pierces.

I shoot a ship that has <50% flux, the beam fails to pierce.

Modded Beam fires at Hammerhead with >70% SOFT flux, it pierces due to script attached to modded beam.

TL;DR: can one make beam that pierce shield depending on enemy overall flux, not just hard

Yeah - take a look at, say, com.fs.starfarer.api.impl.combat.IonBeamEffect.

Is it safe, generally speaking, to modify market industries/conditions/stations during a save load from:

...

As a side note to that, are there any economy-based methods that will for sure need to be called when doing this? For instance, I already call MarketAPI.reapplyIndustries() and MarketAPI.reapplyConditions() respectively - just to be safe.

Yes, it should be fine. Also, you don't necessarily need to worry about calling reapplyIndustries() etc unless you're doing something that depends on all the colony values being in sync. It'll get called fairly frequently (at least once every 3 days, and on every market interaction) anyway. But if you want to be sure, you can just call EconomyAPI.tripleStep() when you're doing making your changes, that *should* sync it all up. But, again, it probably doesn't matter since it'll happen soon anyway.
Logged

BeyondTheHorizon

  • Ensign
  • *
  • Posts: 20
  • Grand Admiral of the Galactic Empire
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6739 on: August 16, 2020, 06:20:13 AM »

Why is there glowing contrails like ship engine behind my laser projectiles? I have already set glow radius to 0 in .proj but nothing have changed.

Spoiler
[close]
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17422
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6740 on: August 17, 2020, 11:54:58 AM »

IIRC the glow is a circular glow around the front of the projectiles. what you're seeing is not a contrail, it's part of the projectile visual.
Logged

Potkin

  • Ensign
  • *
  • Posts: 1
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6741 on: August 17, 2020, 10:15:36 PM »

Ihave an idea for a mod but no idea how to do it or even if its possible. Idea is make me and some friends represented in the game as administrators/officers that can be found on specific planets. Is it possible? If yes can anyone point me in the right direction? Any help is appreciated thanks.
Logged

Wispborne

  • Commander
  • ***
  • Posts: 113
  • Discord: Wisp#0302
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6742 on: August 18, 2020, 06:59:21 PM »

Is there a way to register multiple ModPlugins?

Simply put, I'd like to have the initial ModPlugin verify that the mod's prerequisites are met, then bootstrap the other mod plugin once that's done. Alternatively, have one ModPlugin have its onApplicationLoad get called before the other.

There are workarounds; I could have my verification ModPlugin act as a wrapper for my main plugin, passing through lifecycle method calls. Or I could simply move all of the login in my main plugin into the verification plugin. It'd be cleaner, though, to be able to programmatically add the main modplugin at runtime.

I tried using
Code
Global.getSettings().getModManager().getEnabledModPlugins().add(new LifecyclePlugin());
but it throws a ConcurrentModificationException. Not surprised, it's only meant as a getter.


The less simple reason that I'm trying this is because my main modplugin is in Kotlin, which requires that LazyLib be present or else the class won't even load (LazyLib has the Kotlin runtime) - it crashes during instantiation. I can write a ModPlugin in Java that checks for LazyLib, then bootstraps the Kotlin ModPlugin. And yes, I coulllllld move the logic from the kotlin modplugin to the java one, but....

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17422
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6743 on: August 18, 2020, 07:03:36 PM »

Ihave an idea for a mod but no idea how to do it or even if its possible. Idea is make me and some friends represented in the game as administrators/officers that can be found on specific planets. Is it possible? If yes can anyone point me in the right direction? Any help is appreciated thanks.

Hmm, take a look at the OfficerManagerEvent source. You'll need to have a reasonable understanding of Java, though!


Is there a way to register multiple ModPlugins?

There isn't, sorry! In the next release, you'd be able to specify LazyLib as a hard dependency, though, so that it wouldn't even be possible to enable your mod when that's not present and enabled.
Logged

Wispborne

  • Commander
  • ***
  • Posts: 113
  • Discord: Wisp#0302
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6744 on: August 18, 2020, 07:11:52 PM »

Is there a way to register multiple ModPlugins?

There isn't, sorry! In the next release, you'd be able to specify LazyLib as a hard dependency, though, so that it wouldn't even be possible to enable your mod when that's not present and enabled.

Thanks! I'm going with the wrapper method, calling the lifecycle methods in the kotlin plugin from the java one and it's working just fine.

Looking forward to hard dependencies!

Wispborne

  • Commander
  • ***
  • Posts: 113
  • Discord: Wisp#0302
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6745 on: August 18, 2020, 08:06:24 PM »

Followup: Turns out that missing LazyLib was crashing before onApplicationLoad, when loading my rule script defined in rules.csv! It's written in Kotlin, too, and crashes because the Kotlin runtime provided by LazyLib is missing.

So, I created a new dummy rule that loads before my rule (with no triggers or anything, just a script), added a check for LazyLib in the dummy script constructor and threw an exception if it was missing...but it seems that the game treats any exception thrown when initializing the class as "the rule is missing".

Code
    public DearPlayer_PleaseAdd_LazyLib_ToUseGatesAwakened() {
        super();

        if (!Global.getSettings().getModManager().isModEnabled(MiscKt.LazyLibId)) {
            throw new NullPointerException("LazyLib is required to run Gates Awakened.");
        }
    }

So what happens is this crashes if LazyLib is missing (which we want), but instead of displaying "LazyLib is required to run Gates Awakened.", it displays
Code
com.fs.starfarer.api.util.RuleException: java.lang.RuntimeException: Command [DearPlayer_PleaseAdd_LazyLib_ToUseGatesAwakened] not found in packages:
https://i.imgur.com/FM3DjIc.png

However, if that exception isn't thrown, then no error is displayed and the rule script is loaded.

And so...I named the class "DearPlayer_PleaseAdd_LazyLib_ToUseGatesAwakened", and hopefully it's enough of a cue to get the message across :D

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17422
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6746 on: August 18, 2020, 10:20:24 PM »

Hah, that's the kind of creativity I like to see :)
Logged

Julio Montega

  • Ensign
  • *
  • Posts: 12
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6747 on: August 20, 2020, 01:26:15 AM »

Hi there,
how do i get the game to colour the name of a system on the starmap to match the most powerful faction in that system?
The reason behind that question, is that i find the toggle "inhabited" on the starmap to be counterproductive.
I want to know the system name, even it is uninhabited, but i either have to live with only inhabited systems being named, or all.

I'd love to change that, so generally all system names are shown and the toggle just recolours inhabited system names matching the most powerful colony/faction inside that system.

I didn't find any existing mods for that.
So how'd i start modding this in?
Logged

Morrokain

  • Admiral
  • *****
  • Posts: 1603
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6748 on: August 20, 2020, 12:19:15 PM »

Hi there,
how do i get the game to colour the name of a system on the starmap to match the most powerful faction in that system?
The reason behind that question, is that i find the toggle "inhabited" on the starmap to be counterproductive.
I want to know the system name, even it is uninhabited, but i either have to live with only inhabited systems being named, or all.

I'd love to change that, so generally all system names are shown and the toggle just recolours inhabited system names matching the most powerful colony/faction inside that system.

I didn't find any existing mods for that.
So how'd i start modding this in?

Assuming modders have access to that system at all (I'm not sure they do but someone else will have to confirm because I've never tried) you would have to create your own logic to determine which faction is the most powerful in the system.

It certainly wouldn't be simple, though, even assuming all the necessary API hooks are there.

How I would do this (at least to start as a first pass on the problem):

Spoiler
- Define an Integer (default 0 and not an int because you will be using a map and that doesn't allow primitives as keys) for each faction (name the Integer the faction name).

- Iterate though each market by getting the market list for that system and setting up a switch to to check the factionid of the owning faction. At each switch segment, pass in the faction Integer determined from checking the factionid for that market into a strength calculation method.

- The strength calculation method would do things like add predetermined int values to the Integer based upon things like market size, resource quality, presence of a military base or high command, presence of stations, etc. These values represent the weight of each component of the strength calculation to determine total strength. Return the modified Integer (which now represents the strength of that particular faction in the system) to the primary class method. (Where the switch was)

- After all the markets have been calculated this way, add each faction Integer to a map with the Integer as the key and the faction id as the value returned from the key.

- Sort the Integers to where the first value is the highest. This can be done many different ways. One example is to put them all in an array and use the bubble sort method, for instance. Each sorting method has pros and cons and performance considerations.

- Using your map, get the faction id by passing in the highest Integer you just found into the get(key) method.

- Using the faction id (which now represents the id of the strongest faction in the system) get the FactionAPI for that faction.

- You can get the faction's color from the factionAPI, iirc.

- Add that color to the UI for the system (again, if that is possible)
[close]

There are probably things wrong with that implementation and the whole thing might cause performance problems considering the number of iterations that would likely have to be done, but if I had to figure out a way to do it that is how I would probably start going about it.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 17422
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6749 on: August 20, 2020, 12:22:57 PM »

Ah, yeah, that's not something that's moddable - most core UI things that aren't implemented as some kind of interaction dialog generally aren't.
Logged
Pages: 1 ... 448 449 [450] 451 452 ... 467