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 ... 448 449 [450] 451 452 ... 706

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

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6735 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

  • Commander
  • ***
  • Posts: 177
  • Grand Admiral of the Galactic Empire
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6736 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6737 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 #6738 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

  • Captain
  • ****
  • Posts: 400
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6739 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....
Logged
Mod: Persean Chronicles | Mod Manager: SMOL | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6740 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

  • Captain
  • ****
  • Posts: 400
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6741 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!
Logged
Mod: Persean Chronicles | Mod Manager: SMOL | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Wispborne

  • Captain
  • ****
  • Posts: 400
  • Discord: wispborne
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6742 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
Logged
Mod: Persean Chronicles | Mod Manager: SMOL | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6743 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 #6744 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: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6745 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: 23986
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6746 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

Morrokain

  • Admiral
  • *****
  • Posts: 2143
  • Megalith Dreadnought - Archean Order
    • View Profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6747 on: August 20, 2020, 03:42: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.

I figured that was probably the case, but it was fun thinking through how I would calculate the strength! :)

----------------------------------------------

I just finished setting up logging behavior on a couple scripts that remove the Open Market submarket and Black Market submarket from some entities' MarketAPI.

Just wanted to know if, to anyone's recollection or experience, that would cause any problems anywhere. It doesn't seem to but I'm not deep testing it so figured I'd inquire about it.

As a side question: Where would I look for an example, or is it even possible, to manually edit the contents/restrictions of the military market, and to what degree?
Logged

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
Re: Misc modding questions that are too minor to warrant their own thread
« Reply #6748 on: August 20, 2020, 07:34:27 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!
If they don't need to be recruitable, there are a couple of easier examples for generating an arbitrary person and assign them as admin on a colony, or change the existing admin's name and portrait. Look at CoreLifecyclePluginImpl.assignCustomAdmins() for the first, or this for the second.

I just finished setting up logging behavior on a couple scripts that remove the Open Market submarket and Black Market submarket from some entities' MarketAPI.

Just wanted to know if, to anyone's recollection or experience, that would cause any problems anywhere. It doesn't seem to but I'm not deep testing it so figured I'd inquire about it.

As a side question: Where would I look for an example, or is it even possible, to manually edit the contents/restrictions of the military market, and to what degree?
Removing submarkets is fine in my experience. It may cause problems for mod scripts that expect those submarkets to be there, but since there's no assurance of that (e.g. player markets don't generally have either) that's something for said mod to fix.

Changing military market contents: You either have to replace the submarket plugin (pretty mod-conflicty), or else do some hax to detect when the submarket contents should be updated and modify its cargo directly. tiandong_EventListener has an example.
Changing commission/relationship restrictions requires a plugin replacement.
« Last Edit: August 20, 2020, 07:39:11 PM by Histidine »
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 #6749 on: August 20, 2020, 09:03:57 PM »

Removing submarkets is fine in my experience. It may cause problems for mod scripts that expect those submarkets to be there, but since there's no assurance of that (e.g. player markets don't generally have either) that's something for said mod to fix.

Changing military market contents: You either have to replace the submarket plugin (pretty mod-conflicty), or else do some hax to detect when the submarket contents should be updated and modify its cargo directly. tiandong_EventListener has an example.
Changing commission/relationship restrictions requires a plugin replacement.

Ah ok thanks! As far as military markets, I'm not going to replace the plugin as that would conflict and be difficult to support most likely. I may take a look at the Tiandong script as an example if I wanted to add specific stuff there in the future, but for now the default behavior is good enough for what I'm trying to do.
Logged
Pages: 1 ... 448 449 [450] 451 452 ... 706